Update README.md
Browse files
README.md
CHANGED
@@ -1,11 +1,157 @@
|
|
1 |
---
|
2 |
license: mit
|
3 |
-
language:
|
4 |
-
- en
|
5 |
pipeline_tag: image-classification
|
|
|
|
|
6 |
tags:
|
7 |
- CNN
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
license: mit
|
3 |
+
language: en
|
|
|
4 |
pipeline_tag: image-classification
|
5 |
+
library_name: pytorch
|
6 |
+
datasets: mostafaabla/garbage-classification
|
7 |
tags:
|
8 |
- CNN
|
9 |
+
---
|
10 |
+
|
11 |
+
# Model Card for CNN Waste Classification (PyTorch & OpenCV)
|
12 |
+
|
13 |
+
<!-- Provide a quick summary of what the model is/does. -->
|
14 |
+
|
15 |
+
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.
|
16 |
+
|
17 |
+
## Model Details
|
18 |
+
|
19 |
+
### Model Description
|
20 |
+
|
21 |
+
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.
|
22 |
+
|
23 |
+
* **Developed by:** Gokul Seetharaman
|
24 |
+
* **Model type:** Convolutional Neural Network (CNN)
|
25 |
+
* **License:** MIT
|
26 |
+
* **Finetuned from model \[optional]:** Trained from scratch
|
27 |
+
|
28 |
+
### Model Sources \[optional]
|
29 |
+
|
30 |
+
* **Repository:** [https://github.com/gokulseetharaman/cnn-waste-classification-opencv-pytorch](https://github.com/gokulseetharaman/cnn-waste-classification-opencv-pytorch)
|
31 |
+
* **Dataset:** [https://www.kaggle.com/datasets/mostafaabla/garbage-classification](https://www.kaggle.com/datasets/mostafaabla/garbage-classification)
|
32 |
+
|
33 |
+
## Uses
|
34 |
+
|
35 |
+
### Direct Use
|
36 |
+
|
37 |
+
* Image-based waste detection for smart recycling prototypes
|
38 |
+
* Educational demonstrations of CNNs, OpenCV, and PyTorch
|
39 |
+
* Research baselines for waste/material classification
|
40 |
+
|
41 |
+
|
42 |
+
|
43 |
+
### Recommendations
|
44 |
+
|
45 |
+
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.
|
46 |
+
|
47 |
+
## How to Get Started with the Model
|
48 |
+
|
49 |
+
1. Download `best_model.pth` and `object-detection.py` from this repo or [GitHub](https://github.com/gokulseetharaman/cnn-waste-classification-opencv-pytorch).
|
50 |
+
2. Run `python object-detection.py` for webcam or image predictions.
|
51 |
+
3. Modify `object-detection.py` to use your own image or video source.
|
52 |
+
|
53 |
+
## Training Details
|
54 |
+
|
55 |
+
### Training Data
|
56 |
+
|
57 |
+
* [Kaggle Garbage Classification dataset](https://www.kaggle.com/datasets/mostafaabla/garbage-classification)
|
58 |
+
* 10 classes, \~1200 images (split 80/20 train/val)
|
59 |
+
* Preprocessing: resized to 224x224, normalized, data augmentation (crop, flip, rotation, color jitter, affine)
|
60 |
+
|
61 |
+
### Training Procedure
|
62 |
+
|
63 |
+
* 6 Conv layers, 2 FC layers, dropout, batchnorm
|
64 |
+
* CrossEntropyLoss, AdamW optimizer, 50 epochs, batch size 8
|
65 |
+
|
66 |
+
#### Preprocessing \[optional]
|
67 |
+
|
68 |
+
* Images resized to 224x224
|
69 |
+
* Normalized with ImageNet means/std
|
70 |
+
* Random data augmentation on train set
|
71 |
+
|
72 |
+
#### Training Hyperparameters
|
73 |
+
|
74 |
+
* Training regime: fp32
|
75 |
+
* Epochs: 50, batch size: 8, optimizer: AdamW, LR: 5e-4
|
76 |
+
|
77 |
+
#### Speeds, Sizes, Times \[optional]
|
78 |
+
|
79 |
+
* Training time: \~90 minutes on a modern GPU (varies)
|
80 |
+
* Checkpoint size: \~46MB (`best_model.pth`)
|
81 |
+
|
82 |
+
## Evaluation
|
83 |
+
|
84 |
+
### Testing Data, Factors & Metrics
|
85 |
+
|
86 |
+
#### Testing Data
|
87 |
+
|
88 |
+
* 20% validation split from the Kaggle dataset (stratified)
|
89 |
+
|
90 |
+
#### Factors
|
91 |
+
|
92 |
+
* Performance measured per-class (precision, recall, F1-score, support)
|
93 |
+
|
94 |
+
#### Metrics
|
95 |
+
|
96 |
+
* Overall accuracy, confusion matrix, precision/recall/F1-score per class
|
97 |
+
|
98 |
+
### Results
|
99 |
+
|
100 |
+
* Validation accuracy: **89.56%**
|
101 |
+
* Most class F1-scores >0.85, with "Plastic" lower due to visual ambiguity
|
102 |
+
* Full confusion matrix and metrics in [GitHub README](https://github.com/gokulseetharaman/cnn-waste-classification-opencv-pytorch#results)
|
103 |
+
|
104 |
+
#### Summary
|
105 |
+
|
106 |
+
The model reliably classifies 10 types of waste in standard settings. See GitHub for sample images and live demo outputs.
|
107 |
+
|
108 |
+
## Model Examination \[optional]
|
109 |
+
|
110 |
+
* No explicit interpretability/visualization methods (e.g., GradCAM) included yet.
|
111 |
+
|
112 |
+
## Environmental Impact
|
113 |
+
|
114 |
+
* Estimated training: <1.5 GPU-hour, carbon footprint minimal for local or single-GPU cloud runs
|
115 |
+
* Hardware: NVIDIA GeForce GTX 4060 Laptop GPU
|
116 |
+
* Hours used: \~1.5
|
117 |
+
|
118 |
+
|
119 |
+
## Technical Specifications \[optional]
|
120 |
+
|
121 |
+
### Model Architecture and Objective
|
122 |
+
|
123 |
+
* See "Model Details" and [GitHub repo](https://github.com/gokulseetharaman/cnn-waste-classification-opencv-pytorch#model-architecture) for the full PyTorch code.
|
124 |
+
|
125 |
+
### Compute Infrastructure
|
126 |
+
|
127 |
+
* Local training with NVIDIA GTX 4060 Laptop GPU, 8GB VRAM, 16GB RAM, Windows 11, Python 3.10
|
128 |
+
|
129 |
+
#### Hardware
|
130 |
+
|
131 |
+
* GPU: GTX 4060 (or equivalent, optional CPU)
|
132 |
+
* RAM: 16GB
|
133 |
+
|
134 |
+
#### Software
|
135 |
+
|
136 |
+
* Python 3.10, PyTorch, OpenCV, NumPy
|
137 |
+
|
138 |
+
## Citation
|
139 |
+
|
140 |
+
**BibTeX:**
|
141 |
+
|
142 |
+
```bibtex
|
143 |
+
@misc{gokulseetharaman2025wastecnn,
|
144 |
+
title={CNN Waste Classification with OpenCV and PyTorch},
|
145 |
+
author={Gokul Seetharaman},
|
146 |
+
year={2025},
|
147 |
+
url={https://github.com/gokulseetharaman/cnn-waste-classification-opencv-pytorch}
|
148 |
+
}
|
149 |
+
```
|
150 |
+
|
151 |
+
**APA:**
|
152 |
+
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)
|
153 |
+
|
154 |
+
|
155 |
+
## Model Card Contact
|
156 |
+
|
157 |
+
[GitHub Issues](https://github.com/gokulseetharaman/cnn-waste-classification-opencv-pytorch/issues)
|