@@ -471,6 +471,7 @@ def download_image(
471471 local_dir_path = "." ,
472472 include_annotations = False ,
473473 include_fuse = False ,
474+ include_overlay = False ,
474475 variant = 'original'
475476):
476477 """Downloads the image (and annotation if not None) to local_dir_path
@@ -515,10 +516,12 @@ def download_image(
515516 annotations_filepaths = download_image_annotations (
516517 project , image_name , local_dir_path
517518 )
518- if include_fuse :
519+ if include_fuse or include_overlay :
519520 classes = search_annotation_classes (project , return_metadata = True )
520521 project_type = project_type_int_to_str (project ["type" ])
521- fuse_path = create_fuse_image (filepath , classes , project_type )
522+ fuse_path = create_fuse_image (
523+ filepath , classes , project_type , output_overlay = include_overlay
524+ )
522525 logger .info ("Downloaded image %s to %s." , image_name , filepath )
523526
524527 return (str (filepath ), annotations_filepaths , fuse_path )
@@ -1034,7 +1037,6 @@ def create_fuse_image(
10341037 )
10351038 new_array_ovl = np .array (fi_pil_ovl )
10361039 new_array_ovl [:, :, :- 1 ] += temp_ovl
1037- new_array_ovl [:, :, 3 ] += temp_mask
10381040 fi_pil_ovl = Image .fromarray (new_array_ovl )
10391041 draw_ovl = ImageDraw .Draw (fi_pil_ovl )
10401042 cv2 .ellipse (
@@ -1105,7 +1107,7 @@ def create_fuse_image(
11051107 fi_pil .save (fuse_path )
11061108 if output_overlay :
11071109 overlay_path = str (image ) + "___overlay.jpg"
1108- fi_pil_ovl .save (overlay_path )
1110+ fi_pil_ovl .convert ( "RGB" ). save (overlay_path , subsampling = 0 , quality = 100 )
11091111 return (fuse_path , overlay_path )
11101112 else :
1111- return (fuse_path )
1113+ return (fuse_path , )
0 commit comments