Skip to content

Commit 4f08ff7

Browse files
authored
[AL-5264] Add interpolated frames (#1077)
1 parent 3b5e5ad commit 4f08ff7

File tree

8 files changed

+52
-10
lines changed

8 files changed

+52
-10
lines changed

labelbox/schema/data_row.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ def export_v2(client: 'Client',
188188
"media_type_override": None,
189189
"model_run_ids": None,
190190
"project_ids": None,
191+
"interpolated_frames": False,
191192
})
192193

193194
validate_catalog_export_params(_params)
@@ -235,6 +236,8 @@ def export_v2(client: 'Client',
235236
_params.get('performance_details', False),
236237
"includeLabelDetails":
237238
_params.get('label_details', False),
239+
"includeInterpolatedFrames":
240+
_params.get('interpolated_frames', False),
238241
"projectIds":
239242
_params.get('project_ids', None),
240243
"modelRunIds":

labelbox/schema/dataset.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,7 @@ def export_v2(self,
569569
"media_type_override": None,
570570
"model_run_ids": None,
571571
"project_ids": None,
572+
"interpolated_frames": False,
572573
})
573574
validate_catalog_export_params(_params)
574575

@@ -612,6 +613,8 @@ def export_v2(self,
612613
_params.get('performance_details', False),
613614
"includeLabelDetails":
614615
_params.get('label_details', False),
616+
"includeInterpolatedFrames":
617+
_params.get('interpolated_frames', False),
615618
"projectIds":
616619
_params.get('project_ids', None),
617620
"modelRunIds":

labelbox/schema/export_params.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ class ProjectExportParams(DataRowParams):
2222
project_details: Optional[bool]
2323
label_details: Optional[bool]
2424
performance_details: Optional[bool]
25+
interpolated_frames: Optional[bool]
2526

2627

2728
class CatalogExportParams(DataRowParams):
@@ -30,6 +31,7 @@ class CatalogExportParams(DataRowParams):
3031
performance_details: Optional[bool]
3132
model_run_ids: Optional[List[str]]
3233
project_ids: Optional[List[str]]
34+
interpolated_frames: Optional[bool]
3335

3436

3537
class ModelRunExportParams(DataRowParams):

labelbox/schema/project.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,8 @@ def export_v2(self,
434434
"project_details": False,
435435
"performance_details": False,
436436
"label_details": False,
437-
"media_type_override": None
437+
"media_type_override": None,
438+
"interpolated_frames": False,
438439
})
439440

440441
_filters = filters or ProjectExportFilters({
@@ -474,7 +475,9 @@ def export_v2(self,
474475
"includePerformanceDetails":
475476
_params.get('performance_details', False),
476477
"includeLabelDetails":
477-
_params.get('label_details', False)
478+
_params.get('label_details', False),
479+
"includeInterpolatedFrames":
480+
_params.get('interpolated_frames', False),
478481
},
479482
}
480483
}

labelbox/schema/slice.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ def export_v2(self,
8787
"media_type_override": None,
8888
"model_run_ids": None,
8989
"project_ids": None,
90+
"interpolated_frames": False,
9091
})
9192
validate_catalog_export_params(_params)
9293

@@ -118,6 +119,8 @@ def export_v2(self,
118119
_params.get('performance_details', False),
119120
"includeLabelDetails":
120121
_params.get('label_details', False),
122+
"includeInterpolatedFrames":
123+
_params.get('interpolated_frames', False),
121124
"projectIds":
122125
_params.get('project_ids', None),
123126
"modelRunIds":

tests/integration/annotation_import/fixtures/annotations.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ def bbox_video_annotation_objects():
4141
frame=19,
4242
segment_index=0,
4343
value=Rectangle(
44-
start=Point(x=146.0, y=98.0), # Top left
45-
end=Point(x=382.0, y=341.0), # Bottom right
44+
start=Point(x=186.0, y=98.0), # Top left
45+
end=Point(x=490.0, y=341.0), # Bottom right
4646
))
4747
]
4848

tests/integration/annotation_import/fixtures/video_annotations.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ def bbox_video_annotation_objects():
4141
frame=19,
4242
segment_index=0,
4343
value=Rectangle(
44-
start=Point(x=146.0, y=98.0), # Top left
45-
end=Point(x=382.0, y=341.0), # Bottom right
44+
start=Point(x=186.0, y=98.0), # Top left
45+
end=Point(x=490.0, y=341.0), # Bottom right
4646
))
4747
]
4848

tests/integration/annotation_import/test_export_v2_classifications.py renamed to tests/integration/annotation_import/test_export_v2_video.py

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,12 @@ def test_export_v2_video(client, configured_project_without_data_rows,
3535
num_retries = 5
3636
task = None
3737
while (num_retries > 0):
38-
task = project.export_v2(params={
39-
"performance_details": False,
40-
"label_details": True
41-
})
38+
task = project.export_v2(
39+
params={
40+
"performance_details": False,
41+
"label_details": True,
42+
"interpolated_frames": True
43+
})
4244
task.wait_till_done()
4345
assert task.status == "COMPLETE"
4446
assert task.errors is None
@@ -168,6 +170,32 @@ def test_export_v2_video(client, configured_project_without_data_rows,
168170
all_frames_exported.append(value)
169171
assert (len(all_frames_exported) == 0)
170172

173+
# BEGINNING OF THE VIDEO INTERPOLATION ASSERTIONS
174+
first_frame_id = bbox_video_annotation_objects[0].frame
175+
last_frame_id = bbox_video_annotation_objects[-1].frame
176+
177+
# Generate list of frames with frames in between, e.g. 13, 14, 15, 16, 17, 18, 19
178+
expected_frame_ids = list(range(first_frame_id, last_frame_id + 1))
179+
180+
assert export_frames_ids == expected_frame_ids
181+
182+
exported_objects_dict = export_frames[str(first_frame_id)]['objects']
183+
184+
# Get the label ID
185+
first_exported_label_id = list(exported_objects_dict.keys())[0]
186+
187+
# Since the bounding box moves to the right, the interpolated frame content should start a little bit more far to the right
188+
assert export_frames[str(first_frame_id + 1)]['objects'][
189+
first_exported_label_id]['bounding_box']['left'] > export_frames[
190+
str(first_frame_id
191+
)]['objects'][first_exported_label_id]['bounding_box']['left']
192+
# But it shouldn't be further than the last frame
193+
assert export_frames[str(first_frame_id + 1)]['objects'][
194+
first_exported_label_id]['bounding_box']['left'] < export_frames[
195+
str(last_frame_id
196+
)]['objects'][first_exported_label_id]['bounding_box']['left']
197+
# END OF THE VIDEO INTERPOLATION ASSERTIONS
198+
171199
frame_with_nested_classifications = export_frames['13']
172200
annotation = None
173201
for _, a in frame_with_nested_classifications['objects'].items():

0 commit comments

Comments
 (0)