-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Match image by name (instead of id) on CVAT upload #1807
Conversation
Pull Request Test Coverage Report for Build 6493
💛 - Coveralls |
@@ -432,7 +432,7 @@ def load(file_object, annotations): | |||
) | |||
elif el.tag == 'image': | |||
image_is_opened = True | |||
frame_id = int(el.attrib['id']) | |||
frame_id = annotations.match_frame(el.attrib['name']) |
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.
I think you should use https://github.com/opencv/cvat/blob/develop/cvat/apps/dataset_manager/bindings.py#L571 here, which will fall back to ids and other things in the case image name did not match. This can happen, for example, in the case when the task was created from files on a shared storage, as image names in the task will include their absolute paths, in which case the new variant doesn't work. This problem would require analysis of the whole input file, but ids can simplify things.
Another simple variant - use the name, otherwise use the id and check if basenames match, if there is one provided.
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.
Indeed, I thought match_frame already matched on the basename and not the full path but not sure, and I didn't follow the updates of the importer.
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.
You can find an example of a DataseItem
for these purposes here: https://github.com/opencv/cvat/blob/develop/cvat/apps/dataset_manager/formats/yolo.py#L40
I think, the approach in the last line above will just fit.
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.
Hi, any updates?
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.
Done
@artemisart , thanks for the great contribution. I personally want to accept it. The only problem that it is necessary to fix a component from @zhiltsov-max. Are you going to do that? |
Yes, sorry I didn't have the time to update and test yet but it should be good now. |
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.
@artemisart , Thanks for the PR. Great contribution!
Motivation and context
Currently, the cvat annotation import (upload) matches annotations to frames by id, so this works only on very specific cases like backups for the same task. When moving annotations between tasks, if the order doesn't match exactly or if there are more frames, or (in our case) if we generate cvat annotations for pre-annotation, nothing matched and it's useless.
This PR just uses the same matching as for coco files, so it works both for old use-cases like backup (if the ID matched, then the filenames will match) but also pre-annotation and others.
How has this been tested?
Manually, uploaded some files.
Checklist
develop
branchcvat-core, cvat-data and cvat-ui)
License
Feel free to contact the maintainers if that's a concern.