Skip to content

docs(cookbooks): add pose estimation evaluation cookbook - #2842

Merged
Borda merged 6 commits into
roboflow:developfrom
8rulerstar:docs/cookbook-pose-keypoint-map
Nov 16, 2026
Merged

Borda merged 6 commits into
roboflow:developfrom
8rulerstar:docs/cookbook-pose-keypoint-map

Conversation

@8rulerstar

Copy link
Copy Markdown
Contributor

Description

Adds a cookbook that evaluates a pose model with KeyPointMeanAveragePrecision. None of the published cookbooks covers keypoints or pose yet, and since 0.31.0 supervision can compute COCO keypoint mAP directly.

It runs RF-DETR Keypoint (RFDETRKeypointPreview) on a fixed-seed slice of 200 COCO val2017 images with people, converts the COCO annotations to sv.KeyPoints (with area, iscrowd and the person boxes), scores the predictions, and plots the result. A last section reuses the same predictions to show two mistakes that change the score without an error:

  • scoring only predictions above the display threshold (0.5) drops mAP50-95 from 0.729 to 0.658
  • targets with class id 0 while the COCO-pretrained model reports id 1 give 0.000

Motivation and Context

KeyPointMeanAveragePrecision came in with #2687, and the metric docs show only a minimal loop. This gives a runnable example on real data.

Changes Made

  • docs/notebooks/evaluate-pose-estimation.ipynb: the cookbook, with outputs.
  • docs/theme/cookbooks.html: card at the end (KEYPOINTS,METRICS,EVALUATION, v0.31.2).

Testing

  • Ran the notebook top to bottom in an empty folder (macOS, MPS) with supervision==0.31.2 and rfdetr==1.11.2: about 1.5 minutes including the 241 MB annotations download. The install cell output and local rf-detr log lines were removed before committing.

  • Scored the same 200 images and predictions with pycocotools (iouType="keypoints", imgIds limited to the slice, results including each prediction's bbox). mAP50-95 / 50 / 75 / medium / large match to four decimals: 0.7286 / 0.9162 / 0.8004 / 0.6642 / 0.8200.

  • uvx pre-commit run --files docs/notebooks/evaluate-pose-estimation.ipynb docs/theme/cookbooks.html passes.

  • Not tested: a free Colab runtime.

  • Added/updated tests, and the full suite passes locally (not applicable, docs only)

  • Updated docs (new cookbook; no public API change)

  • Added a changelog entry in docs/changelog.md under Unreleased (skipped, docs-only change)

Additional Notes

  • rfdetr is pinned to 1.11.2 because the keypoint model is a preview whose API and weights may change; the numbers in the outputs are tied to that version.
  • This is complementary to the open pose augmentation cookbook (docs(cookbooks): pose augmentation with left/right keypoint remapping #2537): that one covers augmenting keypoints, this one evaluating them.
  • I kept the pycocotools comparison out of the notebook to keep it short. Happy to add it as an optional last cell if that would help.

@8rulerstar
8rulerstar requested a review from SkalskiP as a code owner October 28, 2026 05:31
@review-notebook-app

Copy link
Copy Markdown

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@codecov

codecov Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95%. Comparing base (f6d87f8) to head (bcfe0f5).

Additional details and impacted files
@@           Coverage Diff           @@
##           develop   #2842   +/-   ##
=======================================
  Coverage       95%     95%           
=======================================
  Files           84      84           
  Lines        15365   15365           
=======================================
  Hits         14625   14625           
  Misses         740     740           
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Borda
Borda requested a balanced review from Copilot October 28, 2026 08:19
@Borda Borda added the documentation Improvements or additions to documentation label Oct 28, 2026

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.

🔵 Needs a closer look

The changes require human validation beyond the automated review.

No open issues 🎉

What changed in this PR

Adds a cookbook for evaluating pose estimation with Supervision’s COCO keypoint mAP metric and makes it discoverable from the cookbook gallery.

Changes:

  • Introduces an RF-DETR Keypoint evaluation walkthrough, including common scoring mistakes.
  • Adds a gallery card tagged KEYPOINTS, METRICS, and EVALUATION, marked v0.31.2.

Review coverage was limited to the gallery change; the notebook itself was not included.

File Description
docs/​theme/​cookbooks.html Adds the pose evaluation cookbook link and card metadata.

Review effort: Balanced

@8rulerstar
8rulerstar force-pushed the docs/cookbook-pose-keypoint-map branch from f5d3b07 to ec75027 Compare November 16, 2026 00:19
Borda and others added 5 commits November 16, 2026 22:45
- Plot the mAP scores from `to_pandas` as a 6x3.5 inch bar chart with shortened labels instead of the fixed 10x6 inch `result.plot()`, and add a short markdown cell before and after it
- Set `figure.autolayout` so every figure, including the `sv.plot_images_grid` sample grid, uses tight layout
- Convert COCO boxes with `sv.xywh_to_xyxy` instead of the manual in-place add
- Pass whole prediction and target lists to `KeyPointMeanAveragePrecision().update` instead of looping per image
- Remap class ids with `dataclasses.replace` instead of rebuilding `sv.KeyPoints` field by field
- Annotate PIL images with `Image.fromarray` in the sample grid, dropping the BGR channel flip
- Replace the saved grid and chart images with outputs from a fresh run

---
Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
…-keypoint-map

---

Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
- Keep only the file name from each COCO image annotation, require the images.cocodataset.org prefix for image URLs, and check the destination stays inside the images folder
- Verify the downloaded annotations archive against a pinned SHA-256 and write the extracted JSON through a temporary file, removing the temporary archive in a finally block
- Keep the target area in float64 so areas near 32² and 96² cannot fall into two size buckets
- Require supervision 0.31.7 or newer in the install cell and update the cookbook card version to match
- State the tested environment (a Mac with Apple silicon, MPS), drop the T4 GPU notebook metadata, and say the seed fixes only the image sample

[resolve group] review items 1 2 3 4 5 6 7 of roboflow#2842

---
Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
Co-authored-by: Codex <[email protected]>
- Plot ground truth and RF-DETR predictions as one 1x2 pair per image instead of a 2x2 grid with blank cells
- Link rfdetr and supervision in the install cell
- Draw a y-axis grid behind the mAP bars

---
Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
- Re-run the notebook end to end with supervision 0.31.7 and rfdetr 1.11.2
- Replace stored plots with one ground truth and prediction pair per image
- Replace the mAP bar chart with the version that has a y-axis grid
- Print the installed supervision version as 0.31.7

---
Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>

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.

🔵 Needs a closer look

The primary notebook is absent from both the supplied diff and checkout, leaving only its cookbook card reviewable and its correctness and execution unassessed.

No open issues 🎉

Review effort: Balanced

@Borda
Borda merged commit d53034f into roboflow:develop Nov 16, 2026
36 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants