Files
julian 4ff31557a8 feat(trainer): training from the collector UI — the trainer becomes a job service, the review page gains a Training section
Trainer: `parking-trainer serve` — a stdlib HTTP job API on the compose network (never
published): /health, /readiness, /versions, /versions/<v>/report, /jobs. One job at a
time; each job runs the CLI as a subprocess with its output captured, state + log
persisted under /out/jobs/ so a restart keeps history. `publish` takes its URL from
TRAINER_PUBLISH_URL. Dockerfile: CMD serve, EXPOSE 8091, healthcheck.

Collector: COLLECTOR_TRAINER_URL + /api/training/{status,jobs,jobs/:id,versions/:v/report}
— a reviewer-gated proxy that forwards a fixed set of paths and whitelisted knobs and
passes the trainer's status codes through (409 while a job runs; 503 unconfigured, 502
unreachable). /review gains the Training section: labels per class vs the minimum with
Train disabled until two classes clear it, mode / backbone / floor, the running job's
live log, the versions with Report / Evaluate / Publish (publish confirms), and the
reminder that pinning stays a git commit. Fixed on the way: an apostrophe in the page's
inline script broke the whole page — a test now parses the script.

Compose: `trainer` is a service (restart: unless-stopped, read-only data volume, its own
trainer-out volume), the `train` profile and TRAINER_OUT are gone; the Docker-socket
route was rejected (root on the host for a service booths upload to). Verified with both
images running together: a Train started through the proxy finished, version and report
came back, the page rendered.

Wiki: bodytype-classifier-training (loop, running it, operating notes superseded),
vision-review-outbox, fleet-deployment-komodo, log.

Claude-Session: https://claude.ai/code/session_01FWncR69HgGPuei1dLrW3cU
2026-09-07 14:34:13 +02:00

2.1 KiB
Raw Permalink Blame History

parking-trainer

The phase-B body-type classifier job. Reads the wash collector's volume (collector.sqlite + crops/), trains a classifier on the reviewer's labels, and writes a versioned model folder the vision image bakes in — or refuses when validation is below the floor. Design and decisions: wiki/decisions/bodytype-classifier-training.md.

parking-trainer inspect  --data /data                       # what a run would train on
parking-trainer train    --data /data --out /out            # features mode (minutes)
parking-trainer train    --mode finetune --epochs 12 ...    # full fine-tune (about an hour on 4 cores)
parking-trainer evaluate --model /out/<version>/bodytype.onnx --data /data
parking-trainer publish  /out/<version> --url https://git.infra.msai.al/api/packages/mca/generic/parking-bodytype

Exit codes: 0 model written · 2 not enough labels · 3 below the floor (report written, no model) · 1 other.

A passing run writes <out>/<version>/:

file what
bodytype.onnx the classifier; input image = RGB float32 0–255 [N,3,S,S], output logits [N,K]; normalisation is inside the graph
bodytype.json sidecar: version, class list (in vocabulary order), input size, crop margin, backbone, mode, label counts, validation metrics
report.md the human report: accuracy, per-class recall/precision, confusion matrix, dropped classes, loss weights
metrics.json the same numbers, machine-readable

On the reviewer's host the image runs serve as the trainer service of the wash-collector stack: a job API (/health, /readiness, /versions, /jobs) on the compose network that the collector's Training section (/review) drives — readiness, Train / Evaluate / Publish, reports and logs. Jobs run as subprocesses of the CLI, one at a time; state and logs persist under /out/jobs/. The CLI stays for debugging: docker compose -f docker-compose.collector.yml exec trainer parking-trainer inspect.

Local dev: uv sync --extra train (CPU torch, ~200 MB), uv run pytest -q. The test suite runs without the extra (torch tests skip), matching CI.