Spaces:
Running
Running
kovacsvi
commited on
Commit
·
7924bcb
1
Parent(s):
32f8ddd
custom css
Browse files
app.py
CHANGED
@@ -13,6 +13,7 @@ import matplotlib.colors as mcolors
|
|
13 |
import plotly.express as px
|
14 |
import seaborn as sns
|
15 |
from tqdm import tqdm
|
|
|
16 |
|
17 |
PATH = '/data/' # at least 150GB storage needs to be attached
|
18 |
os.environ['TRANSFORMERS_CACHE'] = PATH
|
@@ -207,13 +208,13 @@ def predict_wrapper(text, language):
|
|
207 |
return results, figure, piechart, heatmap, output_info
|
208 |
|
209 |
|
210 |
-
with gr.Blocks() as demo:
|
211 |
placeholder = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."
|
212 |
introduction = """This platform is designed to detect and visualize emotions in text. The model behind it operates using a 6-label codebook, including the following labels: ‘Anger’, ‘Fear’, ‘Disgust’, ‘Sadness’, ‘Joy’, and ‘None of Them’.
|
213 |
The model is optimized for sentence-level analysis, and make predictions in the following languages: Czech, English, French, German, Hungarian, Polish, and Slovak.
|
214 |
The text you enter in the input box is automatically divided into sentences, and the analysis is performed on each sentence. Depending on the length of the text, this process may take a few seconds, but for longer texts, it can take up to 2-3 minutes.
|
215 |
"""
|
216 |
-
gr.Markdown(introduction)
|
217 |
with gr.Row():
|
218 |
with gr.Column():
|
219 |
input_text = gr.Textbox(lines=6, label="Input", placeholder="Enter your text here...")
|
@@ -227,13 +228,13 @@ with gr.Blocks() as demo:
|
|
227 |
with gr.Column(scale=7):
|
228 |
piechart = gr.Plot()
|
229 |
with gr.Column(scale=3):
|
230 |
-
gr.Markdown("The following pie chart shows the average probabilities of all emotions associated with the entire text.")
|
231 |
|
232 |
with gr.Row():
|
233 |
with gr.Column(scale=7):
|
234 |
plot = gr.Plot()
|
235 |
with gr.Column(scale=3):
|
236 |
-
gr.Markdown("The bar plot represents the relative frequency of emotion predictions at the sentence level.")
|
237 |
|
238 |
with gr.Row():
|
239 |
with gr.Column(scale=7):
|
@@ -243,13 +244,13 @@ with gr.Blocks() as demo:
|
|
243 |
wrap=True # important
|
244 |
)
|
245 |
with gr.Column(scale=3):
|
246 |
-
gr.Markdown("The table displays the predicted emotion and its confidence value for each sentence in the text.")
|
247 |
|
248 |
with gr.Row():
|
249 |
with gr.Column(scale=7):
|
250 |
heatmap = gr.Plot()
|
251 |
with gr.Column(scale=3):
|
252 |
-
gr.Markdown("The table displays the predicted emotion and its confidence value for each sentence in the text")
|
253 |
|
254 |
with gr.Row():
|
255 |
model_info = gr.Markdown()
|
|
|
13 |
import plotly.express as px
|
14 |
import seaborn as sns
|
15 |
from tqdm import tqdm
|
16 |
+
from utils import css
|
17 |
|
18 |
PATH = '/data/' # at least 150GB storage needs to be attached
|
19 |
os.environ['TRANSFORMERS_CACHE'] = PATH
|
|
|
208 |
return results, figure, piechart, heatmap, output_info
|
209 |
|
210 |
|
211 |
+
with gr.Blocks(css=css) as demo:
|
212 |
placeholder = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."
|
213 |
introduction = """This platform is designed to detect and visualize emotions in text. The model behind it operates using a 6-label codebook, including the following labels: ‘Anger’, ‘Fear’, ‘Disgust’, ‘Sadness’, ‘Joy’, and ‘None of Them’.
|
214 |
The model is optimized for sentence-level analysis, and make predictions in the following languages: Czech, English, French, German, Hungarian, Polish, and Slovak.
|
215 |
The text you enter in the input box is automatically divided into sentences, and the analysis is performed on each sentence. Depending on the length of the text, this process may take a few seconds, but for longer texts, it can take up to 2-3 minutes.
|
216 |
"""
|
217 |
+
gr.Markdown(introduction, elem_classes="info")
|
218 |
with gr.Row():
|
219 |
with gr.Column():
|
220 |
input_text = gr.Textbox(lines=6, label="Input", placeholder="Enter your text here...")
|
|
|
228 |
with gr.Column(scale=7):
|
229 |
piechart = gr.Plot()
|
230 |
with gr.Column(scale=3):
|
231 |
+
gr.Markdown("The following pie chart shows the average probabilities of all emotions associated with the entire text.", elem_classes="info")
|
232 |
|
233 |
with gr.Row():
|
234 |
with gr.Column(scale=7):
|
235 |
plot = gr.Plot()
|
236 |
with gr.Column(scale=3):
|
237 |
+
gr.Markdown("The bar plot represents the relative frequency of emotion predictions at the sentence level.", elem_classes="info")
|
238 |
|
239 |
with gr.Row():
|
240 |
with gr.Column(scale=7):
|
|
|
244 |
wrap=True # important
|
245 |
)
|
246 |
with gr.Column(scale=3):
|
247 |
+
gr.Markdown("The table displays the predicted emotion and its confidence value for each sentence in the text.", elem_classes="info")
|
248 |
|
249 |
with gr.Row():
|
250 |
with gr.Column(scale=7):
|
251 |
heatmap = gr.Plot()
|
252 |
with gr.Column(scale=3):
|
253 |
+
gr.Markdown("The table displays the predicted emotion and its confidence value for each sentence in the text", elem_classes="info")
|
254 |
|
255 |
with gr.Row():
|
256 |
model_info = gr.Markdown()
|
utils.py
CHANGED
@@ -27,4 +27,8 @@ def download_hf_models():
|
|
27 |
token=HF_TOKEN)
|
28 |
for tokenizer_id in tokenizers:
|
29 |
AutoTokenizer.from_pretrained(tokenizer_id)
|
|
|
|
|
|
|
|
|
30 |
|
|
|
27 |
token=HF_TOKEN)
|
28 |
for tokenizer_id in tokenizers:
|
29 |
AutoTokenizer.from_pretrained(tokenizer_id)
|
30 |
+
|
31 |
+
css = '''
|
32 |
+
.info {font-size: 3em; !important}
|
33 |
+
'''
|
34 |
|