@@ -221,41 +221,14 @@ def export_queued_data_rows(self,
221
221
self .uid )
222
222
time .sleep (sleep_time )
223
223
224
- def video_label_generator (self , timeout_seconds = 600 , ** kwargs ):
225
- """
226
- Download video annotations
227
-
228
- Returns:
229
- LabelGenerator for accessing labels for each video
230
- """
231
- _check_converter_import ()
232
- json_data = self .export_labels (download = True ,
233
- timeout_seconds = timeout_seconds ,
234
- ** kwargs )
235
- # assert that the instance this would fail is only if timeout runs out
236
- assert isinstance (
237
- json_data ,
238
- List ), "Unable to successfully get labels. Please try again"
239
- if json_data is None :
240
- raise TimeoutError (
241
- f"Unable to download labels in { timeout_seconds } seconds."
242
- "Please try again or contact support if the issue persists." )
243
- is_video = [
244
- 'frames' in row ['Label' ] for row in json_data if row ['Label' ]
245
- ]
246
- if len (is_video ) and not all (is_video ):
247
- raise ValueError (
248
- "Found non-video data rows in export. "
249
- "Use project.export_labels() to export projects with mixed data types. "
250
- "Or use project.label_generator() for text and imagery data." )
251
- return LBV1Converter .deserialize_video (json_data , self .client )
252
-
253
224
def label_generator (self , timeout_seconds = 600 , ** kwargs ):
254
225
"""
255
- Download text and image annotations
226
+ Download text and image annotations, or video annotations.
227
+
228
+ For a mixture of text/image and video, use project.export_labels()
256
229
257
230
Returns:
258
- LabelGenerator for accessing labels for each text or image
231
+ LabelGenerator for accessing labels
259
232
"""
260
233
_check_converter_import ()
261
234
json_data = self .export_labels (download = True ,
@@ -272,11 +245,14 @@ def label_generator(self, timeout_seconds=600, **kwargs):
272
245
is_video = [
273
246
'frames' in row ['Label' ] for row in json_data if row ['Label' ]
274
247
]
275
- if len (is_video ) and any (is_video ):
248
+
249
+ if len (is_video ) and not all (is_video ) and any (is_video ):
276
250
raise ValueError (
277
- "Found video data rows in export . "
251
+ "Found mixed data types of video and text/image . "
278
252
"Use project.export_labels() to export projects with mixed data types. "
279
- "Or use project.video_label_generator() for video data." )
253
+ )
254
+ if len (is_video ) and all (is_video ):
255
+ return LBV1Converter .deserialize_video (json_data , self .client )
280
256
return LBV1Converter .deserialize (json_data )
281
257
282
258
def export_labels (self ,
0 commit comments