fix: unchain track 5 frames so one bad read cannot poison the rest

The chained attempt (1530bbc) fed each run's result into the next frame's
seed, so a wrong read on one frame carried into the ones after it. Runs are
independent again: every frame is seeded from the drawn shape, frames 2-5
with it grown x1.5 about its centre for motion tolerance. REQ-189, ui-spec
and tasks.md updated to the independent contract.
This commit is contained in:
asus committed 2026-10-05 12:35:17 +07:00
1 parent 1530bbc999
commit 9c95a4a759
4 files changed
+43 -34

No files matched your search

+13 -10
View File
@@ -171,16 +171,19 @@ changes.
- **REQ-189** — In the review editor, the user can push the **selected shape's** box forward
with *Track 5 Frames* (`[T]`): the next five frames each get their own REQ-043 box-assist
run, and the shape is written as `source=manual`. Both geometry types work — a bbox shape
supplies its own box, a polygon is reduced to its bounding box. Runs are **chained, not
independent**: the first frame gets the drawn box untouched, and after each successful run
that run's resulting shape seeds the next frame, grown about its centre by ×1.5 so the
object has room to have moved. A frame SAM3 refuses (nothing inside the box) is reported
and the run continues from the last good seed. Nothing selected, an unusable shape, or the
last frame says so instead of doing nothing. Known cost of chaining: a wrong read on one
frame can carry into the ones after it — the result banner reports only what happened. This
is one-shot hand-off across the next frames, **not** propagation of drawn exemplars (which
stays a non-goal): nothing is tracked frame-to-frame with a motion model, and the runs do
not share state between invocations.
supplies its own box, a polygon is reduced to its bounding box. Runs are **independent**:
every frame is seeded from the drawn shape and never from another run's result, so a wrong
read on one frame cannot carry into the ones after it. The first frame uses the drawn box
untouched; frames 2–5 use it grown about its centre by ×1.5, giving a moving object room
to be inside the seed window. A frame SAM3 refuses (nothing inside the box) is reported and
the remaining frames still run. Nothing selected, an unusable shape, or the last frame says
so instead of doing nothing. Consequence accepted: without chaining there is no size or
position readjustment between frames, so a fast-moving object can still leave the seed
window — denser extraction (higher fps) or a video-propagation requirement (not yet
written) is the fix. This is
one-shot hand-off across the next frames, **not** propagation of drawn exemplars (which
stays a non-goal): nothing is tracked frame-to-frame with a motion model, and the runs
share no state between invocations.
- **REQ-044** — All annotations and review statuses are **persistent** — they survive a
server restart, unlike today's in-memory sessions.
- **REQ-045** — Review progress is visible (e.g. "120/300 reviewed"), and a batch can only
+12 -9
View File
@@ -1409,15 +1409,18 @@ read it.
1. Root cause: `trackForward` sent the **same box** to all 5 frames, and batch 19 was
extracted at **fps 0.5** (one frame every 2 s, `batches.fps`) — a truck entering frame
outruns a static seed. Now the runs are **chained**: first frame gets the drawn box
untouched, each later frame is seeded with the previous run's resulting shape grown ×1.5
about its centre (`SEED_GROWTH`, `growBox`), a refused frame keeps the last good seed.
Geometry handling moved to a module-level `shapeBox()` reused by both call sites.
→ verify: **[DONE]** `npm run build` green; first frame un-grown (stationary case keeps
its exact precision); failure path leaves `seed` untouched; busy guard still blocks a
double-writes; **moving-object behaviour needs the user's GPU run** — expect chained
readjustment to hold a slow move, still lose a fast one at 0.5 fps (fix: re-extract at
2 fps via *Trim → frames per second*, or REQ-190 video propagation).
outruns a static seed. First attempt chained each run's result into the next frame's seed;
that let a wrong read on one frame carry into the following ones, which the user rejected
as poisoning. Final shape: runs are **independent again**, every frame seeded from the
drawn shape, frames 2–5 grown ×1.5 about its centre (`SEED_GROWTH`, `growBox`) for motion
tolerance. Geometry handling moved to module-level `shapeBox()`.
→ verify: **[DONE]** `npm run build` green; no frame's seed derives from a previous result
(`seed` reassignment removed, grep confirms `firstBox` is the only seed source); first frame
un-grown so the stationary case keeps exact precision; growth ×1.5 total size (not 2×);
busy guard still blocks double-writes. **Moving-object behaviour needs the user's GPU
run** — and without chaining, a fast-moving truck may still leave the seed window; fix is
re-extract at 2 fps (*Trim → frames per second*) or a video-propagation requirement
(not yet written; `sam3_video_inference.py` already has `propagate_in_video`).
## Task — Track 5 Frames works at all (REQ-189) `[DONE]`
+9 -7
View File
@@ -989,19 +989,21 @@ previous geometry** and shows the error. Same optimistic-with-rollback pattern f
- *Copy Prev* copies every annotation from frame `n-1` onto this frame (one POST per shape);
disabled at index 0 or when the previous frame is empty.
- *Track 5 Frames* takes the selected shape's bounding box and runs SAM3 assist on the next 5
frames with it. Works for both geometry types: a bbox shape supplies its own box, a polygon
frames with it — the first with that box exactly, the rest with it grown (see below). Works
for both geometry types: a bbox shape supplies its own box, a polygon
is reduced to its bounding box. Nothing selected, an unusable shape, or the last frame
says so in the error slot instead of silently doing nothing; a frame SAM3 refuses (nothing
inside the box) does not stop the rest — the banner then **starts** with `Tracked N of M`
(M = frames actually ahead, ≤ 5) followed by the per-frame failures. A second press while
a run is in flight is ignored. Shapes are written `source=manual`, exactly as a hand-drawn
one.
Runs are **chained**: the first frame uses the drawn box exactly, and every later frame is
seeded with the previous run's resulting shape, grown ×1.5 about its centre so a moving
object still fits. A refused frame keeps the last good seed for the next attempt. Chaining
is not tracking — there is no motion model — so a wrong read can carry forward; only denser
frame extraction (higher fps) or real video propagation fixes a fast-moving object
(REQ-189).
Runs are **independent**: every frame is seeded from the drawn shape, never from another
run's result, so a wrong read on one frame cannot poison the ones after it. The first frame
uses the drawn box exactly; frames 2–5 use it grown ×1.5 about its centre so a moving object
still fits the seed window. A refused frame does not stop the rest. Because nothing carries
between frames there is no size/position readjustment — a fast-moving object can still
outrun the seed; only denser frame extraction (higher fps) or real video propagation fixes
that (REQ-189).
**Quick reclass bar** appears whenever a shape is selected: one button per class
(`[n] name`, class-coloured) plus *Delete [Del]*.
+9 -8
View File
@@ -9,8 +9,9 @@ import ReviewSidebar from '../components/ReviewSidebar'
import ExemplarFilterPanel from '../components/ExemplarFilterPanel'
import useExemplarPool from '../hooks/useExemplarPool'
// How much bigger the seed box gets before each frame after the first, so the
// object has room to have moved. Hand-tuned, not learned (REQ-189).
// How much bigger the seed box gets for each frame after the first, so the
// object has room to have moved. Hand-tuned, not learned (REQ-189). The box
// always derives from the drawn shape — never from a previous run's result.
const SEED_GROWTH = 1.5
// SAM3 assist wants one normalized [x0, y0, x1, y1] box (REQ-043). A bbox
@@ -413,19 +414,19 @@ export default function ReviewPage({ batchId: rawBatchId, projectId, onProject }
setError('')
try {
let tracked = 0
let seed = firstBox
const failures = []
for (let i = 0; i < ahead.length; i++) {
const targetFrame = ahead[i]
// The first frame uses the drawn box untouched. After that the object
// has had time to move, so the last result seeds a wider box.
const seedBox = i === 0 ? seed : growBox(seed, SEED_GROWTH)
// Every frame is seeded from the drawn box, never from a previous
// result, so a bad read on one frame cannot carry into the next.
// Frames 2-5 get it grown about its centre — the object has had
// time to move by then.
const seedBox = i === 0 ? firstBox : growBox(firstBox, SEED_GROWTH)
try {
const created = await api.assist(targetFrame.id, {
await api.assist(targetFrame.id, {
box: seedBox, class_id: current.class_id,
})
tracked++
seed = shapeBox(created?.geometry) ?? seed
patchFrameLocally(targetFrame.id, { annotation_count: (targetFrame.annotation_count ?? 0) + 1 })
} catch (exc) {
failures.push(`frame ${index + i + 2}: ${exc.message}`)