# sups_yolo

Intelligent information-measuring system for real-time control of geometric and physico-mechanical parameters of polyurethane shoe soles.

## Goal

Detect and classify defects on polyurethane soles in several categories, despite moderate disturbances such as dust, glare, and varying lighting conditions.

## Tech stack

| Layer | Choice | Notes |
|-------|--------|-------|
| Language | Python 3.10+ | Main inference and backend language. |
| Object detection | Ultralytics YOLOv8 | One detector instance per camera channel. |
| Web backend | FastAPI | Serves REST/WebSocket APIs for the UI and camera channels. |
| Web UI | HTML + htmx / vanilla JS | Lightweight, channel tabs, history, validation, retraining. |
| Database | SQLite (production ready via `aiosqlite`) | Stores events, images paths, labels, config snapshots. |
| Camera capture | OpenCV + `picamera2` / RTSP URLs | IP cameras or Raspberry Pi cameras. |
| Image augmentation | Albumentations | Synthetic dust, lighting, rotation for training/testing. |
| Training loop | Ultralytics Python API | Fine-tune YOLO on collected verified data. |
| Configuration | JSON files in `config/` | Per-channel preprocessing and model settings. |
| Testing | pytest | Unit and integration tests. |
| Environment | Linux-like OS, RTX 2060 workstation | 2–3 Raspberry Pi / IP cameras, Full HD. |

## System overview

- **Vision hardware**: 2–3 Raspberry Pi or IP cameras with web access + a workstation with an RTX 2060; Full HD cameras.
- **Software**: Linux-like OS, logging of processed data, YOLO-based detection instances per camera.
- **User web interface**: history view, validation status, expert feedback (correct/incorrect), multi-channel tabs (camera 1/2/3 with independent YOLO instances), live camera preview for setup, settings section, retraining with date-restricted data.
- **Event record per sole**: sole ID, defect photo, defect probability, annotated photo with defect zone.
- **Performance target**: 15 seconds per image analysis and result description.

## Documentation

Project documentation lives in [`docs/`](docs/).

## Setup

1. Install [uv](https://docs.astral.sh/uv/) (recommended) or `pip`.
2. Create a virtual environment inside the project:
   ```bash
   uv venv .venv
   source .venv/bin/activate
   ```
3. Install dependencies:
   ```bash
   uv pip install -e ".[dev]"
   ```
4. Copy `config/example.json` to `config/local.json` and adjust camera / model settings.
5. Run tests:
   ```bash
   pytest
   ```
