@@ -141,10 +141,7 @@ def get_image_metadata(project, image_name):
141141 for image in images :
142142 if image ["name" ] == image_name :
143143 return image
144- raise SABaseException (
145- 0 , "Image " + image_name + " doesn't exist in the project " +
146- project ["name" ]
147- )
144+ raise SABaseException (0 , "Image " + image_name + " doesn't exist." )
148145
149146
150147def set_image_annotation_status (project , image_name , annotation_status ):
@@ -499,28 +496,31 @@ def download_image(
499496 if not isinstance (project , dict ):
500497 project = get_project_metadata_bare (project )
501498 img = get_image_bytes (project , image_name , variant = variant )
499+ filepath_save = image_name
502500 if variant == "lores" :
503- image_name += "___lores.jpg"
504- filepath = Path (local_dir_path ) / image_name
505- with open (filepath , 'wb' ) as f :
501+ filepath_save += "___lores.jpg"
502+ filepath_save = Path (local_dir_path ) / filepath_save
503+ with open (filepath_save , 'wb' ) as f :
506504 f .write (img .getbuffer ())
507505 annotations_filepaths = None
508506 fuse_path = None
509507 if include_annotations :
510508 annotations_filepaths = download_image_annotations (
511509 project , image_name , local_dir_path
512510 )
513- if include_fuse or include_overlay :
511+ if annotations_filepaths is not None and (
512+ include_fuse or include_overlay
513+ ):
514514 classes = search_annotation_classes (project )
515515 fuse_path = create_fuse_image (
516- filepath ,
516+ filepath_save ,
517517 classes ,
518518 project ["type" ],
519519 output_overlay = include_overlay
520520 )
521- logger .info ("Downloaded image %s to %s." , image_name , filepath )
521+ logger .info ("Downloaded image %s to %s." , image_name , filepath_save )
522522
523- return (str (filepath ), annotations_filepaths , fuse_path )
523+ return (str (filepath_save ), annotations_filepaths , fuse_path )
524524
525525
526526def delete_image (project , image_name ):
@@ -789,7 +789,7 @@ def download_image_annotations(project, image_name, local_dir_path):
789789
790790 if annotation ["annotation_json_filename" ] is None :
791791 image = get_image_metadata (project , image_name )
792- logger .info ("No annotation found for image %s." , image ["name" ])
792+ logger .warning ("No annotation found for image %s." , image ["name" ])
793793 return None
794794 return_filepaths = []
795795 json_path = Path (local_dir_path ) / annotation ["annotation_json_filename" ]
0 commit comments