Idowu Favour
Email: idowufavour07@gmail.com
This project uses a Convolutional Neural Network (CNN) built with PyTorch to classify images of trash into different categories using the TrashNet dataset.
It demonstrates how deep learning can be applied to environmental sustainability and automated waste classification systems.
| Input Image | Prediction |
|---|---|
| Image 1 | Plastic |
| Image 2 | Glass |
| Image 3 | Paper |
- Dataset: TrashNet
- Source: KaggleHub
- Type: Image classification dataset (folder structured)
import kagglehub
path = kagglehub.dataset_download("feyzazkefe/trashnet")The following transformations were applied:
Random horizontal flip Random rotation (±15°) Resize images to 64×64 Convert to tensor Normalize (mean=0.5, std=0.5) Dataset Split 80% Training 20% Testing
A custom CNN model was built with:
Input → Conv → BN → ELU → MaxPool → Conv → BN → ELU → MaxPool → Conv → BN → ELU → MaxPool → Conv → BN → ELU → AdaptiveAvgPool → Fully Connected Layers → Output
Parameter Value Loss Function CrossEntropyLoss Optimizer Adam Learning Rate 0.001 Scheduler StepLR Epochs 50 Device GPU (if available)
Epoch 1 | Loss: ... Epoch 10 | Loss: ... Epoch 50 | Loss: ...
Model evaluation includes:
Test Loss Test Accuracy
Performed using torch.no_grad() for efficiency.
model.pth
To predict a new image:
output = net(img) _, prediction = torch.max(output, 1) print(dataset.classes[prediction.item()])
Trash-Classification/ │ ├── notebook.ipynb ├── model.pth ├── new_images/ └── README.md
pip install torch torchvision pillow kagglehub
Clone repository Install dependencies Run notebook step-by-step Train model Test predictions
Increase image size (64 → 128/224) Use pretrained models (ResNet, EfficientNet) Deploy using Streamlit or Flask Add real-time camera prediction
MIT License
Idowu Favour Email: idowufavour07@gmail.com