From b182040ba8da125426b3fe9585602e97e31e8139 Mon Sep 17 00:00:00 2001 From: mnoszczak Date: Sun, 30 Apr 2023 11:05:02 +0400 Subject: [PATCH 1/4] Add interpolated frames --- labelbox/schema/data_row.py | 3 +++ labelbox/schema/dataset.py | 3 +++ labelbox/schema/export_params.py | 2 ++ labelbox/schema/project.py | 7 +++++-- labelbox/schema/slice.py | 3 +++ 5 files changed, 16 insertions(+), 2 deletions(-) diff --git a/labelbox/schema/data_row.py b/labelbox/schema/data_row.py index 240e53a03..d82727e0a 100644 --- a/labelbox/schema/data_row.py +++ b/labelbox/schema/data_row.py @@ -188,6 +188,7 @@ def export_v2(client: 'Client', "media_type_override": None, "model_run_ids": None, "project_ids": None, + "interpolated_frames": False, }) validate_catalog_export_params(_params) @@ -235,6 +236,8 @@ def export_v2(client: 'Client', _params.get('performance_details', False), "includeLabelDetails": _params.get('label_details', False), + "includeInterpolatedFrames": + _params.get('interpolated_frames', False), "projectIds": _params.get('project_ids', None), "modelRunIds": diff --git a/labelbox/schema/dataset.py b/labelbox/schema/dataset.py index 0e65b82bb..7a6df8b16 100644 --- a/labelbox/schema/dataset.py +++ b/labelbox/schema/dataset.py @@ -569,6 +569,7 @@ def export_v2(self, "media_type_override": None, "model_run_ids": None, "project_ids": None, + "interpolated_frames": False, }) validate_catalog_export_params(_params) @@ -612,6 +613,8 @@ def export_v2(self, _params.get('performance_details', False), "includeLabelDetails": _params.get('label_details', False), + "includeInterpolatedFrames": + _params.get('interpolated_frames', False), "projectIds": _params.get('project_ids', None), "modelRunIds": diff --git a/labelbox/schema/export_params.py b/labelbox/schema/export_params.py index 70ca8b319..275e3f2b3 100644 --- a/labelbox/schema/export_params.py +++ b/labelbox/schema/export_params.py @@ -22,6 +22,7 @@ class ProjectExportParams(DataRowParams): project_details: Optional[bool] label_details: Optional[bool] performance_details: Optional[bool] + interpolated_frames: Optional[bool] class CatalogExportParams(DataRowParams): @@ -30,6 +31,7 @@ class CatalogExportParams(DataRowParams): performance_details: Optional[bool] model_run_ids: Optional[List[str]] project_ids: Optional[List[str]] + interpolated_frames: Optional[bool] class ModelRunExportParams(DataRowParams): diff --git a/labelbox/schema/project.py b/labelbox/schema/project.py index 5fa560eb9..8b469d8a9 100644 --- a/labelbox/schema/project.py +++ b/labelbox/schema/project.py @@ -434,7 +434,8 @@ def export_v2(self, "project_details": False, "performance_details": False, "label_details": False, - "media_type_override": None + "media_type_override": None, + "interpolated_frames": False, }) _filters = filters or ProjectExportFilters({ @@ -474,7 +475,9 @@ def export_v2(self, "includePerformanceDetails": _params.get('performance_details', False), "includeLabelDetails": - _params.get('label_details', False) + _params.get('label_details', False), + "includeInterpolatedFrames": + _params.get('interpolated_frames', False), }, } } diff --git a/labelbox/schema/slice.py b/labelbox/schema/slice.py index 4a53c53d0..d9fc6bcba 100644 --- a/labelbox/schema/slice.py +++ b/labelbox/schema/slice.py @@ -87,6 +87,7 @@ def export_v2(self, "media_type_override": None, "model_run_ids": None, "project_ids": None, + "interpolated_frames": False, }) validate_catalog_export_params(_params) @@ -118,6 +119,8 @@ def export_v2(self, _params.get('performance_details', False), "includeLabelDetails": _params.get('label_details', False), + "includeInterpolatedFrames": + _params.get('interpolated_frames', False), "projectIds": _params.get('project_ids', None), "modelRunIds": From b2151ac23bb12d3e752fe695d7e02951ae71df0d Mon Sep 17 00:00:00 2001 From: mnoszczak Date: Thu, 11 May 2023 13:47:53 +0200 Subject: [PATCH 2/4] Update tests --- .../annotation_import/fixtures/annotations.py | 4 +-- .../test_export_v2_classifications.py | 36 ++++++++++++++++--- 2 files changed, 34 insertions(+), 6 deletions(-) diff --git a/tests/integration/annotation_import/fixtures/annotations.py b/tests/integration/annotation_import/fixtures/annotations.py index 8dc19f6a0..53c48c184 100644 --- a/tests/integration/annotation_import/fixtures/annotations.py +++ b/tests/integration/annotation_import/fixtures/annotations.py @@ -41,8 +41,8 @@ def bbox_video_annotation_objects(): frame=19, segment_index=0, value=Rectangle( - start=Point(x=146.0, y=98.0), # Top left - end=Point(x=382.0, y=341.0), # Bottom right + start=Point(x=186.0, y=98.0), # Top left + end=Point(x=490.0, y=341.0), # Bottom right )) ] diff --git a/tests/integration/annotation_import/test_export_v2_classifications.py b/tests/integration/annotation_import/test_export_v2_classifications.py index 2d4b4417c..863f4d31e 100644 --- a/tests/integration/annotation_import/test_export_v2_classifications.py +++ b/tests/integration/annotation_import/test_export_v2_classifications.py @@ -35,10 +35,12 @@ def test_export_v2_video(client, configured_project_without_data_rows, num_retries = 5 task = None while (num_retries > 0): - task = project.export_v2(params={ - "performance_details": False, - "label_details": True - }) + task = project.export_v2( + params={ + "performance_details": False, + "label_details": True, + "interpolated_frames": True + }) task.wait_till_done() assert task.status == "COMPLETE" assert task.errors is None @@ -168,6 +170,32 @@ def test_export_v2_video(client, configured_project_without_data_rows, all_frames_exported.append(value) assert (len(all_frames_exported) == 0) + # BEGINNING OF THE VIDEO INTERPOLATION ASSERTIONS + first_frame_id = bbox_video_annotation_objects[0].frame + last_frame_id = bbox_video_annotation_objects[-1].frame + + # Generate list of frames with frames in between, e.g. 13, 14, 15, 16, 17, 18, 19 + expected_frame_ids = list(range(first_frame_id, last_frame_id + 1)) + + assert export_frames_ids == expected_frame_ids + + exported_objects_dict = export_frames[str(first_frame_id)]['objects'] + + # Get the label ID + first_exported_label_id = list(exported_objects_dict.keys())[0] + + # Since the bounding box moves to the right, the interpolated frame content should start a little bit more far to the right + assert export_frames[str(first_frame_id + 1)]['objects'][ + first_exported_label_id]['bounding_box']['left'] > export_frames[ + str(first_frame_id + )]['objects'][first_exported_label_id]['bounding_box']['left'] + # But it shouldn't be further than the last frame + assert export_frames[str(first_frame_id + 1)]['objects'][ + first_exported_label_id]['bounding_box']['left'] < export_frames[ + str(last_frame_id + )]['objects'][first_exported_label_id]['bounding_box']['left'] + # END OF THE VIDEO INTERPOLATION ASSERTIONS + frame_with_nested_classifications = export_frames['13'] annotation = None for _, a in frame_with_nested_classifications['objects'].items(): From 6b065f7c2b76c62a86b2a1576e9cb941a57c3d01 Mon Sep 17 00:00:00 2001 From: mnoszczak Date: Thu, 11 May 2023 20:41:34 +0200 Subject: [PATCH 3/4] Rename file --- ...{test_export_v2_classifications.py => test_export_v2_video.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tests/integration/annotation_import/{test_export_v2_classifications.py => test_export_v2_video.py} (100%) diff --git a/tests/integration/annotation_import/test_export_v2_classifications.py b/tests/integration/annotation_import/test_export_v2_video.py similarity index 100% rename from tests/integration/annotation_import/test_export_v2_classifications.py rename to tests/integration/annotation_import/test_export_v2_video.py From bbfedbd06120990f28032b0cc37a553dd9f8660a Mon Sep 17 00:00:00 2001 From: mnoszczak Date: Fri, 12 May 2023 15:10:57 +0200 Subject: [PATCH 4/4] Update test data --- .../annotation_import/fixtures/video_annotations.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/integration/annotation_import/fixtures/video_annotations.py b/tests/integration/annotation_import/fixtures/video_annotations.py index 8dc19f6a0..53c48c184 100644 --- a/tests/integration/annotation_import/fixtures/video_annotations.py +++ b/tests/integration/annotation_import/fixtures/video_annotations.py @@ -41,8 +41,8 @@ def bbox_video_annotation_objects(): frame=19, segment_index=0, value=Rectangle( - start=Point(x=146.0, y=98.0), # Top left - end=Point(x=382.0, y=341.0), # Bottom right + start=Point(x=186.0, y=98.0), # Top left + end=Point(x=490.0, y=341.0), # Bottom right )) ]