Update app.py
Browse files
app.py
CHANGED
@@ -826,7 +826,21 @@ with gr.Blocks(theme=gr.themes.Soft(), css=css) as demo:
|
|
826 |
</div>
|
827 |
""")
|
828 |
|
829 |
-
# ์ด๋ฒคํธ
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
830 |
input_image.change(
|
831 |
fn=update_process_button,
|
832 |
inputs=[input_image, text_prompt],
|
@@ -841,6 +855,14 @@ with gr.Blocks(theme=gr.themes.Soft(), css=css) as demo:
|
|
841 |
queue=False
|
842 |
)
|
843 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
844 |
bg_prompt.change(
|
845 |
fn=update_controls,
|
846 |
inputs=bg_prompt,
|
@@ -848,20 +870,6 @@ with gr.Blocks(theme=gr.themes.Soft(), css=css) as demo:
|
|
848 |
queue=False
|
849 |
)
|
850 |
|
851 |
-
# ์์น ๋ฒํผ ์ด๋ฒคํธ
|
852 |
-
for btn, pos in [
|
853 |
-
(btn_top_left, "top-left"), (btn_top_center, "top-center"),
|
854 |
-
(btn_top_right, "top-right"), (btn_middle_left, "middle-left"),
|
855 |
-
(btn_middle_center, "middle-center"), (btn_middle_right, "middle-right"),
|
856 |
-
(btn_bottom_left, "bottom-left"), (btn_bottom_center, "bottom-center"),
|
857 |
-
(btn_bottom_right, "bottom-right")
|
858 |
-
]:
|
859 |
-
btn.click(
|
860 |
-
fn=lambda p=pos: p,
|
861 |
-
outputs=position,
|
862 |
-
queue=False
|
863 |
-
)
|
864 |
-
|
865 |
process_btn.click(
|
866 |
fn=process_prompt,
|
867 |
inputs=[
|
@@ -876,6 +884,7 @@ with gr.Blocks(theme=gr.themes.Soft(), css=css) as demo:
|
|
876 |
queue=True
|
877 |
)
|
878 |
|
|
|
879 |
add_text_btn.click(
|
880 |
fn=add_text_to_image,
|
881 |
inputs=[
|
@@ -888,15 +897,15 @@ with gr.Blocks(theme=gr.themes.Soft(), css=css) as demo:
|
|
888 |
y_position,
|
889 |
thickness,
|
890 |
text_position_type,
|
891 |
-
font_choice
|
892 |
],
|
893 |
outputs=combined_image
|
894 |
)
|
895 |
|
896 |
-
demo.queue(max_size=5)
|
897 |
demo.launch(
|
898 |
server_name="0.0.0.0",
|
899 |
server_port=7860,
|
900 |
share=False,
|
901 |
-
max_threads=2
|
902 |
)
|
|
|
826 |
</div>
|
827 |
""")
|
828 |
|
829 |
+
# ๊ฐ ๋ฒํผ์ ๋ํ ํด๋ฆญ ์ด๋ฒคํธ ์ฒ๋ฆฌ
|
830 |
+
def update_position(new_position):
|
831 |
+
return new_position
|
832 |
+
|
833 |
+
btn_top_left.click(fn=lambda: update_position("top-left"), outputs=position)
|
834 |
+
btn_top_center.click(fn=lambda: update_position("top-center"), outputs=position)
|
835 |
+
btn_top_right.click(fn=lambda: update_position("top-right"), outputs=position)
|
836 |
+
btn_middle_left.click(fn=lambda: update_position("middle-left"), outputs=position)
|
837 |
+
btn_middle_center.click(fn=lambda: update_position("middle-center"), outputs=position)
|
838 |
+
btn_middle_right.click(fn=lambda: update_position("middle-right"), outputs=position)
|
839 |
+
btn_bottom_left.click(fn=lambda: update_position("bottom-left"), outputs=position)
|
840 |
+
btn_bottom_center.click(fn=lambda: update_position("bottom-center"), outputs=position)
|
841 |
+
btn_bottom_right.click(fn=lambda: update_position("bottom-right"), outputs=position)
|
842 |
+
|
843 |
+
# Event bindings
|
844 |
input_image.change(
|
845 |
fn=update_process_button,
|
846 |
inputs=[input_image, text_prompt],
|
|
|
855 |
queue=False
|
856 |
)
|
857 |
|
858 |
+
def update_controls(bg_prompt):
|
859 |
+
"""๋ฐฐ๊ฒฝ ํ๋กฌํํธ ์
๋ ฅ ์ฌ๋ถ์ ๋ฐ๋ผ ์ปจํธ๋กค ํ์ ์
๋ฐ์ดํธ"""
|
860 |
+
is_visible = bool(bg_prompt)
|
861 |
+
return [
|
862 |
+
gr.update(visible=is_visible), # aspect_ratio
|
863 |
+
gr.update(visible=is_visible), # object_controls
|
864 |
+
]
|
865 |
+
|
866 |
bg_prompt.change(
|
867 |
fn=update_controls,
|
868 |
inputs=bg_prompt,
|
|
|
870 |
queue=False
|
871 |
)
|
872 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
873 |
process_btn.click(
|
874 |
fn=process_prompt,
|
875 |
inputs=[
|
|
|
884 |
queue=True
|
885 |
)
|
886 |
|
887 |
+
# ํ
์คํธ ์ถ๊ฐ ๋ฒํผ ์ด๋ฒคํธ ์ฐ๊ฒฐ ์์
|
888 |
add_text_btn.click(
|
889 |
fn=add_text_to_image,
|
890 |
inputs=[
|
|
|
897 |
y_position,
|
898 |
thickness,
|
899 |
text_position_type,
|
900 |
+
font_choice # ์๋ก์ด ์
๋ ฅ ์ถ๊ฐ
|
901 |
],
|
902 |
outputs=combined_image
|
903 |
)
|
904 |
|
905 |
+
demo.queue(max_size=5) # ํ ํฌ๊ธฐ ์ ํ
|
906 |
demo.launch(
|
907 |
server_name="0.0.0.0",
|
908 |
server_port=7860,
|
909 |
share=False,
|
910 |
+
max_threads=2 # ์ค๋ ๋ ์ ์ ํ
|
911 |
)
|