Skip to main content

Overview

Reciclaje AI uses a custom-trained YOLOv8 model for detecting and classifying waste materials. The model is hosted on HuggingFace and must be downloaded before you can run the application.

Model Information

Model Details

  • Model Type: YOLOv8 (You Only Look Once v8)
  • Framework: Ultralytics
  • Task: Object Detection and Classification
  • Classes: 5 waste categories
    • Metal
    • Glass
    • Plastic
    • Carton (Cardboard)
    • Medical Waste
  • Format: PyTorch (.pt)
  • File Size: ~6 MB
  • Hosting: HuggingFace Model Hub
This model has been specifically trained on waste and recyclable materials, providing accurate classification for common household and industrial waste items.

Download Methods

1

Visit HuggingFace Repository

Navigate to the model repository:https://huggingface.co/AprendeIngenia/recyclingAI
2

Download the Model File

Click on the “Files and versions” tab, then download best.pt.Or use direct link:
https://huggingface.co/AprendeIngenia/recyclingAI/resolve/main/best.pt
3

Create Models Directory

In your Reciclaje AI project root, create the Modelos directory:
mkdir -p Modelos
4

Move Model File

Place the downloaded best.pt file into the Modelos/ directory:
reciclaje_ai/
├── Modelos/
│   └── best.pt          ← Place file here
├── main.py
├── TrashDetect.py
└── setUp/

Method 2: Using wget (Linux/macOS)

Download directly from the command line:
# Create directory
mkdir -p Modelos

# Download model
wget -O Modelos/best.pt https://huggingface.co/AprendeIngenia/recyclingAI/resolve/main/best.pt
This method is fastest for automated deployments or scripted installations.

Method 3: Using curl

Alternative command-line download:
# Create directory
mkdir -p Modelos

# Download model
curl -L -o Modelos/best.pt https://huggingface.co/AprendeIngenia/recyclingAI/resolve/main/best.pt

Method 4: Using Python

Download programmatically with Python:
import urllib.request
import os

# Create directory
os.makedirs('Modelos', exist_ok=True)

# Download model
url = 'https://huggingface.co/AprendeIngenia/recyclingAI/resolve/main/best.pt'
filename = 'Modelos/best.pt'

print('Downloading model...')
urllib.request.urlretrieve(url, filename)
print(f'Model downloaded to {filename}')
Save this as download_model.py and run:
python download_model.py

Method 5: Using HuggingFace Hub (Advanced)

Use the HuggingFace Hub library for advanced features:
# Install huggingface-hub
pip install huggingface-hub
from huggingface_hub import hf_hub_download
import os

# Create directory
os.makedirs('Modelos', exist_ok=True)

# Download model
model_path = hf_hub_download(
    repo_id="AprendeIngenia/recyclingAI",
    filename="best.pt",
    local_dir="Modelos",
    local_dir_use_symlinks=False
)

print(f'Model downloaded to {model_path}')

Verification

Verify Download

Check that the model file exists and has the correct size:
ls -lh Modelos/best.pt
Expected output: File size should be approximately 6 MB.

Test Model Loading

Verify the model can be loaded by Ultralytics:
from ultralytics import YOLO

try:
    model = YOLO('Modelos/best.pt')
    print('✓ Model loaded successfully')
    print(f'Model classes: {model.names}')
except Exception as e:
    print(f'✗ Error loading model: {e}')
Expected output:
✓ Model loaded successfully
Model classes: {0: 'Metal', 1: 'Glass', 2: 'Plastic', 3: 'Carton', 4: 'Medical'}
If the model loads correctly and shows the 5 waste categories, your setup is complete!

Model Performance

Training Dataset

The model was trained on a diverse dataset including:
  • Various lighting conditions
  • Different angles and perspectives
  • Multiple object sizes
  • Real-world waste scenarios

Expected Accuracy

  • Overall mAP: ~85-90%
  • Metal detection: High accuracy on cans, foil, and metal containers
  • Glass detection: Good performance on bottles and jars
  • Plastic detection: Excellent on bottles, bags, and containers
  • Carton detection: Strong on cardboard boxes and paper products
  • Medical waste: Reliable on syringes, masks, and medical packaging
The model may have reduced accuracy in:
  • Low-light conditions
  • Heavily occluded objects
  • Rare or unusual waste items not in training set
  • Extreme angles or distances

Using Custom Models

Training Your Own Model

If you want to train a custom model:
1

Prepare Dataset

Collect and annotate images of waste items in YOLO format.
2

Train with Ultralytics

from ultralytics import YOLO

# Load a base model
model = YOLO('yolov8n.pt')

# Train on your dataset
model.train(
    data='waste_dataset.yaml',
    epochs=100,
    imgsz=640
)
3

Export Trained Model

Your trained model will be saved as best.pt in the runs/detect/train/weights/ directory.
4

Replace Model File

Copy your custom best.pt to the Modelos/ directory.

Using Different Model Sizes

YOLOv8 comes in different sizes. You can use alternatives:
  • YOLOv8n (Nano): Fastest, lowest accuracy
  • YOLOv8s (Small): Balanced speed and accuracy
  • YOLOv8m (Medium): Good accuracy, moderate speed
  • YOLOv8l (Large): High accuracy, slower
  • YOLOv8x (Extra Large): Highest accuracy, slowest
The provided model is based on YOLOv8n for optimal real-time performance on consumer hardware.

Troubleshooting

Try these solutions:
  1. Use a different download method (wget, curl, or manual)
  2. Check your internet connection
  3. Verify HuggingFace is accessible in your region
  4. Try downloading at a different time
  5. Use a VPN if HuggingFace is blocked
Symptoms: File size is incorrect or model won’t loadSolution:
# Delete incomplete download
rm Modelos/best.pt

# Re-download
wget -O Modelos/best.pt https://huggingface.co/AprendeIngenia/recyclingAI/resolve/main/best.pt

# Verify file size (should be ~6 MB)
ls -lh Modelos/best.pt
Error message: RuntimeError: Error(s) in loading state_dictThis usually indicates:
  • Incompatible Ultralytics version
  • Corrupted model file
Solution:
# Update Ultralytics
pip install --upgrade ultralytics

# Re-download model
wget -O Modelos/best.pt https://huggingface.co/AprendeIngenia/recyclingAI/resolve/main/best.pt
On Linux/macOS:
sudo mkdir -p Modelos
sudo chown $USER:$USER Modelos
Or navigate to a directory where you have write permissions.
Potential causes:
  • Poor lighting conditions
  • Camera quality issues
  • Objects too small or too far
  • Wrong model file
Verify you’re using the correct model:
from ultralytics import YOLO
model = YOLO('Modelos/best.pt')
print(model.names)  # Should show: {0: 'Metal', 1: 'Glass', ...}

Model Updates

Checking for Updates

Periodically check the HuggingFace repository for model improvements: https://huggingface.co/AprendeIngenia/recyclingAI

Updating the Model

To update to a newer version:
# Backup current model
mv Modelos/best.pt Modelos/best.pt.backup

# Download new version
wget -O Modelos/best.pt https://huggingface.co/AprendeIngenia/recyclingAI/resolve/main/best.pt
Keep a backup of the working model in case the new version has issues with your specific use case.

Next Steps

With the model downloaded and verified:

Quick Start

Run your first waste detection

Model Overview

Learn about model specifications

CLI Detection

Use the command-line interface

GUI Application

Use the graphical interface

Build docs developers (and LLMs) love