Spaces:
Sleeping
Sleeping
lorenzoscottb
commited on
Commit
•
40d1f52
1
Parent(s):
29ba5d9
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import os
|
3 |
+
|
4 |
+
path_to_L_model = str(os.environ['path_to_L_model'])
|
5 |
+
path_to_S_model = str(os.environ['path_to_S_model'])
|
6 |
+
read_token = str(os.environ['read_token'])
|
7 |
+
|
8 |
+
title = "DSA II"
|
9 |
+
|
10 |
+
description_main = """
|
11 |
+
A set of models to perform sentiment analysis. Choose between Large-Multilingual or Small-En-only.
|
12 |
+
"""
|
13 |
+
|
14 |
+
description_L = """
|
15 |
+
XLM-R tuned model, EN-tuned, pre-trained with 94 languages available (see original model [card](https://huggingface.co/xlm-roberta-large) to see which are available)
|
16 |
+
"""
|
17 |
+
|
18 |
+
description_S = """
|
19 |
+
A tuned BERT-base-cased model.
|
20 |
+
"""
|
21 |
+
|
22 |
+
examples = [
|
23 |
+
["I was followed by the blue monster but was not scared. I was calm and relaxed."],
|
24 |
+
["Ero seguito dal mostro blu, ma non ero spaventato. Ero calmo e rilassato."],
|
25 |
+
["Śledził mnie niebieski potwór, ale się nie bałem. Byłem spokojny i zrelaksowany."],
|
26 |
+
]
|
27 |
+
|
28 |
+
interface_words = gr.Interface(
|
29 |
+
fn=None,
|
30 |
+
description=description_main,
|
31 |
+
)
|
32 |
+
|
33 |
+
interface_model_L = gr.Interface.load(
|
34 |
+
name=path_to_L_model,
|
35 |
+
description=description_L,
|
36 |
+
examples=examples,
|
37 |
+
title=title,
|
38 |
+
api_key=read_token,
|
39 |
+
)
|
40 |
+
|
41 |
+
interface_model_S = gr.Interface.load(
|
42 |
+
name=path_to_S_model,
|
43 |
+
description=description_S,
|
44 |
+
examples=examples[0],
|
45 |
+
title=title,
|
46 |
+
api_key=read_token,
|
47 |
+
)
|
48 |
+
|
49 |
+
gr.TabbedInterface(
|
50 |
+
[interface_words, interface_model_L, interface_model_S],
|
51 |
+
["Intro", "Large Multilingual", "Base En"]
|
52 |
+
).launch()
|