fix(detection): keep from_inference aligned on partial masks#2362
Open
kounelisagis wants to merge 1 commit into
Open
fix(detection): keep from_inference aligned on partial masks#2362kounelisagis wants to merge 1 commit into
kounelisagis wants to merge 1 commit into
Conversation
process_roboflow_result appended a mask only for predictions carrying one (RLE or polygon), while xyxy/confidence/class_id were appended for every prediction. A result mixing masked and box-only predictions (e.g. a segmentation batch where one polygon is empty) produced a mask array shorter than the boxes, so Detections.from_inference raised a shape-mismatch error. Append None for box-only predictions and build the mask array only when every prediction has a mask, otherwise drop masks to preserve alignment, mirroring the tracker_id handling. Fully-masked and mask-free results are unchanged.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #2362 +/- ##
=======================================
Coverage 82% 82%
=======================================
Files 68 68
Lines 9560 9564 +4
=======================================
+ Hits 7881 7885 +4
Misses 1679 1679 🚀 New features to boost your workflow:
|
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.
Bug
process_roboflow_resultappends a mask only for predictions that carry one (RLE or polygon), but appendsxyxy,confidenceandclass_idfor every prediction. A result that mixes masked and box-only predictions therefore ends up with a mask array shorter than the boxes, andDetections.from_inferenceraises:This shows up with segmentation results where one polygon is empty/degenerate and falls back to a box, so part of the batch has masks and part does not.
This is the same shape of issue as #2353 (partial
tracker_id), in the same function; the mask path was the remaining case.Fix
Append
Nonefor box-only predictions to keep the list aligned, and build the mask array only when every prediction has a mask, otherwise drop masks (with a warning) to preserve alignment withxyxy. Fully-masked and mask-free results are unchanged. Missing entries are detected by identity (mask is None) sinceNone in maskswould compare numpy arrays element-wise and raise.Tests
Added an end-to-end
from_inferencetest for a mixed masked/box-only batch, and updated the existingprocess_roboflow_resultcase that previously documented the misalignment as a known limitation.