Don't export outside frames in frame-based formats (#2345)

* Exclude outside shapes from per frame export

* update changelog
main
Maxim Zhiltsov 5 years ago committed by GitHub
parent c84948f7ee
commit e0afbaf507
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -64,6 +64,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fixed CVAT startup process if the user has `umask 077` in .bashrc file (<https://github.com/openvinotoolkit/cvat/pull/2293>)
- Exception: Cannot read property "each" of undefined after drawing a single point (<https://github.com/openvinotoolkit/cvat/pull/2307>)
- Cannot read property 'label' of undefined (Fixed?) (<https://github.com/openvinotoolkit/cvat/pull/2311>)
- Excluded track frames marked `outside` in `CVAT for Images` export (<https://github.com/openvinotoolkit/cvat/pull/2345>)
### Security

@ -268,6 +268,8 @@ class TaskData:
for shape in sorted(anno_manager.to_shapes(self._db_task.data.size),
key=lambda shape: shape.get("z_order", 0)):
if 'track_id' in shape:
if shape['outside']:
continue
exported_shape = self._export_tracked_shape(shape)
else:
exported_shape = self._export_labeled_shape(shape)
@ -449,10 +451,9 @@ class TaskData:
return None
class CvatTaskDataExtractor(datumaro.SourceExtractor):
def __init__(self, task_data, include_images=False, include_outside=False):
def __init__(self, task_data, include_images=False):
super().__init__()
self._categories = self._load_categories(task_data)
self._include_outside = include_outside
dm_items = []
@ -568,9 +569,6 @@ class CvatTaskDataExtractor(datumaro.SourceExtractor):
anno_attr['track_id'] = shape_obj.track_id
anno_attr['keyframe'] = shape_obj.keyframe
if not self._include_outside and shape_obj.outside:
continue
anno_points = shape_obj.points
if shape_obj.type == ShapeType.POINTS:
anno = datumaro.Points(anno_points,

@ -363,13 +363,24 @@ class TaskExportTest(_DbTestBase):
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)
extractor = CvatTaskDataExtractor(task_data)
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)
dm_dataset = datumaro.components.project.Dataset.from_extractors(extractor)
self.assertEqual(5, len(dm_dataset.get("image_1").annotations))
def test_no_outside_shapes_in_per_frame_export(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"]))
outside_count = 0
for f in task_data.group_by_frame(include_empty=True):
for ann in f.labeled_shapes:
if getattr(ann, 'outside', None):
outside_count += 1
self.assertEqual(0, outside_count)
def test_cant_make_rel_frame_id_from_unknown(self):
images = self._generate_task_images(3)

Loading…
Cancel
Save