@@ -173,13 +173,17 @@ def video_label_generator(self, timeout_seconds=60):
173
173
Returns:
174
174
LabelGenerator for accessing labels for each video
175
175
"""
176
+ _check_converter_import ()
176
177
json_data = self .export_labels (download = True ,
177
178
timeout_seconds = timeout_seconds )
178
- if 'frames' not in json_data [0 ]['Label' ]:
179
+ is_video = [
180
+ 'frames' in row ['Label' ] for row in json_data if row ['Label' ]
181
+ ]
182
+ if len (is_video ) and not all (is_video ):
179
183
raise ValueError (
180
- "frames key not found in the first label. Cannot export video data. "
181
- )
182
- _check_converter_import ( )
184
+ "Found non-video data rows in export. "
185
+ "Use project.export_labels() to export projects with mixed data types. "
186
+ "Or use project.label_generator() for text and imagery data." )
183
187
return LBV1Converter .deserialize_video (json_data , self .client )
184
188
185
189
def label_generator (self , timeout_seconds = 60 ):
@@ -189,9 +193,17 @@ def label_generator(self, timeout_seconds=60):
189
193
Returns:
190
194
LabelGenerator for accessing labels for each text or image
191
195
"""
196
+ _check_converter_import ()
192
197
json_data = self .export_labels (download = True ,
193
198
timeout_seconds = timeout_seconds )
194
- _check_converter_import ()
199
+ is_video = [
200
+ 'frames' in row ['Label' ] for row in json_data if row ['Label' ]
201
+ ]
202
+ if len (is_video ) and not any (is_video ):
203
+ raise ValueError (
204
+ "Found video data rows in export. "
205
+ "Use project.export_labels() to export projects with mixed data types. "
206
+ "Or use project.video_label_generator() for video data." )
195
207
return LBV1Converter .deserialize (json_data )
196
208
197
209
def export_labels (self , download = False , timeout_seconds = 60 ):
0 commit comments