Skip to main content

Introduction

The Trash Classification AI System uses YOLOv11 (specifically the YOLOv11n-seg variant) for instance segmentation of recyclable materials. This training pipeline enables you to train a custom model to detect and segment three classes of trash: cardboard/paper, metal, and plastic.
YOLOv11 is the latest version of Ultralytics’ YOLO family, offering improved accuracy and faster inference speeds compared to previous versions.

Why YOLOv11?

YOLOv11 was selected for this project due to:
  • Real-time Performance: Optimized for fast inference on edge devices
  • Instance Segmentation: Provides pixel-level masks for precise object boundaries
  • Efficient Architecture: The nano variant (yolo11n-seg) balances accuracy with model size
  • Transfer Learning: Pre-trained weights accelerate training convergence
  • Multi-platform Support: Compatible with CUDA, MPS (Apple Silicon), and CPU

Hardware Requirements

  • GPU: NVIDIA GPU with 8GB+ VRAM (RTX 3060 or higher)
  • RAM: 16GB minimum, 32GB recommended
  • Storage: 10GB+ for dataset and training artifacts
  • CPU: Multi-core processor (for data loading)

Supported Devices

The training script automatically detects and uses the best available device:
1

Apple Silicon (M1/M2/M3)

Uses MPS (Metal Performance Shaders) for GPU acceleration
2

NVIDIA CUDA

Automatically leverages CUDA for optimal training speed
3

CPU Fallback

Falls back to CPU if no GPU is available (slower training)

Training Resources

Expected Training Time

Device TypeEpochsEstimated Time
NVIDIA RTX 30803002-4 hours
Apple M1/M23004-8 hours
CPU Only30024-48 hours
Training times vary significantly based on dataset size, image resolution, and hardware specifications. The estimates above are for a typical dataset of 1000-2000 images.

Training Configuration

The default training configuration uses:
  • Model: YOLOv11n-seg (nano segmentation variant)
  • Epochs: 300
  • Image Size: 640x640
  • Batch Size: Automatic (optimized for available memory)
  • Early Stopping: 10 epochs patience
  • Task: Instance segmentation

Training Pipeline Components

  1. Dataset Preparation: Organize images and annotations in YOLO format
  2. Model Initialization: Load pre-trained YOLOv11n-seg weights
  3. Training: Train with automatic device selection and monitoring
  4. Evaluation: Validate performance on validation set
  5. Export: Save best model weights for deployment

Next Steps

Dataset Preparation

Learn how to structure your dataset and prepare annotations

Model Training

Configure and run the training script

Build docs developers (and LLMs) love