Spaces:
Running
on
Zero
Running
on
Zero
Commit
•
f0ba2c6
1
Parent(s):
9b565e0
Update app.py
Browse files
app.py
CHANGED
@@ -132,7 +132,7 @@ def prepare_image_and_mask(image, width, height, overlap_percentage, resize_opti
|
|
132 |
return background, mask
|
133 |
|
134 |
@spaces.GPU
|
135 |
-
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):
|
136 |
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)
|
137 |
|
138 |
if not can_expand(background.width, background.height, width, height, alignment):
|
@@ -162,7 +162,7 @@ def inpaint(image, width, height, overlap_percentage, num_inference_steps, resiz
|
|
162 |
result = result.convert("RGBA")
|
163 |
cnet_image.paste(result, (0, 0), mask)
|
164 |
|
165 |
-
return
|
166 |
|
167 |
def preview_image_and_mask(image, width, height, overlap_percentage, resize_option, custom_resize_percentage, alignment, overlap_left, overlap_right, overlap_top, overlap_bottom):
|
168 |
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)
|
@@ -305,9 +305,9 @@ with gr.Blocks(css=css) as demo:
|
|
305 |
label="Generated Image",
|
306 |
)
|
307 |
use_as_input_button = gr.Button("Use as Input Image", visible=False)
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
|
312 |
def use_output_as_input(output_image):
|
313 |
return gr.update(value=output_image[1])
|
@@ -376,7 +376,7 @@ with gr.Blocks(css=css) as demo:
|
|
376 |
overlap_left, overlap_right, overlap_top, overlap_bottom],
|
377 |
outputs=[result, preview_image],
|
378 |
).then(
|
379 |
-
fn=lambda x, history: update_history(x
|
380 |
inputs=[result, history_gallery],
|
381 |
outputs=history_gallery,
|
382 |
).then(
|
|
|
132 |
return background, mask
|
133 |
|
134 |
@spaces.GPU
|
135 |
+
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)):
|
136 |
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)
|
137 |
|
138 |
if not can_expand(background.width, background.height, width, height, alignment):
|
|
|
162 |
result = result.convert("RGBA")
|
163 |
cnet_image.paste(result, (0, 0), mask)
|
164 |
|
165 |
+
return cnet_image, background
|
166 |
|
167 |
def preview_image_and_mask(image, width, height, overlap_percentage, resize_option, custom_resize_percentage, alignment, overlap_left, overlap_right, overlap_top, overlap_bottom):
|
168 |
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)
|
|
|
305 |
label="Generated Image",
|
306 |
)
|
307 |
use_as_input_button = gr.Button("Use as Input Image", visible=False)
|
308 |
+
with gr.Accordion("History and Mask", open=False):
|
309 |
+
history_gallery = gr.Gallery(label="History", columns=6, object_fit="contain", interactive=False)
|
310 |
+
preview_image = gr.Image(label="Mask preview")
|
311 |
|
312 |
def use_output_as_input(output_image):
|
313 |
return gr.update(value=output_image[1])
|
|
|
376 |
overlap_left, overlap_right, overlap_top, overlap_bottom],
|
377 |
outputs=[result, preview_image],
|
378 |
).then(
|
379 |
+
fn=lambda x, history: update_history(x, history),
|
380 |
inputs=[result, history_gallery],
|
381 |
outputs=history_gallery,
|
382 |
).then(
|