@@ -301,6 +301,8 @@ def __validate_and_format_frame_packet_map(
301
301
raise Exception ("frame_packet_map is not a dict" )
302
302
303
303
for frame , instance_list in frame_packet_map .items ():
304
+ if instance_list is None :
305
+ raise Exception ("instance_list cannot be None" )
304
306
305
307
if type (frame ) != int :
306
308
raise Exception ("frame is not a integer. The key should be the integer frame number." )
@@ -312,7 +314,8 @@ def __validate_and_format_frame_packet_map(
312
314
frame_packet_map [frame ] = self .__validate_and_format_instance_list (
313
315
instance_list = instance_list ,
314
316
assume_new_instances_machine_made = assume_new_instances_machine_made ,
315
- convert_names_to_label_files = convert_names_to_label_files
317
+ convert_names_to_label_files = convert_names_to_label_files ,
318
+ check_frame_number = True
316
319
)
317
320
318
321
return frame_packet_map
@@ -321,7 +324,8 @@ def __validate_and_format_instance_list(
321
324
self ,
322
325
instance_list : list ,
323
326
assume_new_instances_machine_made : bool ,
324
- convert_names_to_label_files : bool ):
327
+ convert_names_to_label_files : bool ,
328
+ check_frame_number : bool = False ):
325
329
326
330
FileConstructor .sanity_check_instance_list (instance_list )
327
331
@@ -334,6 +338,11 @@ def __validate_and_format_instance_list(
334
338
instance_list = instance_list
335
339
)
336
340
341
+ if check_frame_number :
342
+ for elm in instance_list :
343
+ if elm .get ('frame_number' ) is None :
344
+ raise Exception ('All instances must have a "frame_number" key.' )
345
+
337
346
return instance_list
338
347
339
348
def instance_list_label_strings_to_ids (self , instance_list : list ):
@@ -368,6 +377,10 @@ def sanity_check_instance_list(instance_list: list):
368
377
if len (instance_list ) == 0 :
369
378
raise Warning ("'instance_list' is empty" )
370
379
380
+ for elm in instance_list :
381
+ if elm is None :
382
+ raise Exception ("instance_list elements cannot be None" )
383
+
371
384
FileConstructor .__check_for_duplicates_on_instance_list (instance_list )
372
385
373
386
return
0 commit comments