fix: return empty int ndarray instead of None for class_id on empty VLM parse#2239
Open
YousefZahran1 wants to merge 1 commit intoroboflow:developfrom
Open
Conversation
… parse When from_paligemma or from_google_gemini_2_0 find no detections (no regex matches, JSON decode error, or empty bounding-box list), they previously returned None for class_id. All other early-exit and filter paths already return a zero-length ndarray of dtype int. This inconsistency causes downstream AttributeError when callers unconditionally call .shape or iterate over the result. Affected paths: - from_paligemma: matches.shape[0] == 0 branch - from_google_gemini_2_0: JSONDecodeError branch and len(xyxy) == 0 branch Closes roboflow#2219
Member
@YousefZahran1 could you pls sign ^^ 🦝 |
Codecov Report✅ All modified and coverable lines are covered by tests. ❌ Your project check has failed because the head coverage (78%) is below the target coverage (95%). You can increase the head coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## develop #2239 +/- ##
=======================================
Coverage 78% 78%
=======================================
Files 66 66
Lines 8347 8347
=======================================
Hits 6475 6475
Misses 1872 1872 🚀 New features to boost your workflow:
|
Author
|
"CLA signed! Ready for review when you have a moment. |
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.
What
On empty-parse paths in two VLM parsers,
class_idwas returned asNoneinstead of a zero-lengthndarrayof dtypeint, inconsistent with every other exit point in these functions and with the convention established byfrom_google_gemini_2_5,from_qwen_2_5_vl, andfrom_qwen_3_vl.Affected code paths
from_paligemmaNonenp.empty((0,), dtype=int)from_google_gemini_2_0JSONDecodeErrorNonenp.empty((0,), dtype=int)from_google_gemini_2_0Nonenp.empty((0,), dtype=int)Why it matters
Callers that do
class_id.shape,len(class_id), orclass_id[mask]immediately after parsing will get anAttributeError/TypeErrorwhenever zero detections are returned — a very common path in production (frame with nothing to detect). DownstreamDetections.from_vlm(...)pipelines hit this at runtime while unit tests may pass because they check happy paths.Changes
src/supervision/detection/vlm.py— 3 one-line fixes (no logic change)tests/detection/test_vlm.py— updated 10 test expectations to match the new contractAll 88 tests in
tests/detection/test_vlm.pypass.Fixes #2219