Skip to content

Commit fc2f2ed

Browse files
committed
Filter skipped labels for project with videos in label_generator()
1 parent ebdb097 commit fc2f2ed

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

labelbox/schema/project.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,16 +266,21 @@ def label_generator(self, timeout_seconds=600, **kwargs):
266266
json_data = self.export_labels(download=True,
267267
timeout_seconds=timeout_seconds,
268268
**kwargs)
269+
269270
# assert that the instance this would fail is only if timeout runs out
270271
assert isinstance(
271272
json_data,
272273
List), "Unable to successfully get labels. Please try again"
274+
273275
if json_data is None:
274276
raise TimeoutError(
275277
f"Unable to download labels in {timeout_seconds} seconds."
276278
"Please try again or contact support if the issue persists.")
279+
277280
is_video = [
278-
'frames' in row['Label'] for row in json_data if row['Label']
281+
"frames" in row["Label"]
282+
for row in json_data
283+
if row["Label"] and not row["Skipped"]
279284
]
280285

281286
if len(is_video) and not all(is_video) and any(is_video):
@@ -284,7 +289,14 @@ def label_generator(self, timeout_seconds=600, **kwargs):
284289
"Use project.export_labels() to export projects with mixed data types. "
285290
)
286291
if len(is_video) and all(is_video):
292+
# Filter skipped labels to avoid inference errors
293+
json_data = [
294+
label for label in self.export_labels(download=True)
295+
if not label["Skipped"]
296+
]
297+
287298
return LBV1Converter.deserialize_video(json_data, self.client)
299+
288300
return LBV1Converter.deserialize(json_data)
289301

290302
def export_labels(self,

0 commit comments

Comments
 (0)