Update app.py
Browse files
app.py
CHANGED
|
@@ -13,7 +13,12 @@ B: ๋ ์ง์ง ์ ์ด๋?
|
|
| 13 |
"""
|
| 14 |
|
| 15 |
def run_pipeline(text, alpha, z, steps):
|
| 16 |
-
report, img_b64, struct = analyze_dialogue(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
img_md = f"" if img_b64 else ""
|
| 18 |
return report, img_md, str(struct)
|
| 19 |
|
|
@@ -22,7 +27,11 @@ with gr.Blocks() as demo:
|
|
| 22 |
gr.Markdown(INTRO)
|
| 23 |
|
| 24 |
with gr.Row():
|
| 25 |
-
text = gr.Textbox(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
with gr.Column():
|
| 27 |
alpha = gr.Slider(0.1, 0.9, value=0.4, step=0.05, label="EMA ฮฑ(์ค๋ฌด๋ฉ ๊ฐ๋)")
|
| 28 |
z = gr.Slider(1.0, 3.0, value=1.8, step=0.1, label="๊ธ๋ณ Z ์๊ณ๊ฐ")
|
|
@@ -34,11 +43,24 @@ with gr.Blocks() as demo:
|
|
| 34 |
img = gr.Markdown()
|
| 35 |
struct = gr.Textbox(label="๋๋ฒ๊ทธ/๊ตฌ์กฐ ๋ฐ์ดํฐ", lines=10)
|
| 36 |
|
| 37 |
-
#
|
| 38 |
-
btn.click(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
|
| 40 |
-
# โ
Queue๋ฅผ ๋ช
์์ ์ผ๋ก ์ผญ๋๋ค(Gradio ์๋ฒ๊ฐ ํ ๊ธฐ๋ฐ์ด๋ฉด gradio_client๊ฐ ํจ์ฌ ์์ ์ ).
|
| 41 |
-
# launch ์ง์ queue()๋ฅผ ๋ฐ๋์ ํธ์ถ.
|
| 42 |
if __name__ == "__main__":
|
| 43 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
demo.launch(server_name="0.0.0.0", server_port=7860, show_error=True)
|
|
|
|
| 13 |
"""
|
| 14 |
|
| 15 |
def run_pipeline(text, alpha, z, steps):
|
| 16 |
+
report, img_b64, struct = analyze_dialogue(
|
| 17 |
+
text,
|
| 18 |
+
smooth_alpha=alpha,
|
| 19 |
+
z_thresh=z,
|
| 20 |
+
forecast_steps=steps
|
| 21 |
+
)
|
| 22 |
img_md = f"" if img_b64 else ""
|
| 23 |
return report, img_md, str(struct)
|
| 24 |
|
|
|
|
| 27 |
gr.Markdown(INTRO)
|
| 28 |
|
| 29 |
with gr.Row():
|
| 30 |
+
text = gr.Textbox(
|
| 31 |
+
label="๋ํ ์
๋ ฅ",
|
| 32 |
+
lines=12,
|
| 33 |
+
value="A: ๋ ์ ๋ ๋ฆ์์ด?\nB: ๋ฏธ์ํด, ์ฐจ๊ฐ ๋งํ์ด.\nA: ๋ณ๋ช
ํ์ง ๋ง.\nB: ๋ ์ง์ง ์ ์ด๋?"
|
| 34 |
+
)
|
| 35 |
with gr.Column():
|
| 36 |
alpha = gr.Slider(0.1, 0.9, value=0.4, step=0.05, label="EMA ฮฑ(์ค๋ฌด๋ฉ ๊ฐ๋)")
|
| 37 |
z = gr.Slider(1.0, 3.0, value=1.8, step=0.1, label="๊ธ๋ณ Z ์๊ณ๊ฐ")
|
|
|
|
| 43 |
img = gr.Markdown()
|
| 44 |
struct = gr.Textbox(label="๋๋ฒ๊ทธ/๊ตฌ์กฐ ๋ฐ์ดํฐ", lines=10)
|
| 45 |
|
| 46 |
+
# REST ๋
ธ์ถ์ ์ํด api_name ์ ์ง
|
| 47 |
+
btn.click(
|
| 48 |
+
run_pipeline,
|
| 49 |
+
inputs=[text, alpha, z, steps],
|
| 50 |
+
outputs=[report, img, struct],
|
| 51 |
+
api_name="predict"
|
| 52 |
+
)
|
| 53 |
|
|
|
|
|
|
|
| 54 |
if __name__ == "__main__":
|
| 55 |
+
# Gradio ๋ฒ์ ์ฐจ์ด๋ฅผ ํก์ํ๋ queue() ํธ์ถ
|
| 56 |
+
try:
|
| 57 |
+
# gradio>=4 ๊ณ์ด
|
| 58 |
+
demo.queue(default_concurrency_limit=1, max_size=128)
|
| 59 |
+
except TypeError:
|
| 60 |
+
try:
|
| 61 |
+
# ์ผ๋ถ 3.x ๊ณ์ด
|
| 62 |
+
demo.queue(concurrency_count=1, max_size=128)
|
| 63 |
+
except TypeError:
|
| 64 |
+
# ๋ ๊ตฌ๋ฒ์ : ์ธ์ ์์ด
|
| 65 |
+
demo.queue()
|
| 66 |
demo.launch(server_name="0.0.0.0", server_port=7860, show_error=True)
|