Skip to content

Commit 5cdb714

Browse files
committed
Fix fuse creation
1 parent ed537d5 commit 5cdb714

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

superannotate/db/images.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,11 @@ def download_image(
621621
:return: paths of downloaded image and annotations if included
622622
:rtype: tuple
623623
"""
624+
if (include_fuse or include_overlay) and not include_annotations:
625+
raise SABaseException(
626+
0,
627+
"To download fuse or overlay image need to set include_annotations=True in download_image"
628+
)
624629
if not Path(local_dir_path).is_dir():
625630
raise SABaseException(
626631
0, f"local_dir_path {local_dir_path} is not an existing directory"
@@ -818,7 +823,7 @@ def _get_image_pre_or_annotations(project, image_name, pre):
818823
fill_class_and_attribute_names(res_json, annotation_classes_dict)
819824
result = {
820825
f"{pre}annotation_json":
821-
response.json(),
826+
res_json,
822827
f"{pre}annotation_json_filename":
823828
common.get_annotation_json_name(image_name, project_type)
824829
}
@@ -1041,12 +1046,11 @@ def create_fuse_image(
10411046
(image_size[1], image_size[0], 4), [0, 0, 0, 255], np.uint8
10421047
)
10431048
fi_ovl[:, :, :3] = np.array(pil_image)
1049+
fi_pil_ovl = Image.fromarray(fi_ovl)
1050+
draw_ovl = ImageDraw.Draw(fi_pil_ovl)
10441051
if project_type == "Vector":
10451052
fi_pil = Image.fromarray(fi)
10461053
draw = ImageDraw.Draw(fi_pil)
1047-
if output_overlay:
1048-
fi_pil_ovl = Image.fromarray(fi_ovl)
1049-
draw_ovl = ImageDraw.Draw(fi_pil_ovl)
10501054
for annotation in annotation_json["instances"]:
10511055
if "className" not in annotation:
10521056
continue
@@ -1159,6 +1163,11 @@ def create_fuse_image(
11591163
temp_mask = np.alltrue(annotation_mask == part_color, axis=2)
11601164
fi[temp_mask] = fill_color
11611165
fi_pil = Image.fromarray(fi)
1166+
alpha = 0.5 # transparency measure
1167+
if output_overlay:
1168+
fi_pil_ovl = Image.fromarray(
1169+
cv2.addWeighted(fi, alpha, fi_ovl, 1 - alpha, 0)
1170+
)
11621171

11631172
if in_memory:
11641173
if output_overlay:

superannotate/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "4.1.1b1"
1+
__version__ = "4.1.1b2"

0 commit comments

Comments
 (0)