File size: 5,329 Bytes
dce9832 2be1a90 dce9832 2be1a90 dce9832 c234c4f 2be1a90 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 |
---
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) |