From 38005c1044198e86ba846fcbe6380f2594f037fb Mon Sep 17 00:00:00 2001 From: "wq.chu" Date: Sat, 17 Jun 2023 22:05:29 +0800 Subject: [PATCH 1/3] fix save_image png channel --- lama_cleaner/server.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lama_cleaner/server.py b/lama_cleaner/server.py index c186ce238..755dc6295 100644 --- a/lama_cleaner/server.py +++ b/lama_cleaner/server.py @@ -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, From 203e775e2ed9bda2c55b15bba71a2a107ba7b8d2 Mon Sep 17 00:00:00 2001 From: "wq.chu" Date: Sat, 17 Jun 2023 22:05:59 +0800 Subject: [PATCH 2/3] 1.2.1 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 20fad90f8..5c9cd3bc7 100644 --- a/setup.py +++ b/setup.py @@ -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="cwq1913@gmail.com", description="Image inpainting tool powered by SOTA AI Model", From a759a21b00eacf0915d5ac0d9d0f9fd9a7175f16 Mon Sep 17 00:00:00 2001 From: chncaption <101684156+chncaption@users.noreply.github.com> Date: Mon, 19 Jun 2023 12:13:41 +0800 Subject: [PATCH 3/3] update torch 1.9.0 to 1.13.1 --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 2fa4d4fd9..e63e1af1d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -torch>=1.9.0 +torch>=1.13.1 opencv-python flask==2.2.3 flask-socketio