fix: slice numpy array values in custom_data per row in CSVSink and J…#2199
Open
farukalamai wants to merge 1 commit intoroboflow:developfrom
Open
fix: slice numpy array values in custom_data per row in CSVSink and J…#2199farukalamai wants to merge 1 commit intoroboflow:developfrom
farukalamai wants to merge 1 commit intoroboflow:developfrom
Conversation
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.
Before submitting
Description
Fixes a bug in
CSVSinkandJSONSinkwhere passing a numpy array as acustom_datavalue wrote the entire array on every row instead of theper-detection scalar value.
Type of Change
Motivation and Context
When users pass computed per-detection values like
detections.areaviacustom_data, each row should receive its own scalar — not the whole array.The root cause was
row.update(custom_data)inside the per-detection loop,which blindly wrote the whole value. The fix applies the same per-index
slicing logic that
detections.dataalready uses correctly.Closes #1397
Changes Made
src/supervision/detection/tools/csv_sink.py— slice numpy array values incustom_dataper detection rowsrc/supervision/detection/tools/json_sink.py— same fixtests/detection/test_csv.py— added test case for numpy array incustom_dataTesting
Google Colab (optional)
Colab link:
Screenshots/Videos (optional)
Additional Notes
The fix is backward compatible — scalar values in
custom_data(e.g.{"frame_number": 42}) continue to work as before, written as-is on everyrow.