|
--- |
|
license: mit |
|
language: en |
|
pipeline_tag: image-classification |
|
library_name: pytorch |
|
datasets: mostafaabla/garbage-classification |
|
tags: |
|
- CNN |
|
- Waste-classification |
|
- Image-Classification |
|
--- |
|
|
|
# Model Card for CNN Waste Classification (PyTorch & OpenCV) |
|
|
|
<!-- Provide a quick summary of what the model is/does. --> |
|
|
|
A PyTorch Convolutional Neural Network (CNN) for multi-class waste classification using images. Predicts 10 types of waste from static images or real-time webcam streams, supporting applications in smart recycling, education, and research. Uses OpenCV for image handling. Trained on the modified Kaggle Garbage Classification dataset. |
|
|
|
## Model Details |
|
|
|
### Model Description |
|
|
|
A deep learning model for classifying waste into 10 categories: Battery, Cardboard, Clothes, Food Waste, Glass, Metal, Paper, Plastic, Shoes, and Trash. The model uses 6 convolutional layers with batch normalization, dropout, and two fully connected layers. Developed for learning, prototyping, and proof-of-concept smart recycling systems. |
|
|
|
* **Developed by:** Gokul Seetharaman |
|
* **Model type:** Convolutional Neural Network (CNN) |
|
* **License:** MIT |
|
* **Finetuned from model \[optional]:** Trained from scratch |
|
|
|
### Model Sources \[optional] |
|
|
|
* **Repository:** [https://github.com/gokulseetharaman/cnn-waste-classification-opencv-pytorch](https://github.com/gokulseetharaman/cnn-waste-classification-opencv-pytorch) |
|
* **Dataset:** [https://www.kaggle.com/datasets/mostafaabla/garbage-classification](https://www.kaggle.com/datasets/mostafaabla/garbage-classification) |
|
|
|
## Uses |
|
|
|
### Direct Use |
|
|
|
* Image-based waste detection for smart recycling prototypes |
|
* Educational demonstrations of CNNs, OpenCV, and PyTorch |
|
* Research baselines for waste/material classification |
|
|
|
|
|
|
|
### Recommendations |
|
|
|
Users should evaluate model performance on their own data and consider retraining or fine-tuning for domain-specific use. It is not recommended to use the model for high-stakes applications without further testing. |
|
|
|
## How to Get Started with the Model |
|
|
|
1. Download `best_model.pth` and `object-detection.py` from this repo or [GitHub](https://github.com/gokulseetharaman/cnn-waste-classification-opencv-pytorch). |
|
2. Run `python object-detection.py` for webcam or image predictions. |
|
3. Modify `object-detection.py` to use your own image or video source. |
|
|
|
## Training Details |
|
|
|
### Training Data |
|
|
|
* [Kaggle Garbage Classification dataset](https://www.kaggle.com/datasets/mostafaabla/garbage-classification) |
|
* 10 classes, \~1200 images (split 80/20 train/val) |
|
* Preprocessing: resized to 224x224, normalized, data augmentation (crop, flip, rotation, color jitter, affine) |
|
|
|
### Training Procedure |
|
|
|
* 6 Conv layers, 2 FC layers, dropout, batchnorm |
|
* CrossEntropyLoss, AdamW optimizer, 50 epochs, batch size 8 |
|
|
|
#### Preprocessing \[optional] |
|
|
|
* Images resized to 224x224 |
|
* Normalized with ImageNet means/std |
|
* Random data augmentation on train set |
|
|
|
#### Training Hyperparameters |
|
|
|
* Training regime: fp32 |
|
* Epochs: 50, batch size: 8, optimizer: AdamW, LR: 5e-4 |
|
|
|
#### Speeds, Sizes, Times \[optional] |
|
|
|
* Training time: \~90 minutes on a modern GPU (varies) |
|
* Checkpoint size: \~46MB (`best_model.pth`) |
|
|
|
## Evaluation |
|
|
|
### Testing Data, Factors & Metrics |
|
|
|
#### Testing Data |
|
|
|
* 20% validation split from the Kaggle dataset (stratified) |
|
|
|
#### Factors |
|
|
|
* Performance measured per-class (precision, recall, F1-score, support) |
|
|
|
#### Metrics |
|
|
|
* Overall accuracy, confusion matrix, precision/recall/F1-score per class |
|
|
|
### Results |
|
|
|
* Validation accuracy: **89.56%** |
|
* Most class F1-scores >0.85, with "Plastic" lower due to visual ambiguity |
|
* Full confusion matrix and metrics in [GitHub README](https://github.com/gokulseetharaman/cnn-waste-classification-opencv-pytorch#results) |
|
|
|
#### Summary |
|
|
|
The model reliably classifies 10 types of waste in standard settings. See GitHub for sample images and live demo outputs. |
|
|
|
## Model Examination \[optional] |
|
|
|
* No explicit interpretability/visualization methods (e.g., GradCAM) included yet. |
|
|
|
## Environmental Impact |
|
|
|
* Estimated training: <1.5 GPU-hour, carbon footprint minimal for local or single-GPU cloud runs |
|
* Hardware: NVIDIA GeForce GTX 4060 Laptop GPU |
|
* Hours used: \~1.5 |
|
|
|
|
|
## Technical Specifications \[optional] |
|
|
|
### Model Architecture and Objective |
|
|
|
* See "Model Details" and [GitHub repo](https://github.com/gokulseetharaman/cnn-waste-classification-opencv-pytorch#model-architecture) for the full PyTorch code. |
|
|
|
### Compute Infrastructure |
|
|
|
* Local training with NVIDIA GTX 4060 Laptop GPU, 8GB VRAM, 16GB RAM, Windows 11, Python 3.10 |
|
|
|
#### Hardware |
|
|
|
* GPU: GTX 4060 (or equivalent, optional CPU) |
|
* RAM: 16GB |
|
|
|
#### Software |
|
|
|
* Python 3.10, PyTorch, OpenCV, NumPy |
|
|
|
## Citation |
|
|
|
**BibTeX:** |
|
|
|
```bibtex |
|
@misc{gokulseetharaman2025wastecnn, |
|
title={CNN Waste Classification with OpenCV and PyTorch}, |
|
author={Gokul Seetharaman}, |
|
year={2025}, |
|
url={https://github.com/gokulseetharaman/cnn-waste-classification-opencv-pytorch} |
|
} |
|
``` |
|
|
|
**APA:** |
|
Gokul Seetharaman. (2025). CNN Waste Classification with OpenCV and PyTorch. [https://github.com/gokulseetharaman/cnn-waste-classification-opencv-pytorch](https://github.com/gokulseetharaman/cnn-waste-classification-opencv-pytorch) |
|
|
|
|
|
## Model Card Contact |
|
|
|
[GitHub Issues](https://github.com/gokulseetharaman/cnn-waste-classification-opencv-pytorch/issues) |