Skip to content
This repository was archived by the owner on Aug 13, 2025. It is now read-only.

Commit 08a962c

Browse files
committed
1.2.1
1 parent 9de04e4 commit 08a962c

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

lama_cleaner/server.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,11 +138,20 @@ def save_image():
138138
filename = request.form["filename"]
139139
origin_image_bytes = input["image"].read() # RGB
140140
ext = get_image_ext(origin_image_bytes)
141-
image, _, exif_infos = load_img(origin_image_bytes, return_exif=True)
141+
image, alpha_channel, exif_infos = load_img(origin_image_bytes, return_exif=True)
142142
save_path = os.path.join(output_dir, filename)
143143

144+
if alpha_channel is not None:
145+
if alpha_channel.shape[:2] != image.shape[:2]:
146+
alpha_channel = cv2.resize(
147+
alpha_channel, dsize=(image.shape[1], image.shape[0])
148+
)
149+
image = np.concatenate((image, alpha_channel[:, :, np.newaxis]), axis=-1)
150+
151+
pil_image = Image.fromarray(image)
152+
144153
img_bytes = pil_to_bytes(
145-
Image.fromarray(image),
154+
pil_image,
146155
ext,
147156
quality=image_quality,
148157
exif_infos=exif_infos,

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def load_requirements():
2121
# https://setuptools.readthedocs.io/en/latest/setuptools.html#including-data-files
2222
setuptools.setup(
2323
name="lama-cleaner",
24-
version="1.2.0",
24+
version="1.2.1",
2525
author="PanicByte",
2626
author_email="cwq1913@gmail.com",
2727
description="Image inpainting tool powered by SOTA AI Model",

0 commit comments

Comments
 (0)