Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -119,7 +119,7 @@ def prepare_image_and_mask(image, width, height, overlap_percentage, resize_opti
|
|
119 |
return background, mask
|
120 |
|
121 |
@spaces.GPU(duration=200)
|
122 |
-
def inpaint(image, width, height, overlap_percentage, num_inference_steps, resize_option, custom_resize_percentage, prompt_input, alignment, overlap_left, overlap_right, overlap_top, overlap_bottom, progress=gr.Progress(track_tqdm=True)):
|
123 |
|
124 |
background, mask = prepare_image_and_mask(image, width, height, overlap_percentage, resize_option, custom_resize_percentage, alignment, overlap_left, overlap_right, overlap_top, overlap_bottom)
|
125 |
|
@@ -140,7 +140,7 @@ def inpaint(image, width, height, overlap_percentage, num_inference_steps, resiz
|
|
140 |
image=cnet_image,
|
141 |
mask_image=mask,
|
142 |
num_inference_steps=num_inference_steps,
|
143 |
-
guidance_scale=
|
144 |
).images[0]
|
145 |
|
146 |
result = result.convert("RGBA")
|
@@ -238,6 +238,14 @@ with gr.Blocks(css=css) as demo:
|
|
238 |
with gr.Row():
|
239 |
with gr.Column(scale=2):
|
240 |
prompt_input = gr.Textbox(label="Prompt (Optional)")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
241 |
with gr.Column(scale=1):
|
242 |
run_button = gr.Button("Generate")
|
243 |
|
@@ -308,22 +316,23 @@ with gr.Blocks(css=css) as demo:
|
|
308 |
interactive=False,
|
309 |
label="Generated Image",
|
310 |
)
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
|
|
327 |
use_as_input_button = gr.Button("Use as Input Image", visible=False)
|
328 |
with gr.Accordion("History and Mask", open=False):
|
329 |
history_gallery = gr.Gallery(label="History", columns=6, object_fit="contain", interactive=False)
|
@@ -374,7 +383,7 @@ with gr.Blocks(css=css) as demo:
|
|
374 |
fn=inpaint,
|
375 |
inputs=[input_image, width_slider, height_slider, overlap_percentage, num_inference_steps,
|
376 |
resize_option, custom_resize_percentage, prompt_input, alignment_dropdown,
|
377 |
-
overlap_left, overlap_right, overlap_top, overlap_bottom],
|
378 |
outputs=[result, preview_image, result_mask, result_pure, cnet_pure, background],
|
379 |
).then(
|
380 |
fn=lambda x, history: update_history(x, history),
|
|
|
119 |
return background, mask
|
120 |
|
121 |
@spaces.GPU(duration=200)
|
122 |
+
def inpaint(image, width, height, overlap_percentage, num_inference_steps, resize_option, custom_resize_percentage, prompt_input, alignment, overlap_left, overlap_right, overlap_top, overlap_bottom, guidance_scale, progress=gr.Progress(track_tqdm=True)):
|
123 |
|
124 |
background, mask = prepare_image_and_mask(image, width, height, overlap_percentage, resize_option, custom_resize_percentage, alignment, overlap_left, overlap_right, overlap_top, overlap_bottom)
|
125 |
|
|
|
140 |
image=cnet_image,
|
141 |
mask_image=mask,
|
142 |
num_inference_steps=num_inference_steps,
|
143 |
+
guidance_scale=guidance_scale,
|
144 |
).images[0]
|
145 |
|
146 |
result = result.convert("RGBA")
|
|
|
238 |
with gr.Row():
|
239 |
with gr.Column(scale=2):
|
240 |
prompt_input = gr.Textbox(label="Prompt (Optional)")
|
241 |
+
with gr.Column(scale=2):
|
242 |
+
guidance_scale = gr.Slider(
|
243 |
+
minimum=1,
|
244 |
+
maximum=50,
|
245 |
+
value=30,
|
246 |
+
step=0.5,
|
247 |
+
label="Guidance Scale"
|
248 |
+
)
|
249 |
with gr.Column(scale=1):
|
250 |
run_button = gr.Button("Generate")
|
251 |
|
|
|
316 |
interactive=False,
|
317 |
label="Generated Image",
|
318 |
)
|
319 |
+
with gr.Accordion("Step Results", open=False):
|
320 |
+
result_mask = gr.Image(
|
321 |
+
interactive=False,
|
322 |
+
label="Generated Mask",
|
323 |
+
)
|
324 |
+
result_pure = gr.Image(
|
325 |
+
interactive=False,
|
326 |
+
label="Generated Result",
|
327 |
+
)
|
328 |
+
cnet_pure = gr.Image(
|
329 |
+
interactive=False,
|
330 |
+
label="Cnet Pure",
|
331 |
+
)
|
332 |
+
background = gr.Image(
|
333 |
+
interactive=False,
|
334 |
+
label="background",
|
335 |
+
)
|
336 |
use_as_input_button = gr.Button("Use as Input Image", visible=False)
|
337 |
with gr.Accordion("History and Mask", open=False):
|
338 |
history_gallery = gr.Gallery(label="History", columns=6, object_fit="contain", interactive=False)
|
|
|
383 |
fn=inpaint,
|
384 |
inputs=[input_image, width_slider, height_slider, overlap_percentage, num_inference_steps,
|
385 |
resize_option, custom_resize_percentage, prompt_input, alignment_dropdown,
|
386 |
+
overlap_left, overlap_right, overlap_top, overlap_bottom, guidance_scale],
|
387 |
outputs=[result, preview_image, result_mask, result_pure, cnet_pure, background],
|
388 |
).then(
|
389 |
fn=lambda x, history: update_history(x, history),
|