lunadebruyne commited on
Commit
082233a
·
verified ·
1 Parent(s): 0d305fd

Delete app2.py

Browse files
Files changed (1) hide show
  1. app2.py +0 -490
app2.py DELETED
@@ -1,490 +0,0 @@
1
- import gradio as gr
2
- import torch
3
- import numpy as np
4
- import pickle
5
-
6
- import pandas as pd
7
- from tqdm import tqdm
8
-
9
- import altair as alt
10
- import matplotlib.pyplot as plt
11
- from datetime import date, timedelta
12
-
13
- from transformers import AutoTokenizer, AutoConfig, AutoModel, AutoModelForSequenceClassification
14
-
15
- """
16
- description_sentence = "<h3>Demo EmotioNL</h3>\nThis demo allows you to analyse the emotion in a sentence."
17
- description_dataset = "<h3>Demo EmotioNL</h3>\nThis demo allows you to analyse the emotions in a dataset.\nThe data should be in tsv-format with two named columns: the first column (id) should contain the sentence IDs, and the second column (text) should contain the actual texts. Optionally, there is a third column named 'date', which specifies the date associated with the text (e.g., tweet date). This column is necessary when the options 'emotion distribution over time' and 'peaks' are selected."
18
-
19
- inference_modelpath = "model/checkpoint-128"
20
-
21
- def inference_sentence(text):
22
- tokenizer = AutoTokenizer.from_pretrained(inference_modelpath)
23
- model = AutoModelForSequenceClassification.from_pretrained(inference_modelpath)
24
- for text in tqdm([text]):
25
- inputs = tokenizer(text, return_tensors="pt")
26
- with torch.no_grad(): # run model
27
- logits = model(**inputs).logits
28
- predicted_class_id = logits.argmax().item()
29
- output = model.config.id2label[predicted_class_id]
30
- return output
31
-
32
- def frequencies(preds):
33
- preds_dict = {"neutral": 0, "anger": 0, "fear": 0, "joy": 0, "love": 0, "sadness": 0}
34
- for pred in preds:
35
- preds_dict[pred] = preds_dict[pred] + 1
36
- bars = list(preds_dict.keys())
37
- height = list(preds_dict.values())
38
-
39
- x_pos = np.arange(len(bars))
40
- plt.bar(x_pos, height, color=['lightgrey', 'firebrick', 'rebeccapurple', 'orange', 'palevioletred', 'cornflowerblue'])
41
- plt.xticks(x_pos, bars)
42
- return plt
43
-
44
- def inference_dataset(file_object, option_list):
45
- tokenizer = AutoTokenizer.from_pretrained(inference_modelpath)
46
- model = AutoModelForSequenceClassification.from_pretrained(inference_modelpath)
47
- data_path = open(file_object.name, 'r')
48
- df = pd.read_csv(data_path, delimiter='\t', header=0, names=['id', 'text'])
49
- ids = df["id"].tolist()
50
- texts = df["text"].tolist()
51
- preds = []
52
- for text in tqdm(texts): # progressbar
53
- inputs = tokenizer(text, return_tensors="pt")
54
- with torch.no_grad(): # run model
55
- logits = model(**inputs).logits
56
- predicted_class_id = logits.argmax().item()
57
- prediction = model.config.id2label[predicted_class_id]
58
- preds.append(prediction)
59
- predictions_content = list(zip(ids, texts, preds))
60
- # write predictions to file
61
- output = "output.txt"
62
- f = open(output, 'w')
63
- f.write("id\ttext\tprediction\n")
64
- for line in predictions_content:
65
- f.write(str(line[0]) + '\t' + str(line[1]) + '\t' + str(line[2]) + '\n')
66
- output1 = output
67
- output2 = output3 = output4 = output5 = "This option was not selected."
68
- if "emotion frequencies" in option_list:
69
- output2 = frequencies(preds)
70
- else:
71
- output2 = None
72
- if "emotion distribution over time" in option_list:
73
- output3 = "This option was selected."
74
- if "peaks" in option_list:
75
- output4 = "This option was selected."
76
- if "topics" in option_list:
77
- output5 = "This option was selected."
78
- return [output1, output2, output3, output4, output5]
79
-
80
- iface_sentence = gr.Interface(
81
- fn=inference_sentence,
82
- description = description_sentence,
83
- inputs = gr.Textbox(
84
- label="Enter a sentence",
85
- lines=1),
86
- outputs="text")
87
-
88
- inputs = [gr.File(
89
- label="Upload a dataset"),
90
- gr.CheckboxGroup(
91
- ["emotion frequencies", "emotion distribution over time", "peaks", "topics"],
92
- label = "Select options")]
93
-
94
- outputs = [gr.File(),
95
- gr.Plot(label="Emotion frequencies"),
96
- gr.Textbox(label="Emotion distribution over time"),
97
- gr.Textbox(label="Peaks"),
98
- gr.Textbox(label="Topics")]
99
-
100
- iface_dataset = gr.Interface(
101
- fn = inference_dataset,
102
- description = description_dataset,
103
- inputs=inputs,
104
- outputs = outputs)
105
-
106
- iface = gr.TabbedInterface([iface_sentence, iface_dataset], ["Sentence", "Dataset"])
107
-
108
- iface.queue().launch()
109
- """
110
-
111
- #inference_modelpath = "model/checkpoint-128"
112
-
113
- """
114
- def inference_sentence(text):
115
- tokenizer = AutoTokenizer.from_pretrained(inference_modelpath)
116
- model = AutoModelForSequenceClassification.from_pretrained(inference_modelpath)
117
- for text in tqdm([text]):
118
- inputs = tokenizer(text, return_tensors="pt")
119
- with torch.no_grad(): # run model
120
- logits = model(**inputs).logits
121
- predicted_class_id = logits.argmax().item()
122
- output = model.config.id2label[predicted_class_id]
123
- return "Predicted emotion:\n" + output
124
- """
125
- def inference_sentence(text):
126
- output = "This sentence will be processed:\n" + text
127
- return output
128
-
129
-
130
- def unavailable(input_file, input_checks):
131
- output = "As we are currently updating this demo, submitting your own data is unavailable for the moment. However, you can try out the showcase mode 😊"
132
- return gr.update(value=output, label="Oops!", visible=True)
133
-
134
- def showcase(input_file):
135
- output = "showcase/example_predictions.txt"
136
- return gr.update(visible=False), gr.update(value=output, visible=True), gr.update(visible=True), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False) # next_button_freq becomes available
137
-
138
- def file(input_file, input_checks):
139
- #output = "output.txt"
140
- #f = open(output, 'w')
141
- #f.write("The predictions come here.")
142
- #f.close()
143
- output = "showcase/example_predictions.txt"
144
- if "emotion frequencies" in input_checks:
145
- return gr.update(value=output, visible=True), gr.update(visible=True), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False) # next_button_freq becomes available
146
- elif "emotion distribution over time" in input_checks:
147
- return gr.update(value=output, visible=True), gr.update(visible=False), gr.update(visible=True), gr.update(visible=False), gr.update(visible=False) # next_button_dist becomes available
148
- elif "peaks" in input_checks:
149
- return gr.update(value=output, visible=True), gr.update(visible=False), gr.update(visible=False), gr.update(visible=True), gr.update(visible=False) # next_button_peaks becomes available
150
- elif "topics" in input_checks:
151
- return gr.update(value=output, visible=True), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), gr.update(visible=True) # next_button_topics becomes available
152
- else:
153
- return gr.update(value=output, visible=True), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False) # no next_button becomes available
154
-
155
- def freq(output_file, input_checks):
156
- #simple = pd.DataFrame({
157
- #'Emotion category': ['neutral', 'anger', 'fear', 'joy', 'love', 'sadness'],
158
- #'Frequency': [10, 8, 2, 15, 3, 4]})
159
-
160
- f = open("showcase/example_predictions.txt", 'r')
161
- data = f.read().split("\n")
162
- f.close()
163
- data = [line.split("\t") for line in data[1:-1]]
164
-
165
- freq_dict = {}
166
- for line in data:
167
- if line[1] not in freq_dict.keys():
168
- freq_dict[line[1]] = 1
169
- else:
170
- freq_dict[line[1]] += 1
171
-
172
- simple = pd.DataFrame({
173
- 'Emotion category': ['neutral', 'anger', 'fear', 'joy', 'love', 'sadness'],
174
- 'Frequency': [freq_dict['neutral'], freq_dict['anger'], freq_dict['fear'], freq_dict['joy'], freq_dict['love'], freq_dict['sadness']]})
175
-
176
- domain = ['neutral', 'anger', 'fear', 'joy', 'love', 'sadness']
177
- range_ = ['#999999', '#b22222', '#663399', '#ffcc00', '#db7093', '#6495ed']
178
- n = max(simple['Frequency'])
179
-
180
- plot = alt.Chart(simple).mark_bar().encode(
181
- x=alt.X("Emotion category", sort=['neutral', 'anger', 'fear', 'joy', 'love', 'sadness']),
182
- y=alt.Y("Frequency", axis=alt.Axis(grid=False), scale=alt.Scale(domain=[0, (n + 9) // 10 * 10])),
183
- color=alt.Color("Emotion category", scale=alt.Scale(domain=domain, range=range_), legend=None),
184
- tooltip=['Emotion category', 'Frequency']).properties(
185
- width=600).configure_axis(
186
- grid=False).interactive()
187
-
188
- if "emotion distribution over time" in input_checks or (output_file.name).startswith('/tmp/example_predictions'):
189
- return gr.update(value=plot, visible=True), gr.update(visible=True), gr.update(visible=False), gr.update(visible=False) # next_button_dist becomes available
190
- elif "peaks" in input_checks:
191
- return gr.update(value=plot, visible=True), gr.update(visible=False), gr.update(visible=True), gr.update(visible=False) # next_button_peaks becomes available
192
- elif "topics" in input_checks:
193
- return gr.update(value=plot, visible=True), gr.update(visible=False), gr.update(visible=False), gr.update(visible=True) # next_button_topics becomes available
194
- else:
195
- return gr.update(value=plot, visible=True), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False) # no next_button becomes available
196
-
197
-
198
- def dist(output_file, input_checks):
199
- #data = pd.DataFrame({
200
- #'Date': ['1/1', '1/1', '1/1', '1/1', '1/1', '1/1', '2/1', '2/1', '2/1', '2/1', '2/1', '2/1', '3/1', '3/1', '3/1', '3/1', '3/1', '3/1'],
201
- #'Frequency': [3, 5, 1, 8, 2, 3, 4, 7, 1, 12, 4, 2, 3, 6, 3, 10, 3, 4],
202
- #'Emotion category': ['neutral', 'anger', 'fear', 'joy', 'love', 'sadness', 'neutral', 'anger', 'fear', 'joy', 'love', 'sadness', 'neutral', 'anger', 'fear', 'joy', 'love', 'sadness']})
203
-
204
- f = open("showcase/data.txt", 'r')
205
- data = f.read().split("\n")
206
- f.close()
207
- data = [line.split("\t") for line in data[1:-1]]
208
-
209
- freq_dict = {}
210
- for line in data:
211
- dat = str(date(2000+int(line[0].split("/")[2]), int(line[0].split("/")[1]), int(line[0].split("/")[0])))
212
- if dat not in freq_dict.keys():
213
- freq_dict[dat] = {}
214
- if line[1] not in freq_dict[dat].keys():
215
- freq_dict[dat][line[1]] = 1
216
- else:
217
- freq_dict[dat][line[1]] += 1
218
- else:
219
- if line[1] not in freq_dict[dat].keys():
220
- freq_dict[dat][line[1]] = 1
221
- else:
222
- freq_dict[dat][line[1]] += 1
223
-
224
- start_date = date(2000+int(data[0][0].split("/")[2]), int(data[0][0].split("/")[1]), int(data[0][0].split("/")[0]))
225
- end_date = date(2000+int(data[-1][0].split("/")[2]), int(data[-1][0].split("/")[1]), int(data[-1][0].split("/")[0]))
226
- delta = end_date - start_date # returns timedelta
227
- date_range = [str(start_date + timedelta(days=i)) for i in range(delta.days + 1)]
228
-
229
- dates = [dat for dat in date_range for i in range(6)]
230
- frequency = [freq_dict[dat][emotion] if (dat in freq_dict.keys() and emotion in freq_dict[dat].keys()) else 0 for dat in date_range for emotion in ['neutral', 'anger', 'fear', 'joy', 'love', 'sadness']]
231
- categories = [emotion for dat in date_range for emotion in ['neutral', 'anger', 'fear', 'joy', 'love', 'sadness']]
232
-
233
- data = pd.DataFrame({
234
- 'Date': dates,
235
- 'Frequency': frequency,
236
- 'Emotion category': categories})
237
-
238
- domain = ['neutral', 'anger', 'fear', 'joy', 'love', 'sadness']
239
- range_ = ['#999999', '#b22222', '#663399', '#ffcc00', '#db7093', '#6495ed']
240
- n = max(data['Frequency'])
241
-
242
- highlight = alt.selection(
243
- type='single', on='mouseover', fields=["Emotion category"], nearest=True)
244
-
245
-
246
- base = alt.Chart(data).encode(
247
- x ="Date:T",
248
- y=alt.Y("Frequency", scale=alt.Scale(domain=[0, (n + 9) // 10 * 10])),
249
- color=alt.Color("Emotion category", scale=alt.Scale(domain=domain, range=range_), legend=alt.Legend(orient='bottom', direction='horizontal')))
250
-
251
-
252
- points = base.mark_circle().encode(
253
- opacity=alt.value(0),
254
- tooltip=[
255
- alt.Tooltip('Emotion category', title='Emotion category'),
256
- alt.Tooltip('Date:T', title='Date'),
257
- alt.Tooltip('Frequency', title='Frequency')
258
- ]).add_selection(highlight)
259
-
260
-
261
- lines = base.mark_line().encode(
262
- size=alt.condition(~highlight, alt.value(1), alt.value(3)))
263
-
264
- plot = (points + lines).properties(width=600, height=350).interactive()
265
-
266
- if "peaks" in input_checks or (output_file.name).startswith('/tmp/example_predictions'):
267
- return gr.Plot.update(value=plot, visible=True), gr.update(visible=True), gr.update(visible=False) # next_button_peaks becomes available
268
- elif "topics" in input_checks:
269
- return gr.Plot.update(value=plot, visible=True), gr.update(visible=False), gr.update(visible=True) # next_button_topics becomes available
270
- else:
271
- return gr.Plot.update(value=plot, visible=True), gr.update(visible=False), gr.update(visible=False) # no next_button becomes available
272
-
273
- def peaks(output_file, input_checks):
274
- plot = pickle.load(open('showcase/peaks_covid.p', 'rb'))
275
- if "topics" in input_checks or (output_file.name).startswith('/tmp/example_predictions'):
276
- return gr.Plot.update(value=plot, visible=True), gr.update(visible=True) # next_button_topics becomes available
277
- else:
278
- return gr.Plot.update(value=plot, visible=True), gr.update(visible=False) # no next_button becomes available
279
-
280
- def peaks2(output_file, input_checks):
281
- peaks_anger = {"9/2/2020": "up", "18/2/2020": "down", "8/3/2020": "up", "20/3/2020": "up", "31/5/2020": "up", "6/6/2020": "up", "19/6/2020": "up", "19/7/2020": "up"}
282
- peaks_fear = {"8/2/2020": "up", "11/2/2020": "down", "31/5/2020": "down", "12/6/2020": "up", "5/7/2020": "up", "19/7/2020": "up"}
283
- peaks_joy = {"13/3/2020": "up", "4/4/2020": "up", "19/6/2020": "up", "26/6/2020": "up"}
284
- peaks_love = {"12/3/2020": "up", "5/5/2020": "down", "26/6/2020": "up", "7/8/2020": "up",}
285
- peaks_sadness = {"14/2/2020": "up", "3/4/2020": "up", "5/5/2020": "down", "18/5/2020": "down", "30/6/2020": "up", "5/7/2020": "up"}
286
-
287
- text_anger = ", ".join([str(key) + " (↑)" if value == "up" else str(key) + " (↓)" for key, value in peaks_anger.items()])
288
- text_fear = ", ".join([str(key) + " (↑)" if value == "up" else str(key) + " (↓)" for key, value in peaks_fear.items()])
289
- text_joy = ", ".join([str(key) + " (↑)" if value == "up" else str(key) + " (↓)" for key, value in peaks_joy.items()])
290
- text_love = ", ".join([str(key) + " (↑)" if value == "up" else str(key) + " (↓)" for key, value in peaks_love.items()])
291
- text_sadness = ", ".join([str(key) + " (↑)" if value == "up" else str(key) + " (↓)" for key, value in peaks_sadness.items()])
292
-
293
- html = (
294
- '<html>'
295
- '<head>'
296
- '<meta name="viewport" content="width=device-width, initial-scale=1">'
297
- '<style>'
298
- '.dot_neutral {'
299
- 'height: 11px;'
300
- 'width: 11px;'
301
- 'background-color: #999999;'
302
- 'border-radius: 50%;'
303
- 'display: inline-block;'
304
- '}'
305
- '.dot_anger {'
306
- 'height: 11px;'
307
- 'width: 11px;'
308
- 'background-color: #b22222;'
309
- 'border-radius: 50%;'
310
- 'display: inline-block;'
311
- '}'
312
- '.dot_fear {'
313
- 'height: 11px;'
314
- 'width: 11px;'
315
- 'background-color: #663399;'
316
- 'border-radius: 50%;'
317
- 'display: inline-block;'
318
- '}'
319
- '.dot_joy {'
320
- 'height: 11px;'
321
- 'width: 11px;'
322
- 'background-color: #ffcc00;'
323
- 'border-radius: 50%;'
324
- 'display: inline-block;'
325
- '}'
326
- '.dot_love {'
327
- 'height: 11px;'
328
- 'width: 11px;'
329
- 'background-color: #db7093;'
330
- 'border-radius: 50%;'
331
- 'display: inline-block;'
332
- '}'
333
- '.dot_sadness {'
334
- 'height: 11px;'
335
- 'width: 11px;'
336
- 'background-color: #6495ed;'
337
- 'border-radius: 50%;'
338
- 'display: inline-block;'
339
- '}'
340
- '.tab {'
341
- 'padding-left: 1em;'
342
- '}'
343
- '</style>'
344
- '</head>'
345
- '<body>'
346
- '<div>'
347
- '<p>These significant fluctuations were found:</p>'
348
- '<p><span class="dot_anger"></span> anger:</p>'
349
- '<p class="tab">' + text_anger + '<p>'
350
- '<p><span class="dot_fear"></span> fear:</p>'
351
- '<p class="tab">' + text_fear + '<p>'
352
- '<p><span class="dot_joy"></span> joy:</p>'
353
- '<p class="tab">' + text_joy + '<p>'
354
- '<p><span class="dot_love"></span> love:</p>'
355
- '<p class="tab">' + text_love + '<p>'
356
- '<p><span class="dot_sadness"></span> sadness:</p>'
357
- '<p class="tab">' + text_sadness + '<p>'
358
- '</div>'
359
- '</body>'
360
- '</html>'
361
- )
362
- if "topics" in input_checks or (output_file.name).startswith('/tmp/example_predictions'):
363
- return gr.update(value=html, visible=True), gr.update(visible=True) # next_button_topics becomes available
364
- else:
365
- return gr.update(value=html, visible=True), gr.update(visible=False) # no next_button becomes available
366
-
367
- def topics(output_file, input_checks):
368
- plot = pickle.load(open('showcase/vis_classes_covid.p', 'rb'))
369
- plot.update_layout(width=600, height=400)
370
- return gr.Plot.update(value=plot, visible=True) # no next_button becomes available
371
-
372
-
373
- with gr.Blocks() as demo:
374
- with gr.Row():
375
- with gr.Column(scale=1, min_width=100):
376
- gr.Markdown("""
377
- """)
378
- with gr.Column(scale=5, min_width=500):
379
- gr.Markdown("""
380
- <div style="text-align: center"><h1>EmotioNL: A framework for Dutch emotion detection</h1></div>
381
-
382
- <div style="display: block;margin-left: auto;margin-right: auto;width: 60%;"><img alt="EmotioNL logo" src="https://users.ugent.be/~lundbruy/EmotioNL.png" width="100%"></div>
383
-
384
- This demo was made to demonstrate the EmotioNL model, a transformer-based classification model that analyses emotions in Dutch texts. The model uses [RobBERT](https://github.com/iPieter/RobBERT), which was further fine-tuned on the [EmotioNL dataset](https://lt3.ugent.be/resources/emotionl/). The resulting model is a classifier that, given a sentence, predicts one of the following emotion categories: _anger_, _fear_, _joy_, _love_, _sadness_ or _neutral_. The demo can be used either in **sentence mode**, which allows you to enter a sentence for which an emotion will be predicted; or in **dataset mode**, which allows you to upload a dataset or see the full functuonality of with example data.
385
- """)
386
- with gr.Column(scale=1, min_width=100):
387
- gr.Markdown("""
388
- """)
389
- with gr.Row():
390
- with gr.Column(scale=1, min_width=100):
391
- gr.Markdown("""
392
- """)
393
- with gr.Column(scale=5, min_width=500):
394
- with gr.Tab("Sentence"):
395
- gr.Markdown("""
396
- """)
397
- with gr.Row():
398
- with gr.Column():
399
- input = gr.Textbox(
400
- label="Enter a sentence",
401
- value="Jaaah! Volgende vakantie Barcelona en na het zomerseizoen naar de Algarve",
402
- lines=1)
403
- send_btn = gr.Button("Send")
404
- output = gr.Textbox()
405
- send_btn.click(fn=inference_sentence, inputs=input, outputs=output)
406
-
407
- with gr.Tab("Dataset"):
408
- gr.Markdown("""
409
- _As we are currently updating this demo, submitting your own data is unavailable for the moment._
410
- _Try out the showcase mode._
411
- """)
412
- with gr.Row():
413
- with gr.Column(scale=0.75):
414
- demo_btn = gr.Button("Showcase with example data", variant="primary")
415
- with gr.Column(scale=1):
416
- gr.Markdown("""
417
- #### Run in showcase mode or use your own data
418
- Try out the demo in showcase mode, which uses example data (609,206 tweets about the COVID-19 pandemic) with all the options provided by the demo, or upload your own dataset.
419
- """)
420
- with gr.Row():
421
- with gr.Column(scale=0.75):
422
- input_file = gr.File(
423
- label="Upload a dataset")
424
- input_checks = gr.CheckboxGroup(
425
- ["emotion frequencies", "emotion distribution over time", "peaks", "topics"],
426
- label = "Select options")
427
- send_btn = gr.Button("Submit data")
428
- with gr.Column(scale=1):
429
- gr.Markdown("""
430
- #### Data format
431
- The data should be in tsv-format with two named columns: the first column (id) should contain the sentence IDs, and the second column (text) should contain the actual texts. Optionally, there is a third column named 'date', which specifies the date associated with the text (e.g., tweet date). This column is necessary when the options 'emotion distribution over time' and 'peaks' are selected. For now, we only accept files with maximum 400 sentences and a limit of 300 tokens per sentence.
432
-
433
- #### Options
434
- **Emotion frequencies** outputs a bar plot with the prediction frequencies of each emotion category (anger, fear, joy, love, sadness or neutral).
435
- **Emotion distribution over time** outputs a line plot that visualises the frequency of predicted emotions over time for each emotion category.
436
- **Peaks** outputs a step graph that only shows the significant fluctuations (upwards and downwards) in emotion frequencies over time.
437
- **Topics** uses [BERTopic](https://maartengr.github.io/BERTopic/index.html) to find topics in the datasets, and outputs a bar plot that shows the emotion distribution per topic.
438
- """)
439
- with gr.Row():
440
- with gr.Column():
441
- gr.Markdown("""
442
- ___
443
- """)
444
- with gr.Row():
445
- with gr.Column():
446
- output_markdown = gr.Markdown("""
447
- ### Output
448
- """, visible=False)
449
-
450
- message = gr.Textbox(label="Message", visible=False)
451
-
452
- output_file = gr.File(label="Predictions", visible=False)
453
- next_button_freq = gr.Button("Show emotion frequencies", visible=False)
454
-
455
- output_plot = gr.Plot(show_label=False, visible=False).style(container=True)
456
- next_button_dist = gr.Button("Show emotion distribution over time", visible=False)
457
-
458
- output_dist = gr.Plot(show_label=False, visible=False)
459
- next_button_peaks = gr.Button("Show peaks", visible=False)
460
-
461
- output_peaks = gr.Plot(visible=False)
462
- next_button_topics = gr.Button("Show topics", visible=False)
463
-
464
- output_topics = gr.Plot(show_label=False, visible=False)
465
-
466
- #send_btn.click(fn=file, inputs=[input_file,input_checks], outputs=[output_file,next_button_freq,next_button_dist,next_button_peaks,next_button_topics])
467
- next_button_freq.click(fn=freq, inputs=[output_file,input_checks], outputs=[output_plot,next_button_dist,next_button_peaks,next_button_topics])
468
- next_button_dist.click(fn=dist, inputs=[output_file,input_checks], outputs=[output_dist,next_button_peaks,next_button_topics])
469
- next_button_peaks.click(fn=peaks, inputs=[output_file,input_checks], outputs=[output_peaks,next_button_topics])
470
- next_button_topics.click(fn=topics, inputs=[output_file,input_checks], outputs=output_topics)
471
- send_btn.click(fn=unavailable, inputs=[input_file,input_checks], outputs=[output_markdown,message])
472
- demo_btn.click(fn=showcase, inputs=[input_file], outputs=[output_markdown,message,output_file,next_button_freq,next_button_dist,next_button_peaks,next_button_topics])
473
- with gr.Column(scale=1, min_width=100):
474
- gr.Markdown("""
475
- """)
476
-
477
- with gr.Row():
478
- with gr.Column(scale=1, min_width=100):
479
- gr.Markdown("""
480
- """)
481
- with gr.Column(scale=5, min_width=500):
482
- gr.Markdown("""
483
- <font size="2">Both this demo and the dataset have been created by [LT3](https://lt3.ugent.be/), the Language and Translation Technology Team of Ghent University. The EmotioNL project has been carried out with support from the Research Foundation – Flanders (FWO). For any questions, please contact luna.debruyne@ugent.be.</font>
484
-
485
- <div style="display: flex"><img style="margin-right: 1em" alt="LT3 logo" src="https://lt3.ugent.be/static/images/logo_v2_single.png" width="136" height="58"> <img style="margin-right: 1em" alt="FWO logo" src="https://www.fwo.be/images/logo_desktop.png" height="58"></div>
486
- """)
487
- with gr.Column(scale=1, min_width=100):
488
- gr.Markdown("""
489
- """)
490
- demo.launch()