Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -1,5 +1,4 @@
|
|
1 |
import os
|
2 |
-
import spaces
|
3 |
import gradio as gr
|
4 |
import json
|
5 |
import logging
|
@@ -304,7 +303,6 @@ def remove_custom_lora(selected_indices, current_loras):
|
|
304 |
lora_image_2
|
305 |
)
|
306 |
|
307 |
-
@spaces.GPU(duration=75) # ๋ฐ์ฝ๋ ์ดํฐ ์ ๊ฑฐ๊ฐ ํ์ํ ์ ์์
|
308 |
def generate_image(prompt_mash, steps, seed, cfg_scale, width, height, progress):
|
309 |
print("Generating image...")
|
310 |
pipe.to(device)
|
@@ -324,7 +322,6 @@ def generate_image(prompt_mash, steps, seed, cfg_scale, width, height, progress)
|
|
324 |
):
|
325 |
yield img
|
326 |
|
327 |
-
@spaces.GPU(duration=75) # ๋ฐ์ฝ๋ ์ดํฐ ์ ๊ฑฐ๊ฐ ํ์ํ ์ ์์
|
328 |
def generate_image_to_image(prompt_mash, image_input_path, image_strength, steps, cfg_scale, width, height, seed):
|
329 |
pipe_i2i.to(device)
|
330 |
generator = torch.Generator(device=device).manual_seed(seed)
|
@@ -428,7 +425,7 @@ def run_lora(prompt, image_input, image_strength, cfg_scale, steps, selected_ind
|
|
428 |
|
429 |
yield final_image, seed, gr.update(value=progress_bar, visible=False)
|
430 |
|
431 |
-
run_lora.zerogpu = True #
|
432 |
|
433 |
def get_huggingface_safetensors(link):
|
434 |
split_link = link.split("/")
|
@@ -497,7 +494,8 @@ def process_input(input_image, upscale_factor, **kwargs):
|
|
497 |
warnings.warn(
|
498 |
f"Requested output image is too large ({w * upscale_factor}x{h * upscale_factor}). Resizing to ({int(aspect_ratio * MAX_PIXEL_BUDGET ** 0.5 // upscale_factor), int(MAX_PIXEL_BUDGET ** 0.5 // aspect_ratio // upscale_factor)}) pixels."
|
499 |
)
|
500 |
-
gr.Info
|
|
|
501 |
f"Requested output image is too large ({w * upscale_factor}x{h * upscale_factor}). Resizing input to ({int(aspect_ratio * MAX_PIXEL_BUDGET ** 0.5 // upscale_factor), int(MAX_PIXEL_BUDGET ** 0.5 // aspect_ratio // upscale_factor)}) pixels budget."
|
502 |
)
|
503 |
input_image = input_image.resize(
|
@@ -515,7 +513,6 @@ def process_input(input_image, upscale_factor, **kwargs):
|
|
515 |
|
516 |
return input_image.resize((w, h)), w_original, h_original, was_resized
|
517 |
|
518 |
-
@spaces.GPU(duration=75) # ๋ฐ์ฝ๋ ์ดํฐ ์ ๊ฑฐ๊ฐ ํ์ํ ์ ์์
|
519 |
def infer_upscale(
|
520 |
seed,
|
521 |
randomize_seed,
|
@@ -538,7 +535,8 @@ def infer_upscale(
|
|
538 |
|
539 |
generator = torch.Generator().manual_seed(seed)
|
540 |
|
541 |
-
gr.Info
|
|
|
542 |
image = pipe_controlnet(
|
543 |
prompt="",
|
544 |
control_image=control_image,
|
@@ -551,7 +549,7 @@ def infer_upscale(
|
|
551 |
).images[0]
|
552 |
|
553 |
if was_resized:
|
554 |
-
|
555 |
f"Resizing output image to targeted {w_original * upscale_factor}x{h_original * upscale_factor} size."
|
556 |
)
|
557 |
|
@@ -589,7 +587,7 @@ with gr.Blocks(theme="Nymbo/Nymbo_Theme", css=css, delete_cache=(60, 3600)) as a
|
|
589 |
|
590 |
loras_state = gr.State(loras)
|
591 |
selected_indices = gr.State([])
|
592 |
-
|
593 |
with gr.Tab("Generate"):
|
594 |
with gr.Row():
|
595 |
with gr.Column(scale=3):
|
@@ -609,16 +607,16 @@ with gr.Blocks(theme="Nymbo/Nymbo_Theme", css=css, delete_cache=(60, 3600)) as a
|
|
609 |
lora_scale_1 = gr.Slider(label="LoRA 1 Scale", minimum=0, maximum=3, step=0.01, value=1.15)
|
610 |
with gr.Row():
|
611 |
remove_button_1 = gr.Button("Remove", size="sm")
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
with gr.Row():
|
623 |
with gr.Column():
|
624 |
with gr.Group():
|
@@ -764,3 +762,4 @@ app.launch()
|
|
764 |
|
765 |
|
766 |
|
|
|
|
1 |
import os
|
|
|
2 |
import gradio as gr
|
3 |
import json
|
4 |
import logging
|
|
|
303 |
lora_image_2
|
304 |
)
|
305 |
|
|
|
306 |
def generate_image(prompt_mash, steps, seed, cfg_scale, width, height, progress):
|
307 |
print("Generating image...")
|
308 |
pipe.to(device)
|
|
|
322 |
):
|
323 |
yield img
|
324 |
|
|
|
325 |
def generate_image_to_image(prompt_mash, image_input_path, image_strength, steps, cfg_scale, width, height, seed):
|
326 |
pipe_i2i.to(device)
|
327 |
generator = torch.Generator(device=device).manual_seed(seed)
|
|
|
425 |
|
426 |
yield final_image, seed, gr.update(value=progress_bar, visible=False)
|
427 |
|
428 |
+
# run_lora.zerogpu = True # ๋ฐ์ฝ๋ ์ดํฐ ๋ฌธ์ ๋ก ์ ๊ฑฐ
|
429 |
|
430 |
def get_huggingface_safetensors(link):
|
431 |
split_link = link.split("/")
|
|
|
494 |
warnings.warn(
|
495 |
f"Requested output image is too large ({w * upscale_factor}x{h * upscale_factor}). Resizing to ({int(aspect_ratio * MAX_PIXEL_BUDGET ** 0.5 // upscale_factor), int(MAX_PIXEL_BUDGET ** 0.5 // aspect_ratio // upscale_factor)}) pixels."
|
496 |
)
|
497 |
+
# Gradio does not have gr.Info, using print instead
|
498 |
+
print(
|
499 |
f"Requested output image is too large ({w * upscale_factor}x{h * upscale_factor}). Resizing input to ({int(aspect_ratio * MAX_PIXEL_BUDGET ** 0.5 // upscale_factor), int(MAX_PIXEL_BUDGET ** 0.5 // aspect_ratio // upscale_factor)}) pixels budget."
|
500 |
)
|
501 |
input_image = input_image.resize(
|
|
|
513 |
|
514 |
return input_image.resize((w, h)), w_original, h_original, was_resized
|
515 |
|
|
|
516 |
def infer_upscale(
|
517 |
seed,
|
518 |
randomize_seed,
|
|
|
535 |
|
536 |
generator = torch.Generator().manual_seed(seed)
|
537 |
|
538 |
+
# Gradio does not have gr.Info, using print instead
|
539 |
+
print("Upscaling image...")
|
540 |
image = pipe_controlnet(
|
541 |
prompt="",
|
542 |
control_image=control_image,
|
|
|
549 |
).images[0]
|
550 |
|
551 |
if was_resized:
|
552 |
+
print(
|
553 |
f"Resizing output image to targeted {w_original * upscale_factor}x{h_original * upscale_factor} size."
|
554 |
)
|
555 |
|
|
|
587 |
|
588 |
loras_state = gr.State(loras)
|
589 |
selected_indices = gr.State([])
|
590 |
+
|
591 |
with gr.Tab("Generate"):
|
592 |
with gr.Row():
|
593 |
with gr.Column(scale=3):
|
|
|
607 |
lora_scale_1 = gr.Slider(label="LoRA 1 Scale", minimum=0, maximum=3, step=0.01, value=1.15)
|
608 |
with gr.Row():
|
609 |
remove_button_1 = gr.Button("Remove", size="sm")
|
610 |
+
with gr.Column(scale=8):
|
611 |
+
with gr.Row():
|
612 |
+
with gr.Column(scale=0, min_width=50):
|
613 |
+
lora_image_2 = gr.Image(label="LoRA 2 Image", interactive=False, min_width=50, width=50, show_label=False, show_share_button=False, show_download_button=False, show_fullscreen_button=False, height=50)
|
614 |
+
with gr.Column(scale=3, min_width=100):
|
615 |
+
selected_info_2 = gr.Markdown("Select a LoRA 2")
|
616 |
+
with gr.Column(scale=5, min_width=50):
|
617 |
+
lora_scale_2 = gr.Slider(label="LoRA 2 Scale", minimum=0, maximum=3, step=0.01, value=1.15)
|
618 |
+
with gr.Row():
|
619 |
+
remove_button_2 = gr.Button("Remove", size="sm")
|
620 |
with gr.Row():
|
621 |
with gr.Column():
|
622 |
with gr.Group():
|
|
|
762 |
|
763 |
|
764 |
|
765 |
+
|