Spaces:
Running
Running
vkovacs
commited on
Commit
·
624dc37
1
Parent(s):
baacdbb
missing dropdown
Browse files- interfaces/emotion.py +6 -2
interfaces/emotion.py
CHANGED
@@ -14,6 +14,9 @@ HF_TOKEN = os.environ["hf_read"]
|
|
14 |
languages = [
|
15 |
"Czech", "English", "French", "German", "Hungarian", "Italian"
|
16 |
]
|
|
|
|
|
|
|
17 |
|
18 |
def build_huggingface_path(language: str):
|
19 |
return "poltextlab/xlm-roberta-large-pooled-emotions"
|
@@ -39,7 +42,7 @@ def predict(text, model_id, tokenizer_id):
|
|
39 |
output_info = f'<p style="text-align: center; display: block">Prediction was made using the <a href="https://huggingface.co/{model_id}">{model_id}</a> model.</p>'
|
40 |
return output_pred, output_info
|
41 |
|
42 |
-
def predict_cap(text, language):
|
43 |
model_id = build_huggingface_path(language)
|
44 |
tokenizer_id = "xlm-roberta-large"
|
45 |
return predict(text, model_id, tokenizer_id)
|
@@ -47,5 +50,6 @@ def predict_cap(text, language):
|
|
47 |
demo = gr.Interface(
|
48 |
fn=predict_cap,
|
49 |
inputs=[gr.Textbox(lines=6, label="Input"),
|
50 |
-
gr.Dropdown(languages, label="Language")
|
|
|
51 |
outputs=[gr.Label(num_top_classes=5, label="Output"), gr.Markdown()])
|
|
|
14 |
languages = [
|
15 |
"Czech", "English", "French", "German", "Hungarian", "Italian"
|
16 |
]
|
17 |
+
domains = {
|
18 |
+
"parliamentary speech": "parlspeech",
|
19 |
+
}
|
20 |
|
21 |
def build_huggingface_path(language: str):
|
22 |
return "poltextlab/xlm-roberta-large-pooled-emotions"
|
|
|
42 |
output_info = f'<p style="text-align: center; display: block">Prediction was made using the <a href="https://huggingface.co/{model_id}">{model_id}</a> model.</p>'
|
43 |
return output_pred, output_info
|
44 |
|
45 |
+
def predict_cap(text, language, domain):
|
46 |
model_id = build_huggingface_path(language)
|
47 |
tokenizer_id = "xlm-roberta-large"
|
48 |
return predict(text, model_id, tokenizer_id)
|
|
|
50 |
demo = gr.Interface(
|
51 |
fn=predict_cap,
|
52 |
inputs=[gr.Textbox(lines=6, label="Input"),
|
53 |
+
gr.Dropdown(languages, label="Language"),
|
54 |
+
gr.Dropdown(domains.keys(), label="Domain")],
|
55 |
outputs=[gr.Label(num_top_classes=5, label="Output"), gr.Markdown()])
|