This project implements an AI-powered garbage classification system using transfer learning with ResNet50.
The system can classify images of waste into 6 categories:
cardboard | glass | metal | paper | plastic | trash
Additionally, a Gradio-based UI is provided for easy image upload and real-time classification with top‑3 confidence scores.
- Deep Learning with Transfer Learning
- Uses ResNet50 pre-trained on ImageNet.
- Two-phase training: Feature Extraction → Fine-Tuning.
- High Accuracy on 6 Waste Classes
- Achieved 86.72% test accuracy with macro F1-score of 0.87.
- Real-Time Inference
- Gradio UI provides Top‑3 confidence predictions for new images.
- Visual Insights
- Confusion matrix and misclassified images for model analysis.
- Training stabilized at ~0.78–0.80 accuracy after 20 epochs
- Smooth loss curve, low overfitting due to data augmentation & early stopping
| Metric | Score |
|---|---|
| Final Test Accuracy | 86.72% |
| Macro F1-score | 0.87 |
| Weighted F1-score | 0.87 |
- Cardboard → Paper: Often occurs for folded or printed cardboard
- Glass → Metal: Glass jars with metallic lids reflect light like metal
- Trash: Most challenging due to few samples (22 images)
- High-confidence Top‑1 predictions (>89%) for clear cases
- Correct class appears in Top‑3 even in ambiguous cases
- Suitable for smart bin or waste sorting system applications
git clone https://github.com/YourUsername/Garbage-Classification.git
cd Garbage-Classification
python -m venv venv
# macOS/Linux
source venv/bin/activate
# Windows
venv\Scripts\activatepip install -r requirements.txtpython app.pyGradio will launch a local server and provide a link for the web interface.
-
Overfitting during Early Experiments
- Initial models overfitted quickly due to the small dataset
- Solution: Added data augmentation, early stopping, and fine-tuning only top ResNet blocks
-
Visual Similarity between Classes
- Cardboard vs Paper and Glass vs Metal are the most confusing pairs
-
Small Dataset for Trash Class
- Lower representation (22 samples) caused some misclassifications
- Add more data for underrepresented classes like Trash
- Use Progressive Fine-Tuning and Test-Time Augmentation (TTA)
- Deploy to smart bins / IoT with PyTorch Mobile or TensorRT
This project is licensed under the MIT License.
Feel free to use and adapt it for academic or commercial purposes.
Developed by: Ei Khaing
📂 GitHub Repository: Click Here


