@@ -173,13 +173,17 @@ def video_label_generator(self, timeout_seconds=60):
173173 Returns:
174174 LabelGenerator for accessing labels for each video
175175 """
176+ _check_converter_import ()
176177 json_data = self .export_labels (download = True ,
177178 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 ):
179183 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." )
183187 return LBV1Converter .deserialize_video (json_data , self .client )
184188
185189 def label_generator (self , timeout_seconds = 60 ):
@@ -189,9 +193,17 @@ def label_generator(self, timeout_seconds=60):
189193 Returns:
190194 LabelGenerator for accessing labels for each text or image
191195 """
196+ _check_converter_import ()
192197 json_data = self .export_labels (download = True ,
193198 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." )
195207 return LBV1Converter .deserialize (json_data )
196208
197209 def export_labels (self , download = False , timeout_seconds = 60 ):
0 commit comments