Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -71,43 +71,24 @@ def predict_kc(content_html: str):
|
|
| 71 |
label = predict_nb_count([text])[0]
|
| 72 |
return label
|
| 73 |
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
with gr.Blocks(css=css) as demo:
|
| 97 |
-
gr.Markdown("## NBC KC Predictor")
|
| 98 |
-
gr.Markdown("Nhập HTML Content (HTML) và nhấn Enter để dự đoán mã KC.")
|
| 99 |
-
with gr.Column():
|
| 100 |
-
input_box = gr.Textbox(
|
| 101 |
-
lines=6,
|
| 102 |
-
placeholder="Dán HTML Content…",
|
| 103 |
-
label="Nội dung câu hỏi",
|
| 104 |
-
elem_id="input-box"
|
| 105 |
-
)
|
| 106 |
-
output_box = gr.Label(
|
| 107 |
-
label="Mã KC dự đoán",
|
| 108 |
-
elem_id="output-box"
|
| 109 |
-
)
|
| 110 |
-
# Kết nối sự kiện: khi input thay đổi, chạy predict
|
| 111 |
-
input_box.submit(fn=predict_kc, inputs=input_box, outputs=output_box)
|
| 112 |
-
|
| 113 |
-
demo.launch()
|
|
|
|
| 71 |
label = predict_nb_count([text])[0]
|
| 72 |
return label
|
| 73 |
|
| 74 |
+
css = """
|
| 75 |
+
textarea { font-size: 18px !important; }
|
| 76 |
+
.gradio-container .output-text { font-size: 18px !important; }
|
| 77 |
+
"""
|
| 78 |
|
| 79 |
+
interface = gr.Interface(
|
| 80 |
+
fn = predict_kc,
|
| 81 |
+
inputs = gr.Textbox(lines=6,
|
| 82 |
+
placeholder="Dán nội dung câu hỏi dạng HTML",
|
| 83 |
+
label="Nội dung câu hỏi ",
|
| 84 |
+
elem_id="input-box"),
|
| 85 |
+
outputs = gr.Textbox(label="KC dự đoán",
|
| 86 |
+
elem_id="output-box"),
|
| 87 |
+
title = "Demo dự đoán KC",
|
| 88 |
+
description="Dự đoán nhãn KC từ câu hỏi dựa trên Naive Bayes.",
|
| 89 |
+
css=css,
|
| 90 |
+
allow_flagging="never"
|
| 91 |
+
)
|
| 92 |
|
| 93 |
+
if __name__ == "__main__":
|
| 94 |
+
interface.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|