docs: changelog and plan for the cross-model dedup fix

CHANGELOG: the same-class dedup dropped overlapping sacks (FCP keeps every
tracked detection) - published counts increase, the 20-minute test clip now
reports the same 161 in / 1 out as FCP.

Plan: Task 14 (dedup across models only) and the full-clip cross-check
result (161 / 1 / 160 on both sides).
This commit is contained in:
jetson committed 2026-10-28 12:02:48 +07:00
1 parent ac2a2350ad
commit ce93c68dc2
2 files changed
+48 -6

No files matched your search

+11
View File
@@ -29,6 +29,17 @@ version tags are cut in this repo — `main` is the release line).
- `ERD.md` (Mermaid ERD) + this changelog (`97507f8`).
### Fixed
- **Overlapping sacks of one model were dropped** (`ac2a235`): the merged
pipeline ran a same-class IoU-0.5 dedup over **all** detections, including
the primary model's own tracked ones. FCP keeps every tracked detection —
the detector's own NMS already removed duplicates inside a model
(`predict.py:891`). Two sacks stacked on the truck overlap by more than
IoU 0.5, so the recounter dropped one of them and lost its crossing (54
detections dropped in 400 frames of the test clip).
**Consequence: published counts increase** — on the 20-minute test clip
the recounter now reports the same 161 in / 1 out as FCP (it reported
158 in / 1 out before). The dedup now compares only detections from
different models.
- **Upload 500 on new video + start analysis**: `/upload` referenced
`video_path` in `probe_video(video_path)` before the variable was defined
(`NameError` → Flask 500). Removed the duplicate premature height-check
@@ -1057,6 +1057,32 @@ defaults (still not FCP's — see Out of Scope).
---
### Task 14: Dedup across models only — a same-model overlap is a real sack
> Added after the full-clip cross-check against FCP (verification step 6)
> showed 158 sacks where FCP counted 161.
**What was wrong:** the merged pipeline ran a same-class IoU-0.5 dedup over **all**
detections (`_deduplicate_detections`), including the primary model's own tracked
detections. FCP keeps every tracked detection — the detector's own NMS already
removed the duplicates inside a model (`predict.py:891`). Two sacks stacked on a
truck overlap by more than IoU 0.5, so the recounter dropped one of them and lost
its crossing: 54 detections dropped in 400 frames of the test clip.
**Changes:**
- `_deduplicate_detections(primary, extras, iou_threshold)` compares only
detections from **different** models.
- The tracked primary always wins: an extra carries a synthetic track id, and
swapping the id would lose the track's crossing history.
**Commits:** `ac2a235`.
**Verification:** the full clip now reports `loading 161, unloading 1, net 160` —
identical to FCP's `{'total_masuk_truck': 161, 'total_keluar_truck': 1,
'net_karung_di_truk': 160}`.
---
## Out of Scope (deliberately not ported)
| FCP feature | Why not |
@@ -1076,7 +1102,7 @@ defaults (still not FCP's — see Out of Scope).
## Verification
1. **Unit suite**: `python -m pytest tests/ -q` → zero failures (baseline was 204 passed; the branch adds tests in Tasks 0–3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 — 315 passed at the end of the branch).
1. **Unit suite**: `python -m pytest tests/ -q` → zero failures (baseline was 204 passed; the branch adds tests in Tasks 0–3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 — 318 passed at the end of the branch).
2. **Calibration equality** (static geometry must match FCP exactly):
```bash
python - <<'PY'
@@ -1126,9 +1152,14 @@ defaults (still not FCP's — see Out of Scope).
```
Expected: `loading_count` / `unloading_count` agree, or differ by at most the documented platform-only differences (FCP counts a live session per truck batch; the recounter counts the whole clip). Record the actual delta in the PR description.
**Done on this box (2026-10-28)** — a 60 s excerpt of
`uploads/b4-2026-10-15-09-49-46.mp4` (t=170 s), model mode C:
FCP `{'total_masuk_truck': 6, 'total_keluar_truck': 0, 'net_karung_di_truk': 6,
'box_masuk_truck': 0}` vs the recounter `loading 6, unloading 0, net 6,
box_loading 0` — **the same counts**.
**Done on this box (2026-10-28)** — the whole clip
`uploads/b4-2026-10-15-09-49-46.mp4` (15 393 frames, 20 min), model mode C:
FCP `{'total_masuk_truck': 161, 'total_keluar_truck': 1,
'net_karung_di_truk': 160, 'box_masuk_truck': 0}` vs the recounter
`loading 161, unloading 1, net 160, box_loading 0` — **the same counts**.
A 60 s excerpt (t=170 s) agrees as well (6 / 0 / 6 on both sides).
The first full-clip comparison was 158 / 1 / 157 — 3 sacks short. The
cause was the recounter's own same-class IoU-0.5 dedup in the merged
pipeline, which dropped overlapping sacks that FCP keeps (Task 14).
7. **Manual spot check**: play the annotated output of one clip and confirm the counted sacks are exactly the ones that crossed the calibrated line inside the counting polygon.