Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -348,95 +348,7 @@ with gr.Blocks(css=css) as demo:
|
|
348 |
|
349 |
with gr.Column():
|
350 |
result = gr.Image(label="Generated Image", format="png")
|
351 |
-
use_as_input_button = gr.Button("Use as Input Image", visible=False, interactive=False)
|
352 |
|
353 |
history_gallery = gr.Gallery(label="History", columns=6, object_fit="contain", interactive=False)
|
354 |
-
preview_image = gr.Image(label="Preview")
|
355 |
-
|
356 |
-
def use_output_as_input(output_image):
|
357 |
-
"""Sets the generated output as the new input image."""
|
358 |
-
return gr.update(value=output_image)
|
359 |
-
|
360 |
-
use_as_input_button.click(
|
361 |
-
fn=use_output_as_input,
|
362 |
-
inputs=[result],
|
363 |
-
outputs=[input_image]
|
364 |
-
)
|
365 |
-
|
366 |
-
target_ratio.change(
|
367 |
-
fn=preload_presets,
|
368 |
-
inputs=[target_ratio, width_slider, height_slider],
|
369 |
-
outputs=[width_slider, height_slider, settings_panel],
|
370 |
-
queue=False
|
371 |
-
)
|
372 |
-
|
373 |
-
width_slider.change(
|
374 |
-
fn=select_the_right_preset,
|
375 |
-
inputs=[width_slider, height_slider],
|
376 |
-
outputs=[target_ratio],
|
377 |
-
queue=False
|
378 |
-
)
|
379 |
-
|
380 |
-
height_slider.change(
|
381 |
-
fn=select_the_right_preset,
|
382 |
-
inputs=[width_slider, height_slider],
|
383 |
-
outputs=[target_ratio],
|
384 |
-
queue=False
|
385 |
-
)
|
386 |
-
|
387 |
-
resize_option.change(
|
388 |
-
fn=toggle_custom_resize_slider,
|
389 |
-
inputs=[resize_option],
|
390 |
-
outputs=[custom_resize_percentage],
|
391 |
-
queue=False
|
392 |
-
)
|
393 |
-
|
394 |
-
run_button.click(
|
395 |
-
fn=clear_result,
|
396 |
-
inputs=None,
|
397 |
-
outputs=result,
|
398 |
-
).then(
|
399 |
-
fn=infer,
|
400 |
-
inputs=[input_image, width_slider, height_slider, overlap_percentage, num_inference_steps,
|
401 |
-
resize_option, custom_resize_percentage, prompt_input, alignment_dropdown,
|
402 |
-
overlap_left, overlap_right, overlap_top, overlap_bottom],
|
403 |
-
outputs=result,
|
404 |
-
).then(
|
405 |
-
fn=lambda x, history: update_history(x, history),
|
406 |
-
inputs=[result, history_gallery],
|
407 |
-
outputs=history_gallery,
|
408 |
-
).then(
|
409 |
-
fn=lambda: gr.update(visible=True),
|
410 |
-
inputs=None,
|
411 |
-
outputs=use_as_input_button,
|
412 |
-
)
|
413 |
-
|
414 |
-
prompt_input.submit(
|
415 |
-
fn=clear_result,
|
416 |
-
inputs=None,
|
417 |
-
outputs=result,
|
418 |
-
).then(
|
419 |
-
fn=infer,
|
420 |
-
inputs=[input_image, width_slider, height_slider, overlap_percentage, num_inference_steps,
|
421 |
-
resize_option, custom_resize_percentage, prompt_input, alignment_dropdown,
|
422 |
-
overlap_left, overlap_right, overlap_top, overlap_bottom],
|
423 |
-
outputs=result,
|
424 |
-
).then(
|
425 |
-
fn=lambda x, history: update_history(x, history),
|
426 |
-
inputs=[result, history_gallery],
|
427 |
-
outputs=history_gallery,
|
428 |
-
).then(
|
429 |
-
fn=lambda: gr.update(visible=True),
|
430 |
-
inputs=None,
|
431 |
-
outputs=use_as_input_button,
|
432 |
-
)
|
433 |
-
|
434 |
-
preview_button.click(
|
435 |
-
fn=preview_image_and_mask,
|
436 |
-
inputs=[input_image, width_slider, height_slider, overlap_percentage, resize_option, custom_resize_percentage, alignment_dropdown,
|
437 |
-
overlap_left, overlap_right, overlap_top, overlap_bottom],
|
438 |
-
outputs=preview_image,
|
439 |
-
queue=False
|
440 |
-
)
|
441 |
|
442 |
demo.queue(max_size=20).launch(share=False, ssr_mode=False, show_error=True)
|
|
|
348 |
|
349 |
with gr.Column():
|
350 |
result = gr.Image(label="Generated Image", format="png")
|
|
|
351 |
|
352 |
history_gallery = gr.Gallery(label="History", columns=6, object_fit="contain", interactive=False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
353 |
|
354 |
demo.queue(max_size=20).launch(share=False, ssr_mode=False, show_error=True)
|