|
--- |
|
language: en |
|
tags: |
|
- image-classification |
|
- resnet50 |
|
datasets: |
|
- mostafaabla/garbage-classification |
|
license: mit |
|
--- |
|
|
|
|
|
# Model Card for Garbage Classification using ResNet50 v1.2 (Update: increased dataset and model training) |
|
|
|
## Model Overview |
|
This model is a garbage classification system built on the ResNet50 architecture, fine-tuned for classifying household garbage into 12 distinct categories: paper, cardboard, biological, metal, plastic, green-glass, brown-glass, white-glass, clothes, shoes, batteries, and trash. The model was trained on a dataset sourced from the Kaggle Garbage Classification Dataset by Mostafa Abla. The purpose of this model is to assist in sorting household waste for better recycling efficiency. |
|
|
|
## Model Architecture |
|
Base Model: ResNet50 (pre-trained on ImageNet). |
|
|
|
Modifications: The final fully connected layer was modified to output 12 classes instead of the default 1000 classes used in ImageNet. |
|
|
|
## Intended Use |
|
This model is intended for environmental conservation efforts through waste sorting and recycling. It can be implemented in waste management systems, where a camera captures images of garbage and sorts them into appropriate categories for recycling. |
|
|
|
## Potential Use Cases: |
|
|
|
- Automated waste sorting systems. |
|
- Integration in smart recycling bins. |
|
- Environmental and educational tools to promote recycling. |
|
|
|
## Limitations and Ethical Considerations |
|
While this model can help with waste sorting, there are some important considerations to keep in mind: |
|
|
|
- Bias in Dataset: The dataset was collected through web scraping, and some categories, such as clothes and shoes, may not reflect real-world garbage. This could cause inaccuracies in certain classes. |
|
- Ethical Use: The model should not be used in isolation without human oversight, especially in critical recycling operations, as there is potential for error in misclassification that could lead to incorrect waste handling. |
|
- Dataset Limitations: The dataset used was created in a controlled environment, not in real-world garbage scenarios. This may limit the generalizability of the model to environments where garbage is not presented in a clean, well-lit setting. |
|
|
|
## Mitchell's Ethical AI Considerations (2018) |
|
- Bias: The dataset contains inherent bias, as it was primarily collected through web scraping rather than real-world garbage images. For instance, images of clothes are typically of clean clothes, not actual discarded garments, which can lead to incorrect classification. |
|
- Fairness: The model may perform differently depending on the type of garbage presented. Since it was not trained on real-world garbage images, it might favor certain categories. |
|
- Transparency: The model was built using a pre-trained ResNet50 with added modifications, and the details of training and performance metrics are shared openly. |
|
- Mitigation: Further data collection from real-world garbage environments can improve model accuracy and fairness. |
|
|
|
# Training and Experimental Details |
|
## Training Parameters |
|
Optimizer: Adam optimizer with learning rate of 0.001 |
|
Loss Function: CrossEntropyLoss |
|
Scheduler: StepLR, decreasing the learning rate every 7 epochs by a factor of 0.1 |
|
Batch Size: 32 |
|
Number of Epochs: 20 |
|
Transformations: |
|
Training: RandomResizedCrop, RandomRotation, HorizontalFlip, ColorJitter, Normalization. |
|
Validation: Resize, CenterCrop, Normalization. |
|
The training was conducted on a single GPU to speed up computation. |
|
|
|
## Dataset Used |
|
The model was trained using the Kaggle Garbage Classification Dataset https://www.kaggle.com/datasets/mostafaabla/garbage-classification/data. The dataset contains 15,150 images of household garbage spread across 12 classes. The images were split into training and validation sets to evaluate the model performance. |
|
|
|
## Model Evaluation Results |
|
The model's performance was evaluated on the validation set. Below are the key metrics: |
|
|
|
Epoch 1/20 |
|
train Loss: 0.9568 Acc: 0.7011 |
|
valid Loss: 0.4934 Acc: 0.8481 |
|
Epoch 1 completed in 3542.73 seconds. |
|
|
|
Epoch 2/20 |
|
train Loss: 0.6937 Acc: 0.7774 |
|
valid Loss: 0.3939 Acc: 0.8734 |
|
Epoch 2 completed in 3822.20 seconds. |
|
|
|
Epoch 3/20 |
|
train Loss: 0.5917 Acc: 0.8094 |
|
valid Loss: 0.4377 Acc: 0.8663 |
|
Epoch 3 completed in 3805.78 seconds. |
|
|
|
Epoch 4/20 |
|
train Loss: 0.5718 Acc: 0.8146 |
|
valid Loss: 0.3412 Acc: 0.8915 |
|
Epoch 4 completed in 3815.20 seconds. |
|
|
|
Epoch 5/20 |
|
train Loss: 0.5109 Acc: 0.8331 |
|
valid Loss: 0.2614 Acc: 0.9172 |
|
Epoch 5 completed in 3812.79 seconds. |
|
|
|
Epoch 6/20 |
|
train Loss: 0.4824 Acc: 0.8452 |
|
valid Loss: 0.2966 Acc: 0.9011 |
|
Epoch 6 completed in 3809.74 seconds. |
|
|
|
Epoch 7/20 |
|
train Loss: 0.4697 Acc: 0.8447 |
|
valid Loss: 0.2439 Acc: 0.9221 |
|
Epoch 7 completed in 3819.44 seconds. |
|
|
|
Epoch 8/20 |
|
train Loss: 0.3318 Acc: 0.8899 |
|
valid Loss: 0.1065 Acc: 0.9649 |
|
Epoch 8 completed in 3809.94 seconds. |
|
|
|
Epoch 9/20 |
|
train Loss: 0.2785 Acc: 0.9068 |
|
valid Loss: 0.0926 Acc: 0.9714 |
|
Epoch 9 completed in 3821.37 seconds. |
|
|
|
Epoch 10/20 |
|
train Loss: 0.2680 Acc: 0.9114 |
|
valid Loss: 0.0797 Acc: 0.9759 |
|
Epoch 10 completed in 3599.23 seconds. |
|
|
|
Epoch 11/20 |
|
train Loss: 0.2371 Acc: 0.9216 |
|
valid Loss: 0.0738 Acc: 0.9762 |
|
Epoch 11 completed in 3578.04 seconds. |
|
|
|
Epoch 12/20 |
|
train Loss: 0.2333 Acc: 0.9203 |
|
valid Loss: 0.0639 Acc: 0.9791 |
|
Epoch 12 completed in 3690.18 seconds. |
|
|
|
Epoch 13/20 |
|
train Loss: 0.2198 Acc: 0.9254 |
|
valid Loss: 0.0555 Acc: 0.9827 |
|
Epoch 13 completed in 3107.97 seconds. |
|
|
|
Epoch 14/20 |
|
train Loss: 0.2060 Acc: 0.9306 |
|
valid Loss: 0.0560 Acc: 0.9812 |
|
Epoch 14 completed in 3689.20 seconds. |
|
|
|
Epoch 15/20 |
|
train Loss: 0.1962 Acc: 0.9352 |
|
valid Loss: 0.0490 Acc: 0.9843 |
|
Epoch 15 completed in 3664.71 seconds. |
|
|
|
Epoch 16/20 |
|
train Loss: 0.1951 Acc: 0.9346 |
|
valid Loss: 0.0479 Acc: 0.9850 |
|
Epoch 16 completed in 3761.18 seconds. |
|
|
|
Epoch 17/20 |
|
train Loss: 0.1880 Acc: 0.9368 |
|
valid Loss: 0.0455 Acc: 0.9852 |
|
Epoch 17 completed in 3822.19 seconds. |
|
|
|
Epoch 18/20 |
|
train Loss: 0.1912 Acc: 0.9353 |
|
valid Loss: 0.0454 Acc: 0.9854 |
|
Epoch 18 completed in 3830.77 seconds. |
|
|
|
Epoch 19/20 |
|
train Loss: 0.1811 Acc: 0.9396 |
|
valid Loss: 0.0438 Acc: 0.9854 |
|
Epoch 19 completed in 3745.39 seconds. |
|
|
|
Epoch 20/20 |
|
train Loss: 0.1810 Acc: 0.9409 |
|
valid Loss: 0.0427 Acc: 0.9866 |
|
Epoch 20 completed in 3818.20 seconds. |
|
Training complete in 1239m 26s |
|
Best val Acc: 0.9866 |
|
|
|
Test Loss: 0.0427, Test Acc: 0.9866 |
|
Precision: 0.9866, Recall: 0.9866, F1 Score: 0.9866 |
|
|
|
The model showed high accuracy in predicting common categories such as plastic, paper, and metal, but bit struggled with classes like shoes and clothes, reflecting the challenges of web-scraped images for such categories. |
|
|
|
## Conclusion |
|
This ResNet50-based garbage classification model shows promising performance for sorting household waste into multiple categories. It can be used in waste management systems to automate and optimize the recycling process. Future work includes improving data quality by collecting real-world garbage images, fine-tuning the model, and addressing potential biases. |
|
|
|
Further details and the code for this model can be found in the experiment tracking system. |
|
|
|
## Potential Improvements |
|
- Real-world data collection (also preferably from items in poor or trash-like conditions) is necessary to reduce bias, as trash banks and recycling centers encourage people to separate used items into those that are reusable and those that are not suitable for use. |
|
- More data augmentation to handle edge cases like occluded or partially damaged garbage items. |
|
- Deploying the model in edge devices for real-time classification at waste management facilities. |