-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Don't export outside annotations #1729
Changes from all commits
d937154
1924217
990bfb4
7b4dc59
7862c40
abf96c7
13536ff
5498932
7176dfa
fb23e10
eb75ac2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -63,7 +63,7 @@ def _import(src_file, task_data): | |
points=ann.points, | ||
occluded=ann.attributes.get('occluded') == True, | ||
outside=False, | ||
keyframe=False, | ||
keyframe=True, | ||
z_order=ann.z_order, | ||
frame=frame_number, | ||
attributes=[], | ||
|
@@ -78,6 +78,11 @@ def _import(src_file, task_data): | |
for track in tracks.values(): | ||
# MOT annotations do not require frames to be ordered | ||
track.shapes.sort(key=lambda t: t.frame) | ||
# Set outside=True for the last shape in a track to finish the track | ||
track.shapes[-1] = track.shapes[-1]._replace(outside=True) | ||
# Append a shape with outside=True to finish the track | ||
last_shape = track.shapes[-1] | ||
if last_shape.frame + task_data.frame_step <= \ | ||
int(task_data.meta['task']['stop_frame']): | ||
track.shapes.append(last_shape._replace(outside=True, | ||
frame=last_shape.frame + task_data.frame_step) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure that here we need to add task_data.frame_step (probably +1 is correct). You can get a shape with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With +1 I'm not sure about how filtered out frames would be handled in UI, e.g. in "go to the next keyframe" button. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @zhiltsov-max , could you please check? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've checked. We can't just save the next frame (which is |
||
) | ||
task_data.add_track(track) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -77,7 +77,8 @@ def _setUpModule(): | |
_setUpModule() | ||
|
||
from cvat.apps.dataset_manager.annotation import AnnotationIR | ||
from cvat.apps.dataset_manager.bindings import TaskData | ||
from cvat.apps.dataset_manager.bindings import TaskData, CvatTaskDataExtractor | ||
from cvat.apps.dataset_manager.task import TaskAnnotation | ||
from cvat.apps.engine.models import Task | ||
|
||
|
||
|
@@ -406,6 +407,22 @@ def load_dataset(src): | |
self.assertEqual(len(dataset), task["size"]) | ||
self._test_export(check, task, format_name, save_images=False) | ||
|
||
def test_can_skip_outside(self): | ||
images = self._generate_task_images(3) | ||
task = self._generate_task(images) | ||
self._generate_annotations(task) | ||
task_ann = TaskAnnotation(task["id"]) | ||
task_ann.init_from_db() | ||
task_data = TaskData(task_ann.ir_data, Task.objects.get(pk=task["id"])) | ||
|
||
extractor = CvatTaskDataExtractor(task_data, include_outside=False) | ||
dm_dataset = datumaro.components.project.Dataset.from_extractors(extractor) | ||
self.assertEqual(4, len(dm_dataset.get("image_1").annotations)) | ||
|
||
extractor = CvatTaskDataExtractor(task_data, include_outside=True) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe we always should include_outside but different formats can use or ignore such shapes. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe, but there is no formats with such annotation property. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believed it too, so we've been there already. It means that all formats must expect (read as "support") such shapes. Much better is to filter them on the caller's side. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now "caller" knows about format implementation details (a format doesn't support "outside" flag). Is it OK? What is about attributes? Tracks? Cuboids? Are you going to filter that as? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think, only CVAT knows about There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK. I see that CvatTaskDataExtractor is used as an utility function by each format. Thus the knowledge encapsulated. |
||
dm_dataset = datumaro.components.project.Dataset.from_extractors(extractor) | ||
self.assertEqual(5, len(dm_dataset.get("image_1").annotations)) | ||
|
||
def test_cant_make_rel_frame_id_from_unknown(self): | ||
images = self._generate_task_images(3) | ||
images['frame_filter'] = 'step=2' | ||
|
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.
Why do we need the flag at all? When is it useful?