This commit is contained in:
Qing 2023-06-27 10:08:36 +08:00
parent 9de04e42a7
commit 08a962cdfb
2 changed files with 12 additions and 3 deletions

View File

@ -138,11 +138,20 @@ def save_image():
filename = request.form["filename"] filename = request.form["filename"]
origin_image_bytes = input["image"].read() # RGB origin_image_bytes = input["image"].read() # RGB
ext = get_image_ext(origin_image_bytes) 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) 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( img_bytes = pil_to_bytes(
Image.fromarray(image), pil_image,
ext, ext,
quality=image_quality, quality=image_quality,
exif_infos=exif_infos, exif_infos=exif_infos,

View File

@ -21,7 +21,7 @@ def load_requirements():
# https://setuptools.readthedocs.io/en/latest/setuptools.html#including-data-files # https://setuptools.readthedocs.io/en/latest/setuptools.html#including-data-files
setuptools.setup( setuptools.setup(
name="lama-cleaner", name="lama-cleaner",
version="1.2.0", version="1.2.1",
author="PanicByte", author="PanicByte",
author_email="cwq1913@gmail.com", author_email="cwq1913@gmail.com",
description="Image inpainting tool powered by SOTA AI Model", description="Image inpainting tool powered by SOTA AI Model",