diff --git a/modules/img2img.py b/modules/img2img.py index ec72a8ad0..d13733676 100644 --- a/modules/img2img.py +++ b/modules/img2img.py @@ -2,7 +2,6 @@ import os from contextlib import closing from pathlib import Path -import numpy as np from PIL import Image, ImageOps, ImageFilter, ImageEnhance, UnidentifiedImageError import gradio as gr @@ -163,8 +162,7 @@ def img2img(id_task: str, mode: int, prompt: str, negative_prompt: str, prompt_s elif mode == 3: # inpaint sketch image = inpaint_color_sketch["composite"] orig = inpaint_color_sketch["background"] - pred = np.any(np.array(image) != np.array(orig), axis=-1) - mask = Image.fromarray(pred.astype(np.uint8) * 255, "L") + mask = inpaint_color_sketch["layers"][0].getchannel("A") mask = ImageEnhance.Brightness(mask).enhance(1 - mask_alpha / 100) blur = ImageFilter.GaussianBlur(mask_blur) image = Image.composite(image.filter(blur), orig, mask.filter(blur)) diff --git a/modules/ui.py b/modules/ui.py index e4d65f8d8..442d614e4 100644 --- a/modules/ui.py +++ b/modules/ui.py @@ -538,7 +538,7 @@ def create_ui(): add_copy_image_controls('inpaint', init_img_with_mask) with gr.TabItem('Inpaint sketch', id='inpaint_sketch', elem_id="img2img_inpaint_sketch_tab") as tab_inpaint_color: - inpaint_color_sketch = gr.ImageEditor(label="Color sketch inpainting", show_label=False, elem_id="inpaint_sketch", brush=Brush(default_color=opts.img2img_inpaint_sketch_default_brush_color), interactive=True, type="pil", image_mode="RGB", height=opts.img2img_editor_height) + inpaint_color_sketch = gr.ImageEditor(label="Color sketch inpainting", show_label=False, elem_id="inpaint_sketch", brush=Brush(default_color=opts.img2img_inpaint_sketch_default_brush_color), interactive=True, type="pil", image_mode="RGBA", height=opts.img2img_editor_height) add_copy_image_controls('inpaint_sketch', inpaint_color_sketch) with gr.TabItem('Inpaint upload', id='inpaint_upload', elem_id="img2img_inpaint_upload_tab") as tab_inpaint_upload: