Spaces:
Running
Running
kovacsvi
commited on
Commit
·
8ea1705
1
Parent(s):
44d3c68
markdown, radio buttons
Browse files
interfaces/cap_minor_media.py
CHANGED
@@ -139,10 +139,26 @@ def predict_cap(text, language, domain):
|
|
139 |
|
140 |
return predict(text, major_model_id, minor_model_id, tokenizer_id)
|
141 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
142 |
demo = gr.Interface(
|
143 |
title="CAP Media/Minor Topics Babel Demo",
|
144 |
fn=predict_cap,
|
145 |
-
inputs=[gr.
|
|
|
|
|
|
|
|
|
|
|
|
|
146 |
gr.Dropdown(languages, label="Language"),
|
147 |
gr.Dropdown(domains.keys(), label="Domain")],
|
148 |
outputs=[gr.Label(num_top_classes=5, label="Output"), gr.Markdown()])
|
|
|
139 |
|
140 |
return predict(text, major_model_id, minor_model_id, tokenizer_id)
|
141 |
|
142 |
+
description = """
|
143 |
+
You can choose between two approaches for making predictions:
|
144 |
+
|
145 |
+
1. **Hierarchical Classification**
|
146 |
+
First, the model predicts a **major topic**. Then, a second model selects the most probable **subtopic** from within that major topic's category.
|
147 |
+
|
148 |
+
2. **Flat Classification (single model)**
|
149 |
+
A single model directly predicts the most relevant label from all available classes, without distinguishing between major and subtopics.
|
150 |
+
"""
|
151 |
+
|
152 |
demo = gr.Interface(
|
153 |
title="CAP Media/Minor Topics Babel Demo",
|
154 |
fn=predict_cap,
|
155 |
+
inputs=[gr.Markdown(description)
|
156 |
+
gr.Radio(
|
157 |
+
choices=["Hierarchical Classification", "Flat Classification"],
|
158 |
+
label="Prediction Mode",
|
159 |
+
value="Hierarchical Classification"
|
160 |
+
)
|
161 |
+
gr.Textbox(lines=6, label="Input"),
|
162 |
gr.Dropdown(languages, label="Language"),
|
163 |
gr.Dropdown(domains.keys(), label="Domain")],
|
164 |
outputs=[gr.Label(num_top_classes=5, label="Output"), gr.Markdown()])
|