Skip to content

ITEP-90808: Add cosine similarity as a configurable option#1327

Merged
saratpoluri merged 68 commits into
mainfrom
feature/support-cosine
May 2, 2026
Merged

ITEP-90808: Add cosine similarity as a configurable option#1327
saratpoluri merged 68 commits into
mainfrom
feature/support-cosine

Conversation

@saratpoluri
Copy link
Copy Markdown
Contributor

@saratpoluri saratpoluri commented Apr 24, 2026

📝 Description

Adds configurable similarity-metric semantics to the ReID flow so the controller can run either distance-style matching (e.g., L2) or cosine-style matching (implemented via VDMS Inner Product with normalized embeddings).

Changes:

Add metric-aware vector preparation (flattening, dimension checks, optional normalization) and similarity-score validation for IP/cosine paths.
Make UUID matching logic metric-aware (higher-is-better for IP, lower-is-better for L2) and add/expand unit + functional test coverage around the new behavior.
Update docs and functional test matrices to cover metric selection and threshold semantics.

✨ Type of Change

Select the type of change your PR introduces:

  • 🐞 Bug fix – Non-breaking change which fixes an issue
  • 🚀 New feature – Non-breaking change which adds functionality
  • 🔨 Refactor – Non-breaking change which refactors the code base
  • 💥 Breaking change – Changes that break existing functionality
  • 📚 Documentation update
  • 🔒 Security update
  • 🧪 Tests
  • 🚂 CI

🧪 Testing Scenarios

Describe how the changes were tested and how reviewers can test them too:

  • ✅ Tested manually
  • 🤖 Ran automated end-to-end tests

✅ Checklist

Before submitting the PR, ensure the following:

  • 🔍 PR title is clear and descriptive
  • 📝 For internal contributors: If applicable, include the JIRA ticket number (e.g., ITEP-123456) in the PR title. Do not include full URLs
  • 💬 I have commented my code, especially in hard-to-understand areas
  • 📄 I have made corresponding changes to the documentation
  • ✅ I have added tests that prove my fix is effective or my feature works

saratpoluri and others added 30 commits April 11, 2026 01:28
Co-authored-by: Lukasz Talarczyk <lukasz.talarczyk@intel.com>
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Adds “live region dwell time” to region-scoped object outputs (region data + region events) so consumers can see how long an object has been inside a region at publish time.

Additionally, it updates the stability test to include memory leak checks.
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: scenescapecicd <sys_scenescape_ci@intel.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Sarat Poluri <sarat.chandra.poluri@intel.com>
Co-authored-by: Tomasz Dorau <tomasz.dorau@intel.com>
…1139)

VGGT outputs camera poses and depth in scale-ambiguous units, which cased:

Incorrect mesh dimenstions
incorrect pixels_per_meter in renderTopView
Inconsistent scale compared to MapAnything
This PR implements automatic metric scale for VGGT using known camera poses provided to` _processOutputs() and applies scale factor to:

Camera translations
world_points_from_depth
world_points
@saratpoluri
Copy link
Copy Markdown
Contributor Author

@copilot Address all code review comments.

…hresholds, metric-aware docs

Agent-Logs-Url: https://github.com/open-edge-platform/scenescape/sessions/bb444c83-c20c-4ba3-ad9b-50fec7959314

Co-authored-by: saratpoluri <1325325+saratpoluri@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 29, 2026

@copilot Address all code review comments.

Addressed in commit 51481b8:

  1. vdms_adapter.py:20 – Reverted SIMILARITY_METRIC default to "L2" so bare VDMSDatabase() no longer forces IP/normalization semantics.
  2. vdms_adapter.py:53-60 and uuid_manager.py:531-570 – Added _IP_SCORE_TOLERANCE = 1e-6 epsilon to all IP score bounds checks (±(1.0 + 1e-6)) so float32 rounding from VDMS won't silently drop near-perfect matches.
  3. reid-threshold-scenario.json:16-29 – Fixed COSINE threshold directionality: tight scenario now uses 0.99 (near-perfect cosine required → few matches → expect_exceed_max: true) and loose uses 0.01 (almost anything passes → many matches → expect_exceed_max: false).
  4. Extended-ReID.md:222-235 – Tuning guidance for similarity_threshold is now metric-specific: for L2 (lower-is-better) increase to widen / decrease to tighten; for COSINE (higher-is-better) the direction is reversed.
  5. Updated four unit tests that used bare VDMSDatabase() assuming IP default to explicitly pass similarity_metric="IP".

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 19 out of 19 changed files in this pull request and generated 3 comments.

Comment thread controller/src/controller/vdms_adapter.py Outdated
Comment thread controller/src/controller/vdms_adapter.py Outdated
Comment thread controller/src/controller/vdms_adapter.py Outdated
@saratpoluri saratpoluri force-pushed the feature/support-cosine branch from a4c1815 to 36b018c Compare April 30, 2026 22:17
@saratpoluri saratpoluri force-pushed the feature/support-cosine branch 4 times, most recently from 3a4d702 to ef6a6c9 Compare April 30, 2026 22:57
@saratpoluri saratpoluri force-pushed the feature/support-cosine branch from ef6a6c9 to a29eda8 Compare April 30, 2026 23:02
@saratpoluri saratpoluri enabled auto-merge (squash) May 1, 2026 17:57
@saratpoluri saratpoluri merged commit bb3180d into main May 2, 2026
33 checks passed
@saratpoluri saratpoluri deleted the feature/support-cosine branch May 2, 2026 00:03
Copy link
Copy Markdown
Contributor

@sarthakdeva-intel sarthakdeva-intel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

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.