f7a262ac9a
Build & push images / images (push) Successful in 6m31s
apps/trainer (parking-trainer): inspect / train / evaluate / publish. Reads the wash collector's SQLite + crops read-only off its volume; time split (validation = newest slice); thin classes dropped; damped class weights; `features` mode (frozen ImageNet backbone, on-disk feature cache, seconds to retrain) and `finetune` mode (light augmentation). CPU-only torch from PyTorch's wheel index. ONNX export checked against the torch model; NO model file below the validation floor (exit 3, report still written); exit 2 = not enough labels. `evaluate` scores a shipped model on labels reviewed after training + the unlabelled pile; `publish` PUTs a version folder to a Gitea generic package. Light core deps; the `train` extra is heavy — CI syncs without it, torch tests skip. apps/vision: BodyTypeClassifier (bodytype.onnx + sidecar = the preprocessing contract: crop margin, input size, RGB 0-255, normalisation inside the graph) and RefinedVehicleDetector over YOLOX — refines only `car` or a class the classifier trained on, min-confidence, `detector_class` on the result; path set but no file = phase B off without an error; a broken file is a health detail. models/bodytype.version (tracked, empty) pins the published version the Dockerfile fetches at build (BuildKit secret; a pin that cannot be fetched fails the build). Verified: a trainer model gives identical probabilities inside the vision service; both images built and smoke-tested. Delivery: parking-trainer image in build-images.yml, the `trainer` compose profile on the collector stack (CPU, read-only data, TRAINER_OUT), commented TRAINER_OUT/PUBLISH_TOKEN in the wash-collector stack, .dockerignore for both Python contexts, trainer deps synced in CI. Wiki: bodytype-classifier-training rewritten as built (+ one fleet model not per site, secrets/access, where the crops live), opencv-anpr-service §Phase B, vision-review-outbox, vision-service-packaging, fleet-deployment-komodo, index, log. Claude-Session: https://claude.ai/code/session_01FWncR69HgGPuei1dLrW3cU
44 lines
1.9 KiB
Docker
44 lines
1.9 KiB
Docker
# syntax=docker/dockerfile:1.7
|
|
# Parking TRAINER image: the phase-B body-type classifier job. Build CONTEXT is apps/trainer
|
|
# (self-contained Python package). A ONE-OFF JOB on the reviewer's host (art-docker-station),
|
|
# never a booth service: it reads the wash collector's volume (collector.sqlite + crops/)
|
|
# and writes a versioned model folder. CPU-only PyTorch — the host has no usable GPU and a
|
|
# few thousand crops train in minutes/an hour on four Xeon cores.
|
|
# See wiki/decisions/bodytype-classifier-training.md.
|
|
|
|
FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim AS base
|
|
WORKDIR /app
|
|
ENV UV_LINK_MODE=copy \
|
|
UV_COMPILE_BYTECODE=1 \
|
|
PYTHONUNBUFFERED=1
|
|
|
|
RUN apt-get update \
|
|
&& apt-get install -y --no-install-recommends libgl1 libglib2.0-0 \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
COPY pyproject.toml uv.lock .python-version ./
|
|
RUN --mount=type=cache,target=/root/.cache/uv \
|
|
uv sync --frozen --no-install-project --no-dev --extra train
|
|
|
|
COPY trainer/ ./trainer/
|
|
COPY README.md ./
|
|
RUN --mount=type=cache,target=/root/.cache/uv \
|
|
uv sync --frozen --no-dev --extra train
|
|
|
|
# Pre-warm the ImageNet backbone weights INTO the image so a run needs no network (the
|
|
# host has one, but a job that fetches at run time is a job that fails at 2 am). Best-effort:
|
|
# without network at build time torchvision fetches lazily on the first run.
|
|
ENV TORCH_HOME=/app/torch-home
|
|
RUN uv run python -c "import torchvision.models as m; m.resnet18(weights=m.ResNet18_Weights.IMAGENET1K_V1); m.mobilenet_v3_small(weights=m.MobileNet_V3_Small_Weights.IMAGENET1K_V1)" \
|
|
|| echo "[build] backbone weights not pre-warmed (no network) — fetched on first run"
|
|
|
|
RUN useradd --system --create-home --uid 999 trainer \
|
|
&& mkdir -p /data /out && chown -R trainer:trainer /app /out
|
|
USER trainer
|
|
|
|
ENV TRAINER_DATA_DIR=/data \
|
|
TRAINER_OUT_DIR=/out
|
|
VOLUME ["/out"]
|
|
ENTRYPOINT ["uv", "run", "--no-sync", "parking-trainer"]
|
|
CMD ["inspect"]
|