Skip to content

AI-powered garbage classification using ResNet50 & Gradio, classifies waste images into 6 categories with real-time prediction and visualization.

Notifications You must be signed in to change notification settings

9eek9/garbage-classification

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🗑️ Garbage Classification using ResNet50 & Gradio

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.


⚡ Features

  1. Deep Learning with Transfer Learning
    • Uses ResNet50 pre-trained on ImageNet.
    • Two-phase training: Feature Extraction → Fine-Tuning.
  2. High Accuracy on 6 Waste Classes
    • Achieved 86.72% test accuracy with macro F1-score of 0.87.
  3. Real-Time Inference
    • Gradio UI provides Top‑3 confidence predictions for new images.
  4. Visual Insights
    • Confusion matrix and misclassified images for model analysis.

🖼️ Model Workflow

ResNet50 Workflow


📊 Results

Training & Validation Performance

  • 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

Sample Misclassified Images

  • 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)

Inference on New Images (Top‑3 Confidence)

  • 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

🏗️ How to Run

1️⃣ Clone the Repository

git clone https://github.com/YourUsername/Garbage-Classification.git
cd Garbage-Classification

2️⃣Create and activate a virtual environment (Optional):

python -m venv venv
# macOS/Linux
source venv/bin/activate
# Windows
venv\Scripts\activate

3️⃣Install dependencies:

pip install -r requirements.txt

4️⃣ Run Gradio App:

python app.py

Gradio will launch a local server and provide a link for the web interface.


🧠 Lessons Learned & Challenges

  1. 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
  2. Visual Similarity between Classes

    • Cardboard vs Paper and Glass vs Metal are the most confusing pairs
  3. Small Dataset for Trash Class

    • Lower representation (22 samples) caused some misclassifications

✨ Future Improvements

  • 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

📜 License

This project is licensed under the MIT License.
Feel free to use and adapt it for academic or commercial purposes.



🌐 Author & GitHub

Developed by: Ei Khaing

📂 GitHub Repository: Click Here


About

AI-powered garbage classification using ResNet50 & Gradio, classifies waste images into 6 categories with real-time prediction and visualization.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published