lunadebruyne commited on
Commit
4c15c1a
·
1 Parent(s): cbb22ed

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -19
app.py CHANGED
@@ -371,10 +371,10 @@ def topics(output_file, input_checks):
371
 
372
  with gr.Blocks() as demo:
373
  with gr.Row():
374
- with gr.Column(scale=1, min_width=50):
375
  gr.Markdown("""
376
  """)
377
- with gr.Column(scale=6):
378
  gr.Markdown("""
379
  <div style="text-align: center"><h1>EmotioNL: A framework for Dutch emotion detection</h1></div>
380
 
@@ -382,14 +382,14 @@ with gr.Blocks() as demo:
382
 
383
  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.
384
  """)
385
- with gr.Column(scale=1, min_width=50):
386
  gr.Markdown("""
387
  """)
388
  with gr.Row():
389
- with gr.Column(scale=1, min_width=50):
390
  gr.Markdown("""
391
  """)
392
- with gr.Column(scale=6):
393
  with gr.Tab("Sentence"):
394
  gr.Markdown("""
395
  """)
@@ -405,9 +405,17 @@ with gr.Blocks() as demo:
405
 
406
  with gr.Tab("Dataset"):
407
  gr.Markdown("""
408
- _As we are currently updating this demo, submitting your own data is unavailable for the moment._
409
  _Try out the showcase mode._
410
  """)
 
 
 
 
 
 
 
 
411
  with gr.Row():
412
  with gr.Column(scale=0.75):
413
  input_file = gr.File(
@@ -416,20 +424,16 @@ with gr.Blocks() as demo:
416
  ["emotion frequencies", "emotion distribution over time", "peaks", "topics"],
417
  label = "Select options")
418
  send_btn = gr.Button("Submit data")
419
- demo_btn = gr.Button("Showcase with example data", variant="primary")
420
  with gr.Column(scale=1):
421
  gr.Markdown("""
422
  #### Data format
423
  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.
424
 
425
  #### Options
426
- **Emotion frequencies** outputs a bar plot with the prediction frequencies of each emotion category (anger, fear, joy, love, sadness or neutral).
427
- **Emotion distribution over time** outputs a line plot that visualises the frequency of predicted emotions over time for each emotion category.
428
- **Peaks** outputs a step graph that only shows the significant fluctuations (upwards and downwards) in emotion frequencies over time.
429
- **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.
430
-
431
- #### Run in showcase mode or use your own data
432
- 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.
433
  """)
434
  with gr.Row():
435
  with gr.Column():
@@ -465,22 +469,21 @@ with gr.Blocks() as demo:
465
  next_button_topics.click(fn=topics, inputs=[output_file,input_checks], outputs=output_topics)
466
  send_btn.click(fn=unavailable, inputs=[input_file,input_checks], outputs=[output_markdown,message])
467
  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])
468
- with gr.Column(scale=1, min_width=50):
469
  gr.Markdown("""
470
  """)
471
-
472
 
473
  with gr.Row():
474
- with gr.Column(scale=1, min_width=50):
475
  gr.Markdown("""
476
  """)
477
- with gr.Column(scale=6):
478
  gr.Markdown("""
479
  <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 [email protected].</font>
480
 
481
  <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>
482
  """)
483
- with gr.Column(scale=1, min_width=50):
484
  gr.Markdown("""
485
  """)
486
  demo.launch()
 
371
 
372
  with gr.Blocks() as demo:
373
  with gr.Row():
374
+ with gr.Column(scale=1, min_width=100):
375
  gr.Markdown("""
376
  """)
377
+ with gr.Column(scale=5, min_width=500):
378
  gr.Markdown("""
379
  <div style="text-align: center"><h1>EmotioNL: A framework for Dutch emotion detection</h1></div>
380
 
 
382
 
383
  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.
384
  """)
385
+ with gr.Column(scale=1, min_width=100):
386
  gr.Markdown("""
387
  """)
388
  with gr.Row():
389
+ with gr.Column(scale=1, min_width=100):
390
  gr.Markdown("""
391
  """)
392
+ with gr.Column(scale=5, min_width=500):
393
  with gr.Tab("Sentence"):
394
  gr.Markdown("""
395
  """)
 
405
 
406
  with gr.Tab("Dataset"):
407
  gr.Markdown("""
408
+ _As we are currently updating this demo, submitting your own data is unavailable for the moment._
409
  _Try out the showcase mode._
410
  """)
411
+ with gr.Row():
412
+ with gr.Column(scale=0.75):
413
+ demo_btn = gr.Button("Showcase with example data", variant="primary")
414
+ with gr.Column(scale=1):
415
+ gr.Markdown("""
416
+ #### Run in showcase mode or use your own data
417
+ 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.
418
+ """)
419
  with gr.Row():
420
  with gr.Column(scale=0.75):
421
  input_file = gr.File(
 
424
  ["emotion frequencies", "emotion distribution over time", "peaks", "topics"],
425
  label = "Select options")
426
  send_btn = gr.Button("Submit data")
 
427
  with gr.Column(scale=1):
428
  gr.Markdown("""
429
  #### Data format
430
  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.
431
 
432
  #### Options
433
+ **Emotion frequencies** outputs a bar plot with the prediction frequencies of each emotion category (anger, fear, joy, love, sadness or neutral).
434
+ **Emotion distribution over time** outputs a line plot that visualises the frequency of predicted emotions over time for each emotion category.
435
+ **Peaks** outputs a step graph that only shows the significant fluctuations (upwards and downwards) in emotion frequencies over time.
436
+ **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.
 
 
 
437
  """)
438
  with gr.Row():
439
  with gr.Column():
 
469
  next_button_topics.click(fn=topics, inputs=[output_file,input_checks], outputs=output_topics)
470
  send_btn.click(fn=unavailable, inputs=[input_file,input_checks], outputs=[output_markdown,message])
471
  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])
472
+ with gr.Column(scale=1, min_width=100):
473
  gr.Markdown("""
474
  """)
 
475
 
476
  with gr.Row():
477
+ with gr.Column(scale=1, min_width=100):
478
  gr.Markdown("""
479
  """)
480
+ with gr.Column(scale=5, min_width=500):
481
  gr.Markdown("""
482
  <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 [email protected].</font>
483
 
484
  <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>
485
  """)
486
+ with gr.Column(scale=1, min_width=100):
487
  gr.Markdown("""
488
  """)
489
  demo.launch()