Skip to content

NathanCarr10/Machine-Learning-Project

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Garbage Classification with Deep Learning

A multi-class image classification project comparing CNN models trained from scratch with transfer learning using MobileNetV2. This project demonstrates practical deep learning techniques including data augmentation, class weighting for imbalanced datasets, and fine-tuning pre-trained models.

Project Overview

This notebook implements and evaluates multiple approaches to garbage classification:

  • Scratch CNNs: Custom convolutional networks trained from scratch on RGB and grayscale images
  • Transfer Learning: MobileNetV2 pre-trained on ImageNet with optional fine-tuning
  • Architecture Comparison: Tests different input sizes (128×128, 96×96) to balance accuracy and efficiency

Dataset

The project uses a 10-class garbage classification dataset with the following categories:

  • Battery
  • Biological
  • Cardboard
  • Clothes
  • Glass
  • Metal
  • Paper
  • Plastic
  • Shoes
  • Trash

Data is split into 70% training, 10% validation, and 20% testing with class weights applied to address imbalance.

Key Findings

Best Model: Transfer Learning (MobileNetV2 with fine-tuning)

  • Validation Accuracy: 89.06%
  • Test F1-Score (Macro): 0.8789
  • Parameters: ~3.5M
  • Inference Time: Optimized for real-time deployment

Performance comparison shows that transfer learning significantly outperforms scratch models with fewer training epochs, making it ideal for resource-constrained environments.

Technologies & Libraries

  • TensorFlow/Keras: Model building and training
  • Scikit-learn: Model evaluation and confusion matrices
  • Matplotlib/Pandas: Visualization and analysis
  • NumPy: Numerical operations

Notebook Structure

  1. Configuration & Seeds: Sets up reproducible random states
  2. Data Loading: Creates train/validation/test splits with class weighting
  3. Exploratory Data Analysis: Visualizes class distribution and sample images
  4. Model Definitions: Reusable functions for architecture building and training
  5. Scratch Models: Trains CNNs from scratch on RGB and grayscale data
  6. Architecture Comparison: Tests different input sizes and model variants
  7. Transfer Learning: Implements MobileNetV2 with and without fine-tuning
  8. Results & Evaluation: Compares all models and performs final test evaluation
  9. Personal Photo Predictions: Demonstrates real-world inference on custom images

Installation & Usage

Requirements

tensorflow
numpy
pandas
matplotlib
scikit-learn

Running the Notebook

  1. Clone this repository
  2. Install dependencies: pip install -r requirements.txt
  3. Ensure your dataset is structured as: garbage/garbage/[class_folders]/[images]
  4. Open ML_Project.ipynb in Jupyter Notebook or JupyterLab
  5. Run all cells sequentially

Note: Full dataset training may take 30-60 minutes depending on hardware. GPU acceleration is recommended.

Results

Validation Metrics (All Models)

Model Accuracy Precision Recall F1-Score Params
Scratch RGB 128×128 0.8423 0.8389 0.8423 0.8368 379K
Scratch Greyscale 128×128 0.7862 0.7821 0.7862 0.7805 189K
Transfer RGB (Fine-tuned) 0.8906 0.8901 0.8906 0.8789 3.5M

Confusion Matrix Insights

The model shows strong performance across most categories. Common confusion pairs:

  • Metal ↔ Plastic: Similar reflective properties
  • Cardboard ↔ Paper: Similar appearance and color

Portfolio Notes

This project showcases:

  • ✅ End-to-end machine learning pipeline design
  • ✅ Multiple model architectures and training strategies
  • ✅ Rigorous evaluation with appropriate metrics
  • ✅ Handling of class imbalance through weighted training
  • ✅ Transfer learning best practices
  • ✅ Professional code organization and documentation

Author

Nathan Carr (G00410214)
4th Year Machine Learning Module, Atlantic Technological University, Galway, 2026

License

This project is part of academic coursework at ATU Galway. Feel free to use for educational purposes.

About

Multi-class garbage classification using CNNs from scratch and transfer learning with MobileNetV2. 4th Year project for Machine Learning module in ATU Galway 2026

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors