Spaces:
Paused
Paused
Update diffusion_webui/stable_diffusion/inpaint_app.py
Browse files
diffusion_webui/stable_diffusion/inpaint_app.py
CHANGED
|
@@ -29,25 +29,8 @@ stable_negative_prompt_list = [
|
|
| 29 |
]
|
| 30 |
|
| 31 |
|
| 32 |
-
def resize(height,img):
|
| 33 |
-
baseheight = height
|
| 34 |
-
img = Image.open(img)
|
| 35 |
-
hpercent = (baseheight/float(img.size[1]))
|
| 36 |
-
wsize = int((float(img.size[0])*float(hpercent)))
|
| 37 |
-
img = img.resize((wsize,baseheight), Image.Resampling.LANCZOS)
|
| 38 |
-
return img
|
| 39 |
-
|
| 40 |
-
def img_preprocces(source_img, prompt, negative_prompt):
|
| 41 |
-
imageio.imwrite("data.png", source_img["image"])
|
| 42 |
-
imageio.imwrite("data_mask.png", source_img["mask"])
|
| 43 |
-
src = resize(512, "data.png")
|
| 44 |
-
src.save("src.png")
|
| 45 |
-
mask = resize(512, "data_mask.png")
|
| 46 |
-
mask.save("mask.png")
|
| 47 |
-
return src, mask
|
| 48 |
-
|
| 49 |
def stable_diffusion_inpaint(
|
| 50 |
-
|
| 51 |
model_path:str,
|
| 52 |
prompt:str,
|
| 53 |
negative_prompt:str,
|
|
@@ -55,7 +38,8 @@ def stable_diffusion_inpaint(
|
|
| 55 |
num_inference_step:int,
|
| 56 |
):
|
| 57 |
|
| 58 |
-
image
|
|
|
|
| 59 |
pipe = DiffusionPipeline.from_pretrained(
|
| 60 |
model_path,
|
| 61 |
revision="fp16",
|
|
@@ -80,10 +64,11 @@ def stable_diffusion_inpaint(
|
|
| 80 |
def stable_diffusion_inpaint_app():
|
| 81 |
with gr.Tab('Inpaint'):
|
| 82 |
inpaint_image_file = gr.Image(
|
| 83 |
-
source=
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
|
|
|
| 87 |
)
|
| 88 |
|
| 89 |
inpaint_model_id = gr.Dropdown(
|
|
|
|
| 29 |
]
|
| 30 |
|
| 31 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
def stable_diffusion_inpaint(
|
| 33 |
+
dict:str,
|
| 34 |
model_path:str,
|
| 35 |
prompt:str,
|
| 36 |
negative_prompt:str,
|
|
|
|
| 38 |
num_inference_step:int,
|
| 39 |
):
|
| 40 |
|
| 41 |
+
image = dict["image"].convert("RGB").resize((512, 512))
|
| 42 |
+
mask_image = dict["mask"].convert("RGB").resize((512, 512))
|
| 43 |
pipe = DiffusionPipeline.from_pretrained(
|
| 44 |
model_path,
|
| 45 |
revision="fp16",
|
|
|
|
| 64 |
def stable_diffusion_inpaint_app():
|
| 65 |
with gr.Tab('Inpaint'):
|
| 66 |
inpaint_image_file = gr.Image(
|
| 67 |
+
source='upload',
|
| 68 |
+
tool='sketch',
|
| 69 |
+
elem_id="image_upload",
|
| 70 |
+
type="pil",
|
| 71 |
+
label="Upload"
|
| 72 |
)
|
| 73 |
|
| 74 |
inpaint_model_id = gr.Dropdown(
|