Deep learning model for classifying waste images into recyclable material categories using transfer learning. The model identifies different types of waste from images to support automated waste sorting systems.
This project was developed as part of the Bangkit Academy Machine Learning pathway, a program led by Google, GoTo, and Traveloka.
Waste management is a critical challenge in many regions. Manual sorting is inefficient and prone to error. This project explores how computer vision can assist in automatically classifying waste materials from images.
The model performs multi-class image classification to detect common recyclable materials.
The model classifies images into the following categories:
- cardboard
- glass
- metal
- paper
- plastic_bottle
- plastic_container
- plastic_cup
Total classes: 7
The model uses transfer learning with a pretrained MobileNetV2 backbone.
Pipeline architecture:
MobileNetV2 (pretrained)
↓
GlobalAveragePooling2D
↓
Dense (128)
↓
Dense (7) – Softmax
Model specifications:
- Backbone: MobileNetV2
- Input size: 224 × 224
- Output classes: 7
- Total parameters: ~2.75M
- Trainable parameters: ~165K
The base MobileNetV2 layers are frozen while training the classification head.
The dataset uses a directory-based format for image classification:
dataset/
├── cardboard
├── glass
├── metal
├── paper
├── plastic_bottle
├── plastic_container
└── plastic_cup
Each folder contains images representing its corresponding class label.
- Python
- TensorFlow / Keras
- NumPy
- Google Colab
- Transfer Learning with MobileNetV2
ML_Model/
│
├── dataset/
│ ├── cardboard
│ ├── glass
│ ├── metal
│ ├── paper
│ ├── plastic_bottle
│ ├── plastic_container
│ └── plastic_cup
│
├── model.h5
│
├── inference.py
│
└── README.md
Clone the repository:
git clone https://github.com/C242-PS069/ML_Model.git
cd ML_Model
Install dependencies:
pip install tensorflow numpy
Example code to load the trained model:
from tensorflow.keras.models import load_model
model = load_model("model.h5")
model.summary()Run inference on a sample image:
import numpy as np
from tensorflow.keras.preprocessing import image
from tensorflow.keras.models import load_model
model = load_model("model.h5")
img = image.load_img("sample.jpg", target_size=(224,224))
img_array = image.img_to_array(img)
img_array = np.expand_dims(img_array, axis=0)
img_array = img_array / 255.0
prediction = model.predict(img_array)
print(prediction)The model was trained using transfer learning:
- Load pretrained MobileNetV2
- Freeze base convolution layers
- Add classification head
- Train Dense layers on waste dataset
- Optimize using categorical cross-entropy loss
This model can be extended for:
- smart recycling bins
- automated waste sorting systems
- environmental monitoring tools
- mobile recycling applications
Possible improvements include:
- expanding dataset size
- adding more waste categories
- improving model accuracy through fine-tuning
- deploying the model as a REST API
- integrating with mobile or web applications
This project is intended for educational and research purposes.