fix: resolve medium dataset findings#2408
Merged
Merged
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #2408 +/- ##
=======================================
- Coverage 87% 86% -1%
=======================================
Files 70 70
Lines 10240 10330 +90
=======================================
+ Hits 8868 8872 +4
- Misses 1372 1458 +86 🚀 New features to boost your workflow:
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses a set of medium-severity findings across Supervision’s dataset utilities, metrics, trackers, and asset management. The changes focus on preventing unintended caller-data mutation, improving dataset format robustness (COCO/YOLO/folder-structure), and correcting size-bucket metric computation.
Changes:
- Prevents mutation of caller-owned objects in
DetectionDatasetandByteTrack, and adds clearer validation/error behavior around invalid dataset annotations. - Improves dataset format compatibility (COCO tolerates missing
iscrowd/area, YOLO accepts non-RGB modes for size reads) and updates COCO export area semantics for masks. - Fixes size-bucket metric computation by matching across the full detection set first, then scoring per bucket; adds explicit errors for MASKS metrics when masks are missing.
Review scores (n/5):
- Code quality: 4/5
- Testing: 4/5
- Documentation/changelog: 4/5
Reviewed changes
Copilot reviewed 21 out of 21 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/tracker/test_byte_tracker.py | Adds coverage for ByteTrack activation threshold clamping and input non-mutation. |
| tests/test_validators.py | Adds tests for private validator helpers to ensure consistent ValueError messaging. |
| tests/metrics/test_size_buckets.py | Adds regression tests for size-bucket matching behavior and MASKS target validation. |
| tests/dataset/test_core.py | Adds tests for folder-structure loader robustness and DetectionDataset annotation copying/range checks. |
| tests/dataset/formats/test_yolo.py | Adds test ensuring YOLO loader can handle RGBA PNGs when reading dimensions. |
| tests/dataset/formats/test_coco.py | Adds coverage for missing COCO fields, use_iscrowd, and mask-area export behavior. |
| tests/classification/test_core.py | Extends mocks/tests for timm softmax output and numpy-safe equality. |
| tests/assets/test_downloader.py | Updates/adds tests for MD5 verification and retry logic in asset downloads. |
| src/supervision/tracker/byte_tracker/core.py | Clamps det_thresh below 1.0 and avoids mutating input Detections in tracking updates. |
| src/supervision/metrics/utils/matching.py | Adds helper returning both match correctness and matched target indices to support bucket scoring. |
| src/supervision/metrics/recall.py | Reworks size-bucket recall computation to match globally before bucket scoring; adds MASKS validation. |
| src/supervision/metrics/precision.py | Reworks size-bucket precision computation similarly; adds MASKS validation. |
| src/supervision/metrics/f1_score.py | Reworks size-bucket F1 computation similarly; adds MASKS validation. |
| src/supervision/metrics/mean_average_recall.py | Reworks size-bucket mAR computation similarly; adds MASKS validation. |
| src/supervision/dataset/formats/yolo.py | Removes strict image-mode check to allow non-RGB modes when only dimensions are required. |
| src/supervision/dataset/formats/coco.py | Defaults missing iscrowd/area during load; exports mask area as pixel count when mask present. |
| src/supervision/dataset/core.py | Copies annotations defensively, validates class_id dtype/range, adds use_iscrowd, and hardens folder-structure import. |
| src/supervision/classification/core.py | Adds numpy-safe Classifications.__eq__ and softmaxes timm outputs. |
| src/supervision/assets/downloader.py | Adds MD5 verification, retry-on-mismatch behavior, and clearer failure on repeated MD5 mismatch. |
| pyproject.toml | Sets pytest testpaths for more reliable discovery. |
| docs/changelog.md | Documents the user-visible fixes and behavior changes in the unreleased changelog. |
This was referenced Jul 7, 2026
- Reinstated NumPy-safe `Classifications` equality and ordered class-list comparisons in dataset equality. - Restored greedy matching plus size-bucket scoring for Precision, Recall, F1, and MeanAverageRecall, with regression coverage for the medium-object boundary case. --- Co-authored-by: Codex <codex@openai.com>
- Filter size-bucket precision, recall, and F1 against target boxes so predictions no longer claim the bucket. - Preserve confidence order for bucketed mAR@K scoring and return zero when a bucket has no support. - Add regression coverage for bucket matching, empty-support mAR, top-K limits, and missing-mask errors. --- Co-authored-by: Codex <codex@openai.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces several important improvements and bug fixes across dataset handling, metrics computation, and asset management. Key changes include safer handling of user-supplied data to prevent mutation, enhanced error reporting, improved dataset import/export compatibility, and more robust metric calculations. Additionally, asset downloads now include MD5 verification and retry logic, and several utilities have been made more tolerant to data variations.
Dataset handling improvements:
DetectionDatasetno longer mutates caller-suppliedDetectionswhen addingdata["class_name"], and now raises a clearValueErrorwith the image path if annotationclass_idvalues are out of range. [1]], [2]])iscrowdandareafields, exposes ause_iscrowdparameter, and mask export writes mask pixel area instead of bbox area. [1]], [2]], [3]], [4]], [5]], [6]])ClassificationDataset.from_folder_structurenow skips root-level files and dot entries, and only includes valid class directories and image files. [1]], [2]], [3]])Metrics computation fixes:
F1Score,Precision,Recall, andMeanAverageRecallnow compute size-bucket metrics by matching on the full detection set before target-bucket scoring, preventing boundary-size matches from being counted as both false positives and false negatives. MASKS metrics now raise a descriptive error if detections lack masks. [1]], [2]], [3]], [4]], [5]], [6]])Asset download reliability:
Classification utilities:
Classificationsequality now compares NumPy-backed fields by value, andClassifications.from_timmreturns softmax probabilities instead of raw logits. [1]], [2]], [3]])Testing configuration:
These changes collectively enhance data integrity, error handling, and compatibility with common dataset formats, while improving reliability and transparency in both metrics and asset management.