@@ -1082,18 +1082,22 @@ def __get_yolo_format_annotations(self, dataset_folder_path: str) -> dict:
10821082
10831083 # Task Convert
10841084
1085- def export_coco (self , tasks : list , annotations : list = [], output_dir : str = os .path .join ("output" , "coco" )) -> None :
1085+ def export_coco (self , tasks : list , annotations : list = [], output_dir : str = os .path .join ("output" , "coco" ), output_file_name : str = "annotations.json" ) -> None :
10861086 """
10871087 Convert tasks to COCO format and export as a file.
10881088 If you pass annotations, you can export Pose Estimation type annotations.
10891089
10901090 tasks is a list of tasks. (Required)
10911091 annotations is a list of annotations. (Optional)
10921092 output_dir is output directory(default: output/coco). (Optional)
1093+ output_file_name is output file name(default: annotations.json). (Optional)
10931094 """
1095+ if not utils .is_json_ext (output_file_name ):
1096+ raise FastLabelInvalidException (
1097+ "Output file name must have a json extension" , 422 )
10941098 coco = converters .to_coco (tasks , annotations )
10951099 os .makedirs (output_dir , exist_ok = True )
1096- file_path = os .path .join (output_dir , "annotations.json" )
1100+ file_path = os .path .join (output_dir , output_file_name )
10971101 with open (file_path , 'w' ) as f :
10981102 json .dump (coco , f , indent = 4 , ensure_ascii = False )
10991103
0 commit comments