Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -62,6 +62,34 @@ def image_to_image(ip, image, prompt, neg_prompt, width, height, ip_scale, stren
|
|
62 |
|
63 |
return images[0]
|
64 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
|
66 |
with gr.Blocks() as demo:
|
67 |
gr.Markdown("""
|
@@ -98,5 +126,6 @@ with gr.Blocks() as demo:
|
|
98 |
|
99 |
text_button.click(text_to_image, inputs=[text_ip, text_prompt, neg_prompt, width_slider, height_slider, ip_scale_slider, strength_slider, guidance_slider, steps_slider], outputs=output_image)
|
100 |
image_button.click(image_to_image, inputs=[image_ip, image_image, image_prompt, neg_prompt, width_slider, height_slider, ip_scale_slider, strength_slider, guidance_slider, steps_slider], outputs=output_image)
|
|
|
101 |
|
102 |
demo.launch()
|
|
|
62 |
|
63 |
return images[0]
|
64 |
|
65 |
+
@spaces.GPU(enable_queue=True)
|
66 |
+
def inpaint(ip, image_editor, prompt, neg_prompt, width, height, ip_scale, strength, guidance, steps):
|
67 |
+
inpaint_pipeline.to("cuda")
|
68 |
+
|
69 |
+
image = image_editor['background']
|
70 |
+
mask = image_editor['composite']
|
71 |
+
|
72 |
+
ip.thumbnail((1024, 1024))
|
73 |
+
image.thumbnail((1024, 1024))
|
74 |
+
mask.thumbnail((1024, 1024))
|
75 |
+
|
76 |
+
inpaint_pipeline.set_ip_adapter_scale(ip_scale)
|
77 |
+
|
78 |
+
images = inpaint_pipeline(
|
79 |
+
prompt=prompt,
|
80 |
+
image=image,
|
81 |
+
mask_image=mask,
|
82 |
+
ip_adapter_image=ip,
|
83 |
+
negative_prompt=neg_prompt,
|
84 |
+
width=width,
|
85 |
+
height=height,
|
86 |
+
strength=strength,
|
87 |
+
guidance_scale=guidance,
|
88 |
+
num_inference_steps=steps,
|
89 |
+
).images
|
90 |
+
|
91 |
+
return images[0]
|
92 |
+
|
93 |
|
94 |
with gr.Blocks() as demo:
|
95 |
gr.Markdown("""
|
|
|
126 |
|
127 |
text_button.click(text_to_image, inputs=[text_ip, text_prompt, neg_prompt, width_slider, height_slider, ip_scale_slider, strength_slider, guidance_slider, steps_slider], outputs=output_image)
|
128 |
image_button.click(image_to_image, inputs=[image_ip, image_image, image_prompt, neg_prompt, width_slider, height_slider, ip_scale_slider, strength_slider, guidance_slider, steps_slider], outputs=output_image)
|
129 |
+
inpaint_button.click(inpaint, inputs=[inpaint_ip, inpaint_editor, inpaint_prompt, neg_prompt, width_slider, height_slider, ip_scale_slider, strength_slider, guidance_slider, steps_slider], outputs=output_image)
|
130 |
|
131 |
demo.launch()
|