Skip to content

feat(keypoints): add keypoint conversion bridge#2277

Merged
Borda merged 20 commits into
developfrom
feat/keypoints
May 28, 2026
Merged

feat(keypoints): add keypoint conversion bridge#2277
Borda merged 20 commits into
developfrom
feat/keypoints

Conversation

@Borda

@Borda Borda commented May 27, 2026

Copy link
Copy Markdown
Member

No description provided.

Co-authored-by: Codex <codex@openai.com>
@codecov

codecov Bot commented May 27, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 87.27273% with 21 lines in your changes missing coverage. Please review.
✅ Project coverage is 79%. Comparing base (81218c5) to head (efc08bf).

Additional details and impacted files
@@           Coverage Diff            @@
##           develop   #2277    +/-   ##
========================================
  Coverage       78%     79%            
========================================
  Files           66      66            
  Lines         8416    8567   +151     
========================================
+ Hits          6594    6726   +132     
- Misses        1822    1841    +19     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Borda Borda force-pushed the feat/keypoints branch from ca585e9 to b741e05 Compare May 27, 2026 12:19
Borda added 2 commits May 27, 2026 14:29
…ilities

- Simplify `ValueError` matching in `KeyPoints.from_rfdetr` tests.
- Refactor utilities to ensure typed consistency in `merge_data`, `is_data_equal`, and metadata handling.
- Add `_optional_array_equal` helper for comparing arrays with `None` values.
- Enhance type annotations and casting for clarity and correctness in keypoint operations.
- Improve masking logic consistency for conversions and indexing.
…t arrays

- Skip rendering ellipses for non-finite confidence values in `VertexEllipseAnnotator`.
- Ensure `KeyPoints.from_rfdetr` handles empty keypoint arrays by returning an empty instance.
- Add tests for both scenarios for better coverage and validation.
@Borda Borda marked this pull request as ready for review May 27, 2026 15:58
@Borda Borda requested a review from SkalskiP as a code owner May 27, 2026 15:58
Copilot AI review requested due to automatic review settings May 27, 2026 15:58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds an RF-DETR → KeyPoints bridge plus a covariance-ellipse annotator for visualizing per-keypoint uncertainty. KeyPoints.from_rfdetr reads keypoints (and optionally keypoint_precision_cholesky + source_shape) from a Detections instance, converting precision parameters to pixel-space covariance stored under data["covariance"]. The new VertexEllipseAnnotator consumes this covariance to draw solid or dashed ellipses around vertices. Supporting changes loosen is_data_equal / merge_data typing to allow list[Any] data values and switch keypoint equality to a None-safe array comparison.

Changes:

  • Add KeyPoints.from_rfdetr plus internal helpers for source-shape validation and Cholesky-precision-to-pixel-covariance conversion, and make __eq__ None-safe.
  • Add VertexEllipseAnnotator (solid/dashed ellipses, confidence filtering, configurable covariance data key) and export it from supervision.
  • Relax is_data_equal / merge_data type signatures and adjust typing casts in KeyPoints; add tests for the new converter and annotator.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/supervision/key_points/core.py Adds RF-DETR converter, covariance helpers, _optional_array_equal, and typing-related casts.
src/supervision/key_points/annotators.py Implements VertexEllipseAnnotator with solid/dashed rendering and covariance validation.
src/supervision/detection/utils/internal.py Broadens is_data_equal / merge_data typing to support list[Any] data values.
src/supervision/init.py Exports the new VertexEllipseAnnotator from the top-level package.
tests/key_points/test_core.py Adds RF-DETR fixture and tests for keypoints, covariance, missing-data, and empty cases.
tests/key_points/test_from_rfdetr.py New test module covering the from_rfdetr conversion and downstream annotators.
tests/key_points/test_annotators.py Adds TestVertexEllipseAnnotator covering rendering, validation, and edge cases.

Comment thread src/supervision/__init__.py
Comment thread src/supervision/key_points/core.py
Comment thread src/supervision/key_points/core.py
Comment thread src/supervision/key_points/core.py Outdated
Borda and others added 12 commits May 27, 2026 18:53
- Add VertexEllipseAnnotator tab with usage code example
- Add mkdocstrings reference block for API docs generation

---
Co-authored-by: Claude Code <noreply@anthropic.com>
- Add pycon-style doctest showing basic usage and optional covariance path

---
Co-authored-by: Claude Code <noreply@anthropic.com>
- Add Note section to from_rfdetr docstring clarifying (height, width) order
- Update _rfdetr_source_shape ValueError message to state (height, width)

---
Co-authored-by: Claude Code <noreply@anthropic.com>
- Check precision_cholesky.shape[:2] == keypoints.shape[:2] before
  covariance computation; raises ValueError with clear message on mismatch

---
Co-authored-by: Claude Code <noreply@anthropic.com>
- Count non_finite, singular, and overflow failures per conversion call
- Emit aggregated logger.warning when any keypoints are skipped

---
Co-authored-by: Claude Code <noreply@anthropic.com>
- Cast np.asarray result in _get_covariances to NDArray[np.float32]
- Cast reshape+astype result in VertexLabelAnnotator to NDArray[np.int_]

---
Co-authored-by: Claude Code <noreply@anthropic.com>
…seAnnotator

- Verify low-confidence keypoint (0.3 < threshold 0.5) is not drawn
- Verify high-confidence keypoint (0.7 > threshold 0.5) is drawn

---
Co-authored-by: Claude Code <noreply@anthropic.com>
- Test max_axis_length clamps large covariance eigenvalues
- Parametrized test for all constructor ValueError guards (sigma, thickness,
  max_axis_length, dash_length)

---
Co-authored-by: Claude Code <noreply@anthropic.com>
…nnotator

- Note that near-singular precision can produce frame-spanning ellipses
- Recommend setting a pixel bound for production use

---
Co-authored-by: Claude Code <noreply@anthropic.com>
…e docstring

---
Co-authored-by: Claude Code <noreply@anthropic.com>
- Note that confidence is stored as-is (expected probability 0-1)
- Warn about logit-scale output requiring adjusted threshold

---
Co-authored-by: Claude Code <noreply@anthropic.com>
… docstring

- from_rfdetr accepts sv.Detections (not native RF-DETR output); explain why

---
Co-authored-by: Claude Code <noreply@anthropic.com>
@Borda Borda added the enhancement New feature or request label May 27, 2026
Borda added 2 commits May 27, 2026 20:18
- Replace `|` with `Union` for backward compatibility
- Update `Optional` usage for clarity in `from_rfdetr` method
- Add explicit check and conversion for None class_id in RF-DETR detections

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 8 out of 8 changed files in this pull request and generated no new comments.

@Borda Borda merged commit 918b613 into develop May 28, 2026
30 checks passed
@Borda Borda deleted the feat/keypoints branch May 28, 2026 08:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants