Skip to content
This repository was archived by the owner on Aug 13, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions lama_cleaner/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,20 @@ def save_image():
filename = request.form["filename"]
origin_image_bytes = input["image"].read() # RGB
ext = get_image_ext(origin_image_bytes)
image, _, exif_infos = load_img(origin_image_bytes, return_exif=True)
image, alpha_channel, exif_infos = load_img(origin_image_bytes, return_exif=True)
save_path = os.path.join(output_dir, filename)

if alpha_channel is not None:
if alpha_channel.shape[:2] != image.shape[:2]:
alpha_channel = cv2.resize(
alpha_channel, dsize=(image.shape[1], image.shape[0])
)
image = np.concatenate((image, alpha_channel[:, :, np.newaxis]), axis=-1)

pil_image = Image.fromarray(image)

img_bytes = pil_to_bytes(
Image.fromarray(image),
pil_image,
ext,
quality=image_quality,
exif_infos=exif_infos,
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
torch>=1.9.0
torch>=1.13.1
opencv-python
flask==2.2.3
flask-socketio
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def load_requirements():
# https://setuptools.readthedocs.io/en/latest/setuptools.html#including-data-files
setuptools.setup(
name="lama-cleaner",
version="1.2.0",
version="1.2.1",
author="PanicByte",
author_email="[email protected]",
description="Image inpainting tool powered by SOTA AI Model",
Expand Down