Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -55,12 +55,12 @@ with gr.Blocks(css=css) as demo:
|
|
| 55 |
gr.Markdown("### ๐ง ุชุฌุฑุจุฉ ู
ูุตุฉ ุงูุตุญุฉ ุงูููุณูุฉ", elem_classes="rtl")
|
| 56 |
text_input = gr.Textbox(label="ุฃุฏุฎู ุงููุต ููุง ูุชุญูููู", lines=7, elem_classes="rtl")
|
| 57 |
analyze_btn = gr.Button("ุงุจุฏุฃ ุงูุชุญููู", elem_classes="rtl")
|
|
|
|
| 58 |
output_text = gr.Textbox(label="ุงููุชูุฌุฉ", elem_classes="rtl", visible=True)
|
| 59 |
gr.Markdown(
|
| 60 |
"**โ ๏ธ ุชูุฏู
ูุฐู ุงูู
ูุตุฉ ุฏุนู
ูุง ููุณููุง ุขูููุงุ ูุง ุชูุนุฏ ุจุฏููุงู ุนู ุงูุชุดุฎูุตุ ุฃู ุงูุนูุงุฌุ ุฃู ุงูุงุณุชุดุงุฑุฉ ุงูุทุจูุฉ ุงูู
ุชุฎุตุตุฉ.**",
|
| 61 |
elem_classes="rtl"
|
| 62 |
)
|
| 63 |
-
output_table = gr.Dataframe(headers=["ุงููุต", "ุงูุชุตููู"], visible=False)
|
| 64 |
|
| 65 |
def toggle_classification(task_choice):
|
| 66 |
return gr.update(visible=(task_choice == "classification"))
|
|
@@ -112,19 +112,17 @@ with gr.Blocks(css=css) as demo:
|
|
| 112 |
result = analyze(text, task, classify)
|
| 113 |
|
| 114 |
if task == "entity_recognition":
|
| 115 |
-
if isinstance(result,
|
| 116 |
-
return gr.update(visible=False), gr.update(value="โ ๏ธ ูู
ูุชู
ุงูุชุนุฑู ุนูู ุฃู ููุงู", visible=True)
|
| 117 |
-
elif isinstance(result, list) and len(result) == 0:
|
| 118 |
-
return gr.update(visible=False), gr.update(value="โ ๏ธ ูู
ูุชู
ุงูุชุนุฑู ุนูู ุฃู ููุงู", visible=True)
|
| 119 |
-
else:
|
| 120 |
return gr.update(value=result, visible=True), gr.update(visible=False)
|
|
|
|
|
|
|
| 121 |
else:
|
| 122 |
-
return gr.update(
|
| 123 |
|
| 124 |
analyze_btn.click(
|
| 125 |
route_output,
|
| 126 |
inputs=[text_input, task_type, classify_type],
|
| 127 |
-
outputs=[
|
| 128 |
)
|
| 129 |
|
| 130 |
demo.launch()
|
|
|
|
| 55 |
gr.Markdown("### ๐ง ุชุฌุฑุจุฉ ู
ูุตุฉ ุงูุตุญุฉ ุงูููุณูุฉ", elem_classes="rtl")
|
| 56 |
text_input = gr.Textbox(label="ุฃุฏุฎู ุงููุต ููุง ูุชุญูููู", lines=7, elem_classes="rtl")
|
| 57 |
analyze_btn = gr.Button("ุงุจุฏุฃ ุงูุชุญููู", elem_classes="rtl")
|
| 58 |
+
output_table = gr.Dataframe(headers=["ุงููุต", "ุงูุชุตููู"], visible=False)
|
| 59 |
output_text = gr.Textbox(label="ุงููุชูุฌุฉ", elem_classes="rtl", visible=True)
|
| 60 |
gr.Markdown(
|
| 61 |
"**โ ๏ธ ุชูุฏู
ูุฐู ุงูู
ูุตุฉ ุฏุนู
ูุง ููุณููุง ุขูููุงุ ูุง ุชูุนุฏ ุจุฏููุงู ุนู ุงูุชุดุฎูุตุ ุฃู ุงูุนูุงุฌุ ุฃู ุงูุงุณุชุดุงุฑุฉ ุงูุทุจูุฉ ุงูู
ุชุฎุตุตุฉ.**",
|
| 62 |
elem_classes="rtl"
|
| 63 |
)
|
|
|
|
| 64 |
|
| 65 |
def toggle_classification(task_choice):
|
| 66 |
return gr.update(visible=(task_choice == "classification"))
|
|
|
|
| 112 |
result = analyze(text, task, classify)
|
| 113 |
|
| 114 |
if task == "entity_recognition":
|
| 115 |
+
if isinstance(result, list) and len(result) > 0:
|
|
|
|
|
|
|
|
|
|
|
|
|
| 116 |
return gr.update(value=result, visible=True), gr.update(visible=False)
|
| 117 |
+
else:
|
| 118 |
+
return gr.update(visible=False), gr.update(value="โ ๏ธ ูู
ูุชู
ุงูุชุนุฑู ุนูู ุฃู ููุงู", visible=True)
|
| 119 |
else:
|
| 120 |
+
return gr.update(visible=False), gr.update(value=result, visible=True)
|
| 121 |
|
| 122 |
analyze_btn.click(
|
| 123 |
route_output,
|
| 124 |
inputs=[text_input, task_type, classify_type],
|
| 125 |
+
outputs=[output_table, output_text] # โ
ุชุฑุชูุจ ุงูู
ุฎุฑุฌุงุช ุงูุตุญูุญ
|
| 126 |
)
|
| 127 |
|
| 128 |
demo.launch()
|