Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -702,28 +702,16 @@ with gr.Blocks(theme=gr.themes.Soft(), css=css) as demo:
|
|
702 |
|
703 |
|
704 |
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
'y_position': text_y_position.value
|
716 |
-
}
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
# ์์น ๋ฒํผ ์ด๋ฒคํธ
|
721 |
-
for btn, pos in [
|
722 |
-
(btn_top_left, "top-left"), (btn_top_center, "top-center"), (btn_top_right, "top-right"),
|
723 |
-
(btn_middle_left, "middle-left"), (btn_middle_center, "middle-center"), (btn_middle_right, "middle-right"),
|
724 |
-
(btn_bottom_left, "bottom-left"), (btn_bottom_center, "bottom-center"), (btn_bottom_right, "bottom-right")
|
725 |
-
]:
|
726 |
-
btn.click(fn=lambda p=pos: p, outputs=position)
|
727 |
|
728 |
# ์ด๋ฒคํธ ๋ฐ์ธ๋ฉ
|
729 |
input_image.change(
|
@@ -747,7 +735,7 @@ def get_text_params():
|
|
747 |
queue=False
|
748 |
)
|
749 |
|
750 |
-
# ์์น ๋ฒํผ ์ด๋ฒคํธ
|
751 |
for btn, pos in [
|
752 |
(btn_top_left, "top-left"), (btn_top_center, "top-center"), (btn_top_right, "top-right"),
|
753 |
(btn_middle_left, "middle-left"), (btn_middle_center, "middle-center"), (btn_middle_right, "middle-right"),
|
@@ -765,29 +753,20 @@ def get_text_params():
|
|
765 |
aspect_ratio,
|
766 |
position,
|
767 |
scale_slider,
|
768 |
-
#
|
769 |
-
{
|
770 |
-
'text': text_input,
|
771 |
-
'font_size': font_size,
|
772 |
-
'thickness': thickness,
|
773 |
-
'color': color_dropdown,
|
774 |
-
'opacity': opacity_slider,
|
775 |
-
'x_position': text_x_position,
|
776 |
-
'y_position': text_y_position
|
777 |
-
}
|
778 |
],
|
779 |
outputs=[combined_image, extracted_image],
|
780 |
queue=True
|
781 |
)
|
782 |
|
|
|
783 |
if HF_TOKEN:
|
784 |
login(token=HF_TOKEN, add_to_git_credential=False)
|
785 |
|
786 |
-
# FLUX ํ์ดํ๋ผ์ธ ์ด๊ธฐํ ์์
|
787 |
pipe = FluxPipeline.from_pretrained(
|
788 |
"black-forest-labs/FLUX.1-dev",
|
789 |
torch_dtype=torch.float16,
|
790 |
-
token=HF_TOKEN
|
791 |
)
|
792 |
|
793 |
demo.queue(max_size=5)
|
|
|
702 |
|
703 |
|
704 |
|
705 |
+
def get_text_params():
|
706 |
+
return {
|
707 |
+
'text': text_input.value,
|
708 |
+
'font_size': font_size.value,
|
709 |
+
'thickness': thickness.value,
|
710 |
+
'color': color_dropdown.value,
|
711 |
+
'opacity': opacity_slider.value,
|
712 |
+
'x_position': text_x_position.value,
|
713 |
+
'y_position': text_y_position.value
|
714 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
715 |
|
716 |
# ์ด๋ฒคํธ ๋ฐ์ธ๋ฉ
|
717 |
input_image.change(
|
|
|
735 |
queue=False
|
736 |
)
|
737 |
|
738 |
+
# ์์น ๋ฒํผ ์ด๋ฒคํธ (ํ ๋ฒ๋ง ์ ์)
|
739 |
for btn, pos in [
|
740 |
(btn_top_left, "top-left"), (btn_top_center, "top-center"), (btn_top_right, "top-right"),
|
741 |
(btn_middle_left, "middle-left"), (btn_middle_center, "middle-center"), (btn_middle_right, "middle-right"),
|
|
|
753 |
aspect_ratio,
|
754 |
position,
|
755 |
scale_slider,
|
756 |
+
gr.State(get_text_params) # State ๊ฐ์ฒด๋ก ๊ฐ์ธ์ ์ ๋ฌ
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
757 |
],
|
758 |
outputs=[combined_image, extracted_image],
|
759 |
queue=True
|
760 |
)
|
761 |
|
762 |
+
# HF ํ ํฐ ๋ฐ ํ์ดํ๋ผ์ธ ์ด๊ธฐํ
|
763 |
if HF_TOKEN:
|
764 |
login(token=HF_TOKEN, add_to_git_credential=False)
|
765 |
|
|
|
766 |
pipe = FluxPipeline.from_pretrained(
|
767 |
"black-forest-labs/FLUX.1-dev",
|
768 |
torch_dtype=torch.float16,
|
769 |
+
token=HF_TOKEN
|
770 |
)
|
771 |
|
772 |
demo.queue(max_size=5)
|