Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -57,7 +57,7 @@ def load_default_pipeline():
|
|
| 57 |
).to("cuda")
|
| 58 |
return gr.update(value="Default pipeline loaded!")
|
| 59 |
|
| 60 |
-
@spaces.GPU(duration=
|
| 61 |
def fill_image(prompt, image, model_selection, paste_back):
|
| 62 |
print(f"Received image: {image}")
|
| 63 |
if image is None:
|
|
@@ -116,6 +116,8 @@ def prepare_image_and_mask(image, width, height, overlap_percentage, resize_opti
|
|
| 116 |
resize_percentage = 100
|
| 117 |
elif resize_option == "80%":
|
| 118 |
resize_percentage = 80
|
|
|
|
|
|
|
| 119 |
elif resize_option == "50%":
|
| 120 |
resize_percentage = 50
|
| 121 |
elif resize_option == "33%":
|
|
@@ -261,7 +263,7 @@ def use_output_as_input(output_image):
|
|
| 261 |
|
| 262 |
def preload_presets(target_ratio, ui_width, ui_height):
|
| 263 |
if target_ratio == "9:16":
|
| 264 |
-
changed_width =
|
| 265 |
changed_height = 1280
|
| 266 |
return changed_width, changed_height, gr.update()
|
| 267 |
elif target_ratio == "2:3":
|
|
@@ -270,7 +272,7 @@ def preload_presets(target_ratio, ui_width, ui_height):
|
|
| 270 |
return changed_width, changed_height, gr.update()
|
| 271 |
elif target_ratio == "16:9":
|
| 272 |
changed_width = 1280
|
| 273 |
-
changed_height =
|
| 274 |
return changed_width, changed_height, gr.update()
|
| 275 |
elif target_ratio == "1:1":
|
| 276 |
changed_width = 1024
|
|
@@ -319,6 +321,17 @@ css = """
|
|
| 319 |
div#component-17 {
|
| 320 |
height: auto !important;
|
| 321 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 322 |
"""
|
| 323 |
|
| 324 |
title = """<h1 align="center">Diffusers Image Outpaint</h1>
|
|
@@ -415,7 +428,7 @@ with gr.Blocks(css=css, fill_height=True) as demo:
|
|
| 415 |
with gr.Row():
|
| 416 |
target_ratio = gr.Radio(
|
| 417 |
label="Expected Ratio",
|
| 418 |
-
choices=["9:16", "16:9", "1:1", "Custom"],
|
| 419 |
value="1:1",
|
| 420 |
scale=2
|
| 421 |
)
|
|
@@ -432,21 +445,21 @@ with gr.Blocks(css=css, fill_height=True) as demo:
|
|
| 432 |
minimum=720,
|
| 433 |
maximum=1536,
|
| 434 |
step=8,
|
| 435 |
-
value=
|
| 436 |
)
|
| 437 |
height_slider = gr.Slider(
|
| 438 |
label="Target Height",
|
| 439 |
minimum=720,
|
| 440 |
maximum=1536,
|
| 441 |
step=8,
|
| 442 |
-
value=
|
| 443 |
)
|
| 444 |
num_inference_steps = gr.Slider(label="Steps", minimum=4, maximum=12, step=1, value=8)
|
| 445 |
with gr.Group():
|
| 446 |
overlap_percentage = gr.Slider(
|
| 447 |
label="Mask overlap (%)",
|
| 448 |
minimum=1,
|
| 449 |
-
maximum=
|
| 450 |
value=10,
|
| 451 |
step=1
|
| 452 |
)
|
|
@@ -459,7 +472,7 @@ with gr.Blocks(css=css, fill_height=True) as demo:
|
|
| 459 |
with gr.Row():
|
| 460 |
resize_option = gr.Radio(
|
| 461 |
label="Resize input image",
|
| 462 |
-
choices=["Full", "80%", "50%", "33%", "25%", "Custom"],
|
| 463 |
value="Full"
|
| 464 |
)
|
| 465 |
custom_resize_percentage = gr.Slider(
|
|
@@ -472,15 +485,15 @@ with gr.Blocks(css=css, fill_height=True) as demo:
|
|
| 472 |
)
|
| 473 |
with gr.Column():
|
| 474 |
preview_button = gr.Button("Preview alignment and mask")
|
| 475 |
-
gr.Examples(
|
| 476 |
-
|
| 477 |
-
|
| 478 |
-
|
| 479 |
-
|
| 480 |
-
|
| 481 |
-
|
| 482 |
-
|
| 483 |
-
)
|
| 484 |
with gr.Column():
|
| 485 |
result_outpaint = ImageSlider(
|
| 486 |
interactive=False,
|
|
|
|
| 57 |
).to("cuda")
|
| 58 |
return gr.update(value="Default pipeline loaded!")
|
| 59 |
|
| 60 |
+
@spaces.GPU(duration=7)
|
| 61 |
def fill_image(prompt, image, model_selection, paste_back):
|
| 62 |
print(f"Received image: {image}")
|
| 63 |
if image is None:
|
|
|
|
| 116 |
resize_percentage = 100
|
| 117 |
elif resize_option == "80%":
|
| 118 |
resize_percentage = 80
|
| 119 |
+
elif resize_option == "66%":
|
| 120 |
+
resize_percentage = 66
|
| 121 |
elif resize_option == "50%":
|
| 122 |
resize_percentage = 50
|
| 123 |
elif resize_option == "33%":
|
|
|
|
| 263 |
|
| 264 |
def preload_presets(target_ratio, ui_width, ui_height):
|
| 265 |
if target_ratio == "9:16":
|
| 266 |
+
changed_width = 768
|
| 267 |
changed_height = 1280
|
| 268 |
return changed_width, changed_height, gr.update()
|
| 269 |
elif target_ratio == "2:3":
|
|
|
|
| 272 |
return changed_width, changed_height, gr.update()
|
| 273 |
elif target_ratio == "16:9":
|
| 274 |
changed_width = 1280
|
| 275 |
+
changed_height = 768
|
| 276 |
return changed_width, changed_height, gr.update()
|
| 277 |
elif target_ratio == "1:1":
|
| 278 |
changed_width = 1024
|
|
|
|
| 321 |
div#component-17 {
|
| 322 |
height: auto !important;
|
| 323 |
}
|
| 324 |
+
|
| 325 |
+
|
| 326 |
+
@media only screen and (max-width: 600px) {
|
| 327 |
+
.gr-row {
|
| 328 |
+
flex-direction: column;
|
| 329 |
+
}
|
| 330 |
+
.gr-column {
|
| 331 |
+
margin-bottom: 10px;
|
| 332 |
+
}
|
| 333 |
+
}
|
| 334 |
+
|
| 335 |
"""
|
| 336 |
|
| 337 |
title = """<h1 align="center">Diffusers Image Outpaint</h1>
|
|
|
|
| 428 |
with gr.Row():
|
| 429 |
target_ratio = gr.Radio(
|
| 430 |
label="Expected Ratio",
|
| 431 |
+
choices=["2:3", "9:16", "16:9", "1:1", "Custom"],
|
| 432 |
value="1:1",
|
| 433 |
scale=2
|
| 434 |
)
|
|
|
|
| 445 |
minimum=720,
|
| 446 |
maximum=1536,
|
| 447 |
step=8,
|
| 448 |
+
value=1024,
|
| 449 |
)
|
| 450 |
height_slider = gr.Slider(
|
| 451 |
label="Target Height",
|
| 452 |
minimum=720,
|
| 453 |
maximum=1536,
|
| 454 |
step=8,
|
| 455 |
+
value=1024,
|
| 456 |
)
|
| 457 |
num_inference_steps = gr.Slider(label="Steps", minimum=4, maximum=12, step=1, value=8)
|
| 458 |
with gr.Group():
|
| 459 |
overlap_percentage = gr.Slider(
|
| 460 |
label="Mask overlap (%)",
|
| 461 |
minimum=1,
|
| 462 |
+
maximum=80,
|
| 463 |
value=10,
|
| 464 |
step=1
|
| 465 |
)
|
|
|
|
| 472 |
with gr.Row():
|
| 473 |
resize_option = gr.Radio(
|
| 474 |
label="Resize input image",
|
| 475 |
+
choices=["Full", "80%", "66%", "50%", "33%", "25%", "Custom"],
|
| 476 |
value="Full"
|
| 477 |
)
|
| 478 |
custom_resize_percentage = gr.Slider(
|
|
|
|
| 485 |
)
|
| 486 |
with gr.Column():
|
| 487 |
preview_button = gr.Button("Preview alignment and mask")
|
| 488 |
+
# gr.Examples(
|
| 489 |
+
# examples=[
|
| 490 |
+
# ["./examples/example_1.webp", 1280, 720, "Middle"],
|
| 491 |
+
# ["./examples/example_2.jpg", 1440, 810, "Left"],
|
| 492 |
+
# ["./examples/example_3.jpg", 1024, 1024, "Top"],
|
| 493 |
+
# ["./examples/example_3.jpg", 1024, 1024, "Bottom"],
|
| 494 |
+
# ],
|
| 495 |
+
# inputs=[input_image_outpaint, width_slider, height_slider, alignment_dropdown],
|
| 496 |
+
# )
|
| 497 |
with gr.Column():
|
| 498 |
result_outpaint = ImageSlider(
|
| 499 |
interactive=False,
|