-
Notifications
You must be signed in to change notification settings - Fork 512
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: coco category ids can now be not sequential - avoiding memory leak #4309
fix: coco category ids can now be not sequential - avoiding memory leak #4309
Conversation
Important Auto Review SkippedAuto reviews are disabled on base/target branches other than the default branch. Please add the base/target branch pattern to the list of additional branches to be reviewed in the settings. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughThe update in the Changes
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@patrontheo thanks for taking this on! I'll defer to @swheaton for functional review.
With respect to your comment about add_coco_labels()
, perhaps you could update so that its classes
argument can be either a list (current) or a dict (new format)?
…f classes or a dict mapping ids to labels
Yes, good idea, I did that. For the Exporter, I haven't tried yet to use existing IDs as you suggested (in #4293), but I'll see if I get a bit of time to look at it. |
@swheaton any input ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, I'll handle my suggestion to retain class mappings when exporting in a follow-up commit 👍
@patrontheo sorry been very busy, prepping to go on leave. Thank you for the contribution!! |
Closes #4293.
What changes are proposed in this pull request?
parse_coco_categories
returnsclasses_map
instead ofclasses
. It is a dict mapping class IDs to class labels. In areas where the list of classes are needed, it it obtained throughlist(classes_map.values())
.The caveat I see here is that the public facing
add_coco_labels
function takes classes as an argument (the list of class labels). To avoid changing the public interface, I did not modify that and builtclasses_map
usingclasses_map = {i: label for i, label in enumerate(classes)}
. This should work but requires that inlabels_or_path
files, the category IDs are sequential (starting from zero). This was already the case before this change.If we want to allow non-sequential category IDs here also, we need to change the public interface and require
classes_map
instead ofclasses
. Or do you see another solution ? Should we change the public interface or leave it like that ?How is this patch tested? If it is not, please explain why.
Not thoroughly. I am opening a draft PR to run the tests, as explained in Contributing.
Release Notes
Is this a user-facing change that should be mentioned in the release notes?
notes for FiftyOne users.
(Details in 1-2 sentences. You can just refer to another PR with a description
if this PR is part of a larger change.)
What areas of FiftyOne does this PR affect?
fiftyone
Python library changesSummary by CodeRabbit