Skip to content

feat(identity): condition box padding on the box's source (gate item 4) - #12

Merged
AlexSKuznetsov merged 1 commit into
mainfrom
feat/source-conditioned-box-padding
Aug 27, 2026
Merged

feat(identity): condition box padding on the box's source (gate item 4)#12
AlexSKuznetsov merged 1 commit into
mainfrom
feat/source-conditioned-box-padding

Conversation

@AlexSKuznetsov

Copy link
Copy Markdown
Collaborator

What

Splits the single global identity_box_padding (0.12) into two source-conditioned knobs, applied at the call site that knows where the box came from:

Box source Knob Default Call sites
Grounder (VLM analyze/localize) identity_grounder_box_padding 0.75 query path (pipeline.py, ×3) + grounded enroll (enroll.py, ×2)
Tracker (SAM2, register button) identity_tracker_box_padding 0.0 enroll_center_anchor (enroll.py, ×1)

enroll_manual is unaffected — it masks with a full-ones mask, so padding never applies there.

Why

Gate item 4 (docs/19-Post-Spike-Build-Plan.md), spikes 3e/2e. One padding value can't serve both sources:

  • A grounder box can be cropped tight to the object's most recognizable part; widening it repairs the scoping (F1 0.776 → 0.909, spike 3e).
  • A tracker box has no such defect, so the same padding only pulls in desk and hurts separation (+0.340 → +0.255, spike 2e).

Local validation (padding sweep on the identity probe)

Ran a real sweep to pick the grounder default rather than inherit 0.75 blind: LFM-3B grounds every probe image (local proxy for Cosmos), then the production crop path (box_to_maskprepare_masked_crop) at each padding → C-RADIOv4-H → the probe's balanced accept/reject scoring. native = bare LFM box; extent = LFM + item 3's extent clause (post-item-3 proxy).

boxset    pad    sep     F1    AUC
native   0.12  0.018  0.432  0.546   ← old shipped default (too low)
native   0.75  0.115  0.824  0.875
extent   0.00  0.112  0.846  0.864
extent   0.50  0.163  0.917  0.942   ← best separation/margin
extent   0.75  0.153  0.936  0.949   ← best F1/AUC, reject rate 1.00
  • The old 0.12 was genuinely too low; 0.75 is where a mis-scoped box becomes healthy (reproduces spike 3e).
  • Item 3 and item 4 are complementary: a well-scoped (extent) box at 0.0 padding already beats a bare box at 0.75, but padding still adds separation on top, peaking at 0.5–0.75.
  • 0.75 is the safer default — near-optimal when the box is well-scoped, clearly best when it isn't. No case for dialing back toward 0.12.

Caveats: LFM is a proxy for Cosmos; n=36 across 3 keyring instances; the tracker side (0.0) was not re-verified here (the probe has no tracked clips).

Tests

  • New test_box_padding_is_conditioned_on_the_box_source asserts the grounded path widens (grounder padding) and the register-button path stays tight (tracker padding), across both enrollment paths.
  • Full suite 175 passed, ruff and pyright clean.

🤖 Generated with Claude Code

One global `identity_box_padding` (0.12) padded every identity crop the same,
but the enrollment-redesign spikes measured two opposite optima by source:

- A grounder box (VLM analyze/localize) can be cropped tight to the object's
  most recognizable part; widening it to 0.75 repairs the scoping (F1 0.776
  -> 0.909, spike 3e).
- A tracker box (SAM2, register button) has no such defect, so the same
  padding only pulls in desk and hurts separation (+0.340 -> +0.255, spike 2e).

Split the knob into `identity_grounder_box_padding` (0.75) and
`identity_tracker_box_padding` (0.0), and apply each at the call site that
knows the box origin: the query path and the grounded enrollment path crop
grounder boxes; `enroll_center_anchor` crops the tracker box. `enroll_manual`
is unaffected (it masks with a full-ones mask). Status surface and wiring
updated; a test asserts padding-per-source across both enrollment paths.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@AlexSKuznetsov
AlexSKuznetsov merged commit 8f4c0e7 into main Aug 27, 2026
2 checks passed
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