Project Analysis
image

YOLOv8-Based Object Detection & Segmentation for Trash

About Project

Waste classification and plant disease identification are critical for sustainability and agriculture. Manual sorting is time-consuming, error-prone, and inconsistent. Automating these tasks requires accurate object detection and segmentation, even in noisy, real-world environments with class imbalance and complex backgrounds.

Problem Statement

Waste classification and plant disease identification are critical for sustainability and agriculture. Manual sorting is time-consuming, error-prone, and inconsistent. Automating these tasks requires accurate object detection and segmentation, even in noisy, real-world environments with class imbalance and complex backgrounds.

Objective

To develop and deploy a robust deep learning system using YOLOv8 for:

  • Trash Object Detection: Detect and classify cardboard, glass, metal, and plastic waste
  • Plant Disease Instance Segmentation: Identify diseased regions in plant leaves with pixel-level precision
  • Live Prediction: Real-time object detection using webcam input
  • Deployment: Integrated with Django and FastAPI for full-stack deployment

Proposed Solution

Part A: Trash Object Detection
  • Trained YOLOv8n on a trash dataset with 1,783 training images
  • Classes: cardboard (0), glass (1), metal (2)
  • Used pretrained weights and AdamW optimizer
  • Evaluation Metrics:
    • mAP@0.5: 98.9%
    • mAP@0.5–0.95: 88.4%
    • Precision: 97.3%
    • Recall: 96.3%

Technologies Used

Core Frameworks & Libraries
  • Ultralytics YOLOv8
  • PyTorch
  • OpenCV
Deployment
  • ONNX Export for model deployment
  • FastAPI + Django for live inference with webcam input
Development Environment
  • Google Colab (Tesla T4 GPU)
Languages & Config Formats
  • Python
  • YAML
  • JSON

Challenges Faced

  • CPU-based training on local system led to slow and interrupted runs
  • Initial plant disease segmentation model showed low generalization on unseen data
  • Webcam-based live deployment faced performance drops (<40% accuracy)
  • Heavy model load time; skipped deeper tuning due to time constraints

Methodology

Data Preparation
  • Verified image-label pairs for consistency
  • Converted annotations to YOLO format
  • Ensured uniform image size:
    • 640×640 for trash detection
    • 256×256 for plant segmentation
Model Training
  • Used modular Python functions for dataset loading and training configuration
  • Monitored key training metrics:
    • Precision
    • Recall
    • mAP
    • Box/Classification Loss
  • Trained both detection and segmentation variants of YOLOv8
Evaluation & Analysis
  • Plotted confidence score histograms
  • Analyzed confusion matrices and false positive rates
  • Tracked mAP evolution across epochs and different augmentation strategies
Deployment
  • Integrated YOLOv8 model with FastAPI for backend inference
  • Connected to a Django frontend that captures webcam images and displays results
  • Exported the final trained model in ONNX format for cross-platform deployment

Result / Outcome

Results Summary
Task mAP@50 mAP@50–95 Precision Recall
Trash Detection 0.989 0.884 0.973 0.963
Plant Disease Segmentation 0.504 0.176 0.593 0.368
  • Mosaic augmentation significantly improved detection accuracy
  • Trash detection model achieved real-time performance (2.2 ms/image)
  • Segmentation model underperformed due to limited training scope

EDA
ML MODEL