Add "category" as required var in detections and annotations ds#124
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #124 +/- ##
==========================================
- Coverage 99.46% 99.45% -0.01%
==========================================
Files 8 8
Lines 558 555 -3
==========================================
- Hits 555 552 -3
Misses 3 3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
7 tasks
…is not defined in map_category_to_str
…taset when computing 'raw' dataframe (in pivoting step)
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.
Description
What is this PR
Why is this PR needed?
At the moment, it is possible to pass to the "export to COCO" function an annotations dataset that does not have a "category" data array. The function will fill in a dummy value (category ID = -1 and category = '') before exporting. However, the resulting JSON file will not pass the corresponding jsonschema validation and I get the error:
This is because the categories section in the JSON is exported as:
Although this is somewhat documented at the moment, it is confusing and not very useful. It is also odd that the category name if not defined is mapped to NaN and the supercategory is mapped to "".
For reference, note that the COCO standard does specify a
category_idfor each annotation.What does this PR do?
save_bboxes.to_COCOwe get a clear error message.Two additions that are not exactly related to the original issue but relevant when creating the intermediate dataframe to export a dataset to COCO format:
This PR also adds
uv.lockto .gitignore.References
The issue came up when simulating a proof-reading scenario: a detections dataset with a "label" data array (rather than a "category" data array and following work in PR #114) can be passed to
save_bboxes.to_COCObut the output JSON file was violating the COCO file schema.A quick fix is to rename the data array in the input dataset from "label" to "category", but it seems more consistent to include a required "category" data array in the definition of a bbox dataset if that is the underlying meaning.
How has this PR been tested?
Tests pass locally and in CI
Is this a breaking change?
No.
Does this PR require an update to the documentation?
Yes, the docstrings have been updated as part of this PR.
Checklist: