Skip to content

ana-morais57/Waste-Image-Classifier

 
 

Repository files navigation

logo_ironhack_blue 7

Waste Image Classifier with TensorFlow

This repository contains a Computer Vision project to classify waste images into "Recyclable" or "Household Waste." It employs transfer learning with MobileNetV2 and a custom-built pipeline for preprocessing, training, evaluation, and deployment.


Table of Contents

  1. Overview
  2. Dataset
  3. Exploratory Data Analysis (EDA)
  4. Model Development
  5. Training and Evaluation
  6. Deployment
  7. Usage
  8. Files in Repository
  9. Future Work

Overview

This project aims to automate waste sorting by classifying images into two categories:

  • Recyclable
  • Household Waste

Key highlights:

  • Comprehensive EDA for dataset understanding.
  • Transfer learning with MobileNetV2.
  • Deployment using Streamlit for user-friendly interaction.

Dataset

The Recycling dataset consists of images for machine learning classification, that were divided into two categories:

  • Recyclable: Aluminum cans, glass bottles, etc.
  • Household Waste: Food waste, plastic straws, etc.

Dataset Organization

The dataset was split into:

  • Training: 70%
  • Validation: 15%
  • Test: 15%

Images were preprocessed with unique names to avoid duplication and ensure consistency.


Exploratory Data Analysis (EDA)

  • Conducted using custom scripts in eda_utils.py.
  • Key analyses include:
    • Image size and format.
    • Dataset distribution by categories.

Model Development

Baseline Model

A custom Convolutional Neural Network (CNN) was built to establish a baseline for classification performance.

Transfer Learning with MobileNetV2

  • Architecture: MobileNetV2 pre-trained on ImageNet.

Training and Evaluation

The models were trained and evaluated with:

  • Metrics: Accuracy, loss, precision, recall, and F1-score.
  • Regularization: learning rate scheduling.
  • Callbacks: Early stopping and model checkpoints.

Deployment

The model is deployed using Streamlit:

  • Interface: Upload an image and classify it as "Recyclable" or "Household Waste."
  • Backend: Uses a saved Keras model (best_mobilenet_model.keras) for inference.

How to Run

# Install dependencies
pip install -r requirements.txt

# Run the app
streamlit run app.py

Usage

Training

Run the notebook MyTemplate.ipynb to train and evaluate models:

  • Edit paths to match your dataset structure.
  • Experiment with different augmentation and transfer learning techniques.

Prediction

Upload an image to the Streamlit app and receive a prediction with confidence.


Files in Repository

File Description
requirements.txt List of Python dependencies required for the project..
RecyclingClassifier.ipynb Notebook for experimenting with the extended dataset.
eda_utils.py Utility functions for EDA and dataset analysis.
utils.py Helper functions for organizing images and assigning unique names.
app.py Streamlit application for deploying the classification model.
best_mobilenet_model.keras Pre-trained MobileNetV2 model saved after fine-tuning.
RecyclingClassification.pdf Presentation detailing the project details and conclusions.

Future Work

  • Model Optimization: Test alternative architectures like ResNet or EfficientNet.
  • Augmentation: Applied transformations like rotation, zoom, and flipping to improve generalization.
  • Fine-tuning: Enabled training on specific layers to adapt MobileNetV2 to the dataset.
  • Data Expansion: Incorporate more waste categories and diverse images.
  • Deployment: Extend deployment to cloud platforms (e.g., AWS, Google Cloud).

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Jupyter Notebook 99.7%
  • Python 0.3%