Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Repository files navigation

Screenshot 2024-04-13 at 7 49 54 PM

Project layout

  • common/ — shared code between training and serving: model architecture (model.py), class labels (labels.py), and image transforms (transforms.py). Keeps the two from silently drifting apart.
  • model/ — training pipeline. Downloads the TrashNet dataset and fine-tunes an EfficientNet-b0 to classify 6 categories: cardboard, glass, metal, paper, plastic, trash.
  • ml_backend/ — FastAPI server that receives a photo from the ESP32 over WiFi and returns the predicted category as plain text.
  • firmware/ — PlatformIO project for a Freenove ESP32-WROVER CAM board: captures a photo on an ultrasonic trigger, sends it to ml_backend, and drives servos to sort the item into a bin.

All Python commands below are run from the repo root, so common resolves as a sibling package.

Training the model

python -m venv .venv && source .venv/bin/activate
pip install -r model/requirements.txt
python -m model.download_dataset   # downloads TrashNet into model/data/
python -m model.train              # trains, writes model/checkpoints/best_model.pth + model_config.json

Running the backend

pip install -r ml_backend/requirements.txt
uvicorn ml_backend.main:app --host 0.0.0.0 --port 8000

POST /predict with a raw JPEG body returns the predicted label as plain text (e.g. plastic).

Flashing the firmware

cd firmware
pio run --target upload
pio device monitor

Before flashing:

  • Fill in the real servo angles in firmware/src/sorter.cpp's CALIBRATION_TABLE (currently placeholders) to match your physical sorter.
  • Set SERVER_HOST in firmware/include/config.h to the IP the machine running ml_backend gets once it joins the ESP32's trashcan WiFi network.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages