fix(tracking): named-target drift + occlusion chase; perf: ReID on GPU#101
Closed
TCVinNYC wants to merge 5 commits into
Closed
fix(tracking): named-target drift + occlusion chase; perf: ReID on GPU#101TCVinNYC wants to merge 5 commits into
TCVinNYC wants to merge 5 commits into
Conversation
Bug: when a target was selected by identity (name) and then lost, the appearance-only ReID recovery (`_maybe_reid_recover`) re-bound the lock to whatever visible track best matched the body template — so the camera drifted onto the next visually-similar person, then the next unknown track. A named-identity target now re-binds via ReID only to a track that face-recognition has confirmed as the SAME identity (`_reid_rebind_allows`); otherwise it stays searching until the real person's face is seen again. A manual/clicked target (no identity) keeps the appearance-based re-bind it relies on. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…luded target Bug: when the target was covered by something/someone the detector returned only the visible part (e.g. the legs); the tracker kept that shrinking box as a confident, non-lost track, so the PTZ chased it down to the last-known partial position (box + aim dot drifting onto the legs). The drive loop now tracks a slowly-updated "healthy" target-height reference and coasts (track_active=False) when the box height suddenly collapses below it — the occlusion signature — while a gradual shrink (the subject walking away) keeps the reference in step and is NOT flagged, so normal following is unaffected. The camera resumes when the subject reappears at full size. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…always CPU ReID was pinned to device="cpu" — a major per-frame cost on Macs that also stalls the inference thread through the GIL (the appearance pass holds it during the torch/numpy work). It now auto-selects the Apple GPU (mps) or CUDA when available and falls back to CPU if GPU init fails. AUTOPTZ_REID_DEVICE overrides the choice (e.g. =cpu if an OSNet op misbehaves on mps). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…ITS) On Intel + AMD Macs (e.g. iMac Pro Xeon + Vega 56) CoreML may silently run on the CPU instead of the discrete GPU. The compute-unit target is now configurable (default ALL) so it can be verified/forced: run `--bench` with CPUOnly and again with ALL/CPUAndGPU and compare to see whether the Vega is actually helping. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Member
Author
|
Superseded by #100 — |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Three root-cause fixes from a systematic debugging pass on the user's report (each TDD'd, full suite green). These are pre-existing issues on
main/rc2, independent of PR #100.Fixes
_reid_rebind_allows); otherwise it stays searching. Manual/clicked targets keep appearance re-bind.lost, so the PTZ chased it down to the last-known partial position. The drive loop now tracks a slow "healthy height" reference and coasts on a sudden collapse (occlusion) while a gradual shrink (walking away) keeps following — distinguished so normal following is unaffected.device="cpu"(a major per-frame cost on the M4 Pro that also stalled the inference thread via the GIL). It now auto-selects mps/CUDA with a CPU fallback;AUTOPTZ_REID_DEVICEoverrides.Why these
Measured on an M4 Pro: detector = 11ms (CoreML, accelerated). The 148ms with all services on is face (forced CPU) + ReID (CPU) — #3 gets ReID onto the GPU. #1/#2 are the "loses my person / chases the wrong box" report.
Tests
New
tests/test_target_lock.py,tests/test_reid_device.py. Full suite 1046 passing, ruff clean.Validate on real cameras before merge
mpsand the per-frame budget drops (setAUTOPTZ_REID_DEVICE=cputo compare / if mps misbehaves).🤖 Generated with Claude Code