This project is a simple image classification project that classifies images of garbage into different classes of household waste.
The dataset used for this project is the Garbage Classification dataset from Kaggle. The dataset contains 12 classes of garbage images. The classes are:
- battery
- biological
- brown-glass
- cardboard
- clothes
- green-glass
- metal
- paper
- plastic
- shoes
- trash
- white-glass
The model used for this project has EfficientNet as the backbone, following by a fully connected layer.
To use this project, you need to have Python 3 installed. A virtual environment is recommended to manage your Python packages.
To install the required packages, run the following command:
pip install -r requirements.txt
If you also want to use the jupyter notebook, you need to install the corresponding requirements with the following command:
pip install -r notebook_requirements.txt
Download the dataset using the script below:
python -m scripts.download_dataset
.
The script will ask you to provide your Kaggle username and Kaggle API key. You can get your Kaggle API key by following the instructions here.
To use the repository, you can either train the model or use a pre-trained model. You can find on this link. (Note: the pretrained should be placed in the 'checkpoints' folder.)
To train the model, run the following command:
python -m scripts.train
To test the model, run the following command:
python -m scripts.eval
To predict the class of an image, run the following command:
python -m scripts.predict --image_path path/to/image
You can observe some results for the following images:
paper | plastic-bottle | wash-clot | white-glass |
---|---|---|---|
![]() |
![]() |
![]() |
![]() |
For that, just run the following command:
python -m scripts.visualize_results
You should see the following output:
Image 1/4
Image: paper
Prediction: paper
Confidence: 0.999967634677887
Class probabilities: [0.00 0.00 0.00 0.00 0.00 0.00 0.00 1.00 0.00 0.00 0.00 0.00]
Image 2/4
Image: wash-cloth
Prediction: clothes
Confidence: 1.0
Class probabilities: [0.00 0.00 0.00 0.00 1.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00]
Image 3/4
Image: white-glass
Prediction: white-glass
Confidence: 1.0
Class probabilities: [0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 1.00]
Image 4/4
Image: plastic-bottle
Prediction: plastic
Confidence: 1.0
Class probabilities: [0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 1.00 0.00 0.00 0.00]
This project is licensed under the MIT License - see the LICENSE file for details.