lunadebruyne commited on
Commit
ea5dfc8
·
1 Parent(s): 49dac6b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -18
app.py CHANGED
@@ -385,7 +385,6 @@ with gr.Blocks() as demo:
385
  with gr.Column(scale=1, min_width=100):
386
  gr.Markdown("""
387
  """)
388
-
389
  with gr.Row():
390
  with gr.Column(scale=1, min_width=100):
391
  gr.Markdown("""
@@ -406,34 +405,34 @@ with gr.Blocks() as demo:
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():
414
  demo_btn = gr.Button("Showcase with example data", variant="primary")
415
- with gr.Column():
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():
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():
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():
@@ -462,17 +461,18 @@ with gr.Blocks() as demo:
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=message)
472
- demo_btn.click(fn=showcase, inputs=[input_file], outputs=[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
  with gr.Row():
477
  with gr.Column(scale=1, min_width=100):
478
  gr.Markdown("""
@@ -481,11 +481,9 @@ with gr.Blocks() as demo:
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: grid;grid-template-columns: 150px auto;"><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
-
490
- demo.launch()
491
-
 
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("""
 
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(
422
  label="Upload a dataset")
423
  input_checks = gr.CheckboxGroup(
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():
 
461
  next_button_topics = gr.Button("Show topics", visible=False)
462
 
463
  output_topics = gr.Plot(show_label=False, visible=False)
464
+
465
  #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])
466
  next_button_freq.click(fn=freq, inputs=[output_file,input_checks], outputs=[output_plot,next_button_dist,next_button_peaks,next_button_topics])
467
  next_button_dist.click(fn=dist, inputs=[output_file,input_checks], outputs=[output_dist,next_button_peaks,next_button_topics])
468
  next_button_peaks.click(fn=peaks, inputs=[output_file,input_checks], outputs=[output_peaks,next_button_topics])
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("""
 
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()