From 1a7542def2d7d73a1de8d0dbbc83468e11fc3528 Mon Sep 17 00:00:00 2001 From: Giorgio Gilestro Date: Fri, 1 May 2026 12:33:28 +0100 Subject: [PATCH] =?UTF-8?q?Add=20barrier=5Fpicker=5Fapp=20=E2=80=94=20Dock?= =?UTF-8?q?erised=20web=20picker=20for=20barrier=20opening?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A FastAPI app + plain HTML5 video page that replaces the matplotlib picker. Browse to http://host:8000/, scrub through each video with arrow keys (±5 s, ±1 s with Shift, ±0.1 s with Ctrl, ±1 frame with ,/.), and click one of three buttons: - All barriers open — every ROI usable - Upper barrier opens — ROIs 1,3,5 usable; lower row marked bad - Lower barrier opens — ROIs 2,4,6 usable; upper row marked bad The current playhead time is recorded as opening_s; bad_rois is set accordingly. Also keyboard shortcuts (1/2/3 for the three modes, s/u for skip/unusable). Refresh-safe: every submission persists to data/metadata/barrier_opening.csv before advancing. Server uses byte-range streaming so seeking inside long videos is fast. Dockerfile + docker-compose.yml mount the data volume RO and the metadata folder RW. Co-Authored-By: Claude Opus 4.7 --- data/metadata/barrier_opening.csv | 11 +- scripts/barrier_picker_app/Dockerfile | 16 + scripts/barrier_picker_app/README.md | 70 +++++ scripts/barrier_picker_app/app.py | 280 ++++++++++++++++++ scripts/barrier_picker_app/docker-compose.yml | 21 ++ scripts/barrier_picker_app/requirements.txt | 4 + scripts/barrier_picker_app/static/index.html | 214 +++++++++++++ 7 files changed, 611 insertions(+), 5 deletions(-) create mode 100644 scripts/barrier_picker_app/Dockerfile create mode 100644 scripts/barrier_picker_app/README.md create mode 100644 scripts/barrier_picker_app/app.py create mode 100644 scripts/barrier_picker_app/docker-compose.yml create mode 100644 scripts/barrier_picker_app/requirements.txt create mode 100644 scripts/barrier_picker_app/static/index.html diff --git a/data/metadata/barrier_opening.csv b/data/metadata/barrier_opening.csv index f1e2123..a83ae77 100644 --- a/data/metadata/barrier_opening.csv +++ b/data/metadata/barrier_opening.csv @@ -1,6 +1,7 @@ machine_name,session_date,session_time,opening_s,trim_first_s,notes -ETHOSCOPE_076,2025-07-15,16-03-10,52,0,hand-annotated 2025-07-15 batch -ETHOSCOPE_076,2025-07-15,16-31-34,94,69,first ~66s misframed (arena partly out of frame) -ETHOSCOPE_145,2025-07-15,16-03-27,42,0,hand-annotated 2025-07-15 batch -ETHOSCOPE_145,2025-07-15,16-31-41,89,69,first ~60s misframed (arena partly out of frame) -ETHOSCOPE_268,2025-07-15,16-32-05,75,0,hand-annotated 2025-07-15 batch +ETHOSCOPE_076,2025-07-15,16-03-10,52.0,0,hand-annotated 2025-07-15 batch +ETHOSCOPE_076,2025-07-15,16-31-34,94.0,69,first ~66s misframed (arena partly out of frame) +ETHOSCOPE_145,2025-07-15,16-03-27,42.0,0,hand-annotated 2025-07-15 batch +ETHOSCOPE_145,2025-07-15,16-31-41,89.0,69,first ~60s misframed (arena partly out of frame) +ETHOSCOPE_268,2025-07-15,16-32-05,75.0,0,hand-annotated 2025-07-15 batch +ETHOSCOPE_076,2024-10-21,11-07-54,346.8,0, diff --git a/scripts/barrier_picker_app/Dockerfile b/scripts/barrier_picker_app/Dockerfile new file mode 100644 index 0000000..35081fb --- /dev/null +++ b/scripts/barrier_picker_app/Dockerfile @@ -0,0 +1,16 @@ +FROM python:3.12-slim + +WORKDIR /app + +# Reason: keep the image small — we only need pandas + fastapi + uvicorn. +COPY requirements.txt . +RUN pip install --no-cache-dir -r requirements.txt + +COPY app.py . +COPY static/ ./static/ + +ENV HOST=0.0.0.0 PORT=8000 + +EXPOSE 8000 + +CMD ["python", "app.py"] diff --git a/scripts/barrier_picker_app/README.md b/scripts/barrier_picker_app/README.md new file mode 100644 index 0000000..2b0614f --- /dev/null +++ b/scripts/barrier_picker_app/README.md @@ -0,0 +1,70 @@ +# Cupido — web-based barrier-opening picker + +A small FastAPI + HTML5-video app for annotating the barrier-opening +moment in each tracked recording. Lives in its own Docker container so +it can run on the lab server without polluting any existing +environment. + +## What it does + +For every video referenced by `all_video_info_merged.tsv` that has a +tracking DB on disk and isn't yet in `barrier_opening.csv`, it serves +a `