From 10791e7d3571fbd2888d6a0a00d0c7af89b12f9e Mon Sep 17 00:00:00 2001 From: missionfloyd Date: Mon, 4 Dec 2023 22:40:40 -0700 Subject: [PATCH] Fix inpaint --- modules/img2img.py | 2 +- modules/ui.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/img2img.py b/modules/img2img.py index 333b6ee9f..34642ce1b 100644 --- a/modules/img2img.py +++ b/modules/img2img.py @@ -158,7 +158,7 @@ def img2img(id_task: str, mode: int, prompt: str, negative_prompt: str, prompt_s image = sketch mask = None elif mode == 2: # inpaint - image, mask = init_img_with_mask["image"], init_img_with_mask["mask"] + image, mask = init_img_with_mask["background"], init_img_with_mask["layers"][0] mask = processing.create_binary_mask(mask) elif mode == 3: # inpaint sketch image = inpaint_color_sketch diff --git a/modules/ui.py b/modules/ui.py index 4ada327d4..2e6c6ce8a 100644 --- a/modules/ui.py +++ b/modules/ui.py @@ -8,6 +8,7 @@ from contextlib import ExitStack import gradio as gr import gradio.utils +from gradio.components.image_editor import Brush import numpy as np from PIL import Image, PngImagePlugin # noqa: F401 from modules.call_queue import wrap_gradio_gpu_call, wrap_queued_call, wrap_gradio_call @@ -534,7 +535,7 @@ def create_ui(): add_copy_image_controls('sketch', sketch) with gr.TabItem('Inpaint', id='inpaint', elem_id="img2img_inpaint_tab") as tab_inpaint: - init_img_with_mask = gr.Image(label="Image for inpainting with mask", show_label=False, elem_id="img2maskimg", source="upload", interactive=True, type="pil", tool="sketch", image_mode="RGBA", height=opts.img2img_editor_height, brush_color=opts.img2img_inpaint_mask_brush_color) + init_img_with_mask = gr.ImageEditor(label="Image for inpainting with mask", show_label=False, elem_id="img2maskimg", sources=("upload", "clipboard"), brush=Brush(colors=["#000000"], color_mode="fixed"), interactive=True, type="pil", image_mode="RGBA", height=opts.img2img_editor_height, brush_color=opts.img2img_inpaint_mask_brush_color) 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: