Skip to content

feat(reid): appearance ReID association via standalone reid package#511

Open
AlexBodner wants to merge 36 commits into
developfrom
feat/core/reid-consume-reid-package
Open

feat(reid): appearance ReID association via standalone reid package#511
AlexBodner wants to merge 36 commits into
developfrom
feat/core/reid-consume-reid-package

Conversation

@AlexBodner

@AlexBodner AlexBodner commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds optional appearance-ReID to BoT-SORT, sourcing the model stack from the standalone reid package. Trackers ships only NumPy association glue (ReIDEncoder, FeatureBank, appearance_similarity, extract_detection_embeddings) plus BoT-SORT appearance–IoU fusion. Encoder weights, preprocessing, catalog, and gallery evaluation live in reid and are never vendored.

This branch is rebased onto current develop and is independent of the earlier stacked ReID PRs (#480/#501/#502).

Depends on publishing reid (re-ID#1 is merged to main; PyPI / public install still pending).

Added things

  • Deps: trackers[reid] optional extra → temporary git pin reid @ git+…@main until PyPI. reid.* in mypy overrides; uv.lock updated.
  • Association glue (src/trackers/core/reid/, torch-free): ReIDEncoder, FeatureBank (BoT-SORT EMA L2 before/after blend), appearance_similarity, extract_detection_embeddings.
  • Lazy import: CLI loads reid.ReIDModel at use time (same pattern as detection); Importing BoT-SORT stays free of reid / torch (isolation test).
  • BoT-SORT wiring: appearance–IoU fusion, per-track feature bank, params reid_model, reid_ema_alpha, appearance_threshold, proximity_threshold.
  • CLI: --tracker.reid.{enable,model,device,architecture} on trackers track (BoT-SORT only).
  • Tests: association / fusion / CLI unit tests (no --extra reid required), @integration smoke with a real reid.ReIDModel, isolation test.
  • Docs / notebook: docs/api/reid.md, install notes, BoT-SORT Appearance ReID section; eval notebook uses public trackers[reid] install path.
  • CI: unit (ci-tests.yml) syncs without --extra reid; integration (ci-integrations.yml) keeps --extra reid.

Pre-merge checklist

  • Publish reid to PyPI (dev / pre-release is fine).
  • Swap the git pin in pyproject.toml to a PyPI range (e.g. reid>=0.1.0,<0.2 or the chosen pre-release pin) and refresh uv.lock.
  • Confirm integration CI is green with --extra reid (smoke should run, not skip).
  • Optional: confirm FastReID / OSNet defaults and MOT17 reference numbers still match intended parity.

@AlexBodner
AlexBodner requested a review from SkalskiP as a code owner July 21, 2026 14:01
AlexBodner and others added 3 commits July 21, 2026 11:07
Add the optional trackers[reid] extra (git-pinned roboflow-reid during
review) plus the lazy trackers._reid boundary that resolves reid.ReIDModel
on demand. Ship association-only, torch-free modules under
trackers.core.reid: the ReIDEncoder protocol, FeatureBank (per-track EMA),
and appearance_similarity / extract_detection_embeddings.

The model stack (encoder, weights, preprocessing, catalog, gallery eval)
lives in the standalone reid package and is never vendored.

Co-authored-by: Cursor <cursoragent@cursor.com>
Add appearance-IoU fusion (botsort/fusion.py) and wire it into BoT-SORT's
first and unconfirmed association stages, gated by proximity (standard IoU)
and appearance thresholds. Tracklets gain an optional per-track feature
bank; matched high-confidence detections update it. reid_model,
reid_ema_alpha, appearance_threshold, and proximity_threshold are new
BoTSORTTracker params; reid_model is excluded from CLI reflection.

Add --tracker.reid.{enable,model,device,architecture} CLI flags routed
through trackers._reid to reid.ReIDModel.from_pretrained. Importing BoT-SORT
stays torch-free (asserted by an isolation test). Add association/fusion/CLI
unit tests and a reid-backed integration smoke; docs and mkdocs nav cover
the association-only surface and link the model/eval stack out to reid.

CI installs the reid extra (unfrozen while the dep is a git pin).

Co-authored-by: Cursor <cursoragent@cursor.com>
- FeatureBank.update now L2-normalizes the incoming embedding and the
  resulting EMA, keeping the stored feature on the unit hypersphere
  (matches upstream BoT-SORT STrack.update_features). reid returns raw
  embeddings; normalization happens in the bank. Docstrings/tests updated.
- Vectorize appearance._l2_normalize_rows.

Co-authored-by: Cursor <cursoragent@cursor.com>
@AlexBodner
AlexBodner force-pushed the feat/core/reid-consume-reid-package branch from 5afd3b9 to fbbe664 Compare July 21, 2026 14:15
@AlexBodner AlexBodner changed the title feat(reid): appearance ReID association via standalone roboflow-reid package feat(reid): appearance ReID association via standalone reid package Jul 21, 2026
AlexBodner and others added 6 commits July 21, 2026 12:04
…tion.

Ports eval_trackers_reid from the reid-training branch with standalone reid imports and Colab-friendly private git installs for both trackers and re-ID.

Co-authored-by: Cursor <cursoragent@cursor.com>
Exclude the default dev group from build/docs sync, authenticate git in
integration/pytest workflows, and fix pre-commit failures in the ReID
benchmark notebook and codespell config.

Co-authored-by: Cursor <cursoragent@cursor.com>
Move the private git dependency to the reid extra only, avoid uv run
re-syncing the dev group in build/docs jobs, and fix notebook JSON for
pre-commit.

Co-authored-by: Cursor <cursoragent@cursor.com>
State what trackers.core.reid covers positively, defer model/eval to the
reid package, and drop subtractive architecture prose. Align install extra
wording with develop (no roboflow-reid in prose).

Co-authored-by: Cursor <cursoragent@cursor.com>
AlexBodner and others added 2 commits July 21, 2026 12:27
Add MOT17 val with/without ReID reference scores to the ReID API page and align the BoT-SORT optional ReID section with trackers docs style.

Co-authored-by: Cursor <cursoragent@cursor.com>
Load frames by MOT index, use per-sequence FPS, re-encode to H.264 for notebook/Colab playback, and embed at the combined panel width.

Co-authored-by: Cursor <cursoragent@cursor.com>
AlexBodner and others added 7 commits July 22, 2026 10:48
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Inline the optional reid import in the CLI like detection/tune, and keep
all BoT-SORT ReID coverage in one test module.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
AlexBodner and others added 14 commits July 22, 2026 11:23
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Default proximity to the association matrix so callers only pass a separate
standard-IoU gate when association uses GIoU/DIoU/CIoU.

Co-authored-by: Cursor <cursoragent@cursor.com>
Match upstream BoT-SORT: one IoU compute, proximity mask from the pre-fusion
matrix, score fusion only for association. Recompute only for IoU variants.

Co-authored-by: Cursor <cursoragent@cursor.com>
Only compute standard IoU for ReID proximity when association uses a
variant metric; plain IoU reuses the association matrix.

Co-authored-by: Cursor <cursoragent@cursor.com>
One helper builds score-fused geometry plus optional appearance fusion,
shared by first and unconfirmed association. Drop thin wrappers and
redundant comments.

Co-authored-by: Cursor <cursoragent@cursor.com>
Drop the duplicate prerequisite helper and reject --tracker.reid.architecture
without --tracker.reid.model so bare architecture cannot load random weights.

Co-authored-by: Cursor <cursoragent@cursor.com>
Use the published package name `reid` (git@main until PyPI), keep unit tests free of `--extra reid`, and clean up ReID association glue/docs/tests for the cutover.

Co-authored-by: Cursor <cursoragent@cursor.com>
Drop redundant embedding validation, dead reset/is_initialized API, and defensive getattr; keep device="auto" for reid to resolve.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant