Spaces:
Building
Building
Update app.py
Browse files
app.py
CHANGED
@@ -572,7 +572,7 @@ def infer_upscale(
|
|
572 |
|
573 |
if randomize_seed:
|
574 |
seed = random.randint(0, MAX_SEED)
|
575 |
-
|
576 |
input_image, w_original, h_original, was_resized = process_input(
|
577 |
input_image, upscale_factor
|
578 |
)
|
@@ -607,11 +607,11 @@ def infer_upscale(
|
|
607 |
# resize to target desired size
|
608 |
image = image.resize((w_original * upscale_factor, h_original * upscale_factor))
|
609 |
image.save("output.jpg")
|
610 |
-
|
611 |
-
return
|
612 |
except Exception as e:
|
613 |
print(f"Error in infer_upscale: {str(e)}")
|
614 |
-
return
|
615 |
|
616 |
|
617 |
with gr.Blocks(theme="Nymbo/Nymbo_Theme", css=css, delete_cache=(60, 3600)) as app:
|
@@ -724,7 +724,8 @@ with gr.Blocks(theme="Nymbo/Nymbo_Theme", css=css, delete_cache=(60, 3600)) as a
|
|
724 |
upscale_randomize_seed = gr.Checkbox(label="Randomize seed for Upscaling", value=True)
|
725 |
|
726 |
with gr.Row():
|
727 |
-
upscale_result = gr.Image(label="
|
|
|
728 |
|
729 |
# Event handlers
|
730 |
gallery.select(
|
@@ -757,7 +758,7 @@ with gr.Blocks(theme="Nymbo/Nymbo_Theme", css=css, delete_cache=(60, 3600)) as a
|
|
757 |
inputs=[selected_indices, loras_state],
|
758 |
outputs=[loras_state, gallery, selected_info_1, selected_info_2, selected_indices, lora_scale_1, lora_scale_2, lora_image_1, lora_image_2]
|
759 |
)
|
760 |
-
# 이벤트 핸들러 수정
|
761 |
gr.on(
|
762 |
triggers=[generate_button.click, prompt.submit],
|
763 |
fn=run_lora,
|
@@ -768,7 +769,6 @@ with gr.Blocks(theme="Nymbo/Nymbo_Theme", css=css, delete_cache=(60, 3600)) as a
|
|
768 |
inputs=[result, history_gallery],
|
769 |
outputs=history_gallery,
|
770 |
)
|
771 |
-
|
772 |
|
773 |
# 업스케일 버튼 이벤트 추가
|
774 |
upscale_button.click(
|
@@ -781,7 +781,7 @@ with gr.Blocks(theme="Nymbo/Nymbo_Theme", css=css, delete_cache=(60, 3600)) as a
|
|
781 |
upscale_factor,
|
782 |
controlnet_conditioning_scale,
|
783 |
],
|
784 |
-
outputs=upscale_result,
|
785 |
)
|
786 |
|
787 |
if __name__ == "__main__":
|
|
|
572 |
|
573 |
if randomize_seed:
|
574 |
seed = random.randint(0, MAX_SEED)
|
575 |
+
|
576 |
input_image, w_original, h_original, was_resized = process_input(
|
577 |
input_image, upscale_factor
|
578 |
)
|
|
|
607 |
# resize to target desired size
|
608 |
image = image.resize((w_original * upscale_factor, h_original * upscale_factor))
|
609 |
image.save("output.jpg")
|
610 |
+
|
611 |
+
return image, seed
|
612 |
except Exception as e:
|
613 |
print(f"Error in infer_upscale: {str(e)}")
|
614 |
+
return None, seed
|
615 |
|
616 |
|
617 |
with gr.Blocks(theme="Nymbo/Nymbo_Theme", css=css, delete_cache=(60, 3600)) as app:
|
|
|
724 |
upscale_randomize_seed = gr.Checkbox(label="Randomize seed for Upscaling", value=True)
|
725 |
|
726 |
with gr.Row():
|
727 |
+
upscale_result = gr.Image(label="Upscaled Image", type="pil")
|
728 |
+
upscale_seed_output = gr.Number(label="Seed Used", precision=0)
|
729 |
|
730 |
# Event handlers
|
731 |
gallery.select(
|
|
|
758 |
inputs=[selected_indices, loras_state],
|
759 |
outputs=[loras_state, gallery, selected_info_1, selected_info_2, selected_indices, lora_scale_1, lora_scale_2, lora_image_1, lora_image_2]
|
760 |
)
|
761 |
+
# 이벤트 핸들러 수정
|
762 |
gr.on(
|
763 |
triggers=[generate_button.click, prompt.submit],
|
764 |
fn=run_lora,
|
|
|
769 |
inputs=[result, history_gallery],
|
770 |
outputs=history_gallery,
|
771 |
)
|
|
|
772 |
|
773 |
# 업스케일 버튼 이벤트 추가
|
774 |
upscale_button.click(
|
|
|
781 |
upscale_factor,
|
782 |
controlnet_conditioning_scale,
|
783 |
],
|
784 |
+
outputs=[upscale_result, upscale_seed_output],
|
785 |
)
|
786 |
|
787 |
if __name__ == "__main__":
|