lunadebruyne commited on
Commit
e974c2a
·
1 Parent(s): 3b915c4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -117,7 +117,7 @@ def unavailable(input_file, input_checks):
117
  return gr.update(value=output, label="Oops!", visible=True)
118
 
119
  def showcase(input_file):
120
- output = "showcase/data.txt"
121
  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
122
 
123
  def file(input_file, input_checks):
@@ -125,7 +125,7 @@ def file(input_file, input_checks):
125
  #f = open(output, 'w')
126
  #f.write("The predictions come here.")
127
  #f.close()
128
- output = "showcase/data.txt"
129
  if "emotion frequencies" in input_checks:
130
  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
131
  elif "emotion distribution over time" in input_checks:
@@ -142,7 +142,7 @@ def freq(output_file, input_checks):
142
  #'Emotion category': ['neutral', 'anger', 'fear', 'joy', 'love', 'sadness'],
143
  #'Frequency': [10, 8, 2, 15, 3, 4]})
144
 
145
- f = open("showcase/data.txt", 'r')
146
  data = f.read().split("\n")
147
  f.close()
148
  data = [line.split("\t") for line in data[1:-1]]
@@ -170,7 +170,7 @@ def freq(output_file, input_checks):
170
  width=600).configure_axis(
171
  grid=False).interactive()
172
 
173
- if "emotion distribution over time" in input_checks or (output_file.name).startswith('/tmp/data'):
174
  return gr.update(value=plot, visible=True), gr.update(visible=True), gr.update(visible=False), gr.update(visible=False) # next_button_dist becomes available
175
  elif "peaks" in input_checks:
176
  return gr.update(value=plot, visible=True), gr.update(visible=False), gr.update(visible=True), gr.update(visible=False) # next_button_peaks becomes available
@@ -248,7 +248,7 @@ def dist(output_file, input_checks):
248
 
249
  plot = (points + lines).properties(width=600, height=350).interactive()
250
 
251
- if "peaks" in input_checks or (output_file.name).startswith('/tmp/data'):
252
  return gr.Plot.update(value=plot, visible=True), gr.update(visible=True), gr.update(visible=False) # next_button_peaks becomes available
253
  elif "topics" in input_checks:
254
  return gr.Plot.update(value=plot, visible=True), gr.update(visible=False), gr.update(visible=True) # next_button_topics becomes available
@@ -341,7 +341,7 @@ def peaks(output_file, input_checks):
341
  '</body>'
342
  '</html>'
343
  )
344
- if "topics" in input_checks or (output_file.name).startswith('/tmp/data'):
345
  return gr.update(value=html, visible=True), gr.update(visible=True) # next_button_topics becomes available
346
  else:
347
  return gr.update(value=html, visible=True), gr.update(visible=False) # no next_button becomes available
 
117
  return gr.update(value=output, label="Oops!", visible=True)
118
 
119
  def showcase(input_file):
120
+ output = "showcase/example_predictions.txt"
121
  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
122
 
123
  def file(input_file, input_checks):
 
125
  #f = open(output, 'w')
126
  #f.write("The predictions come here.")
127
  #f.close()
128
+ output = "showcase/example_predictions.txt"
129
  if "emotion frequencies" in input_checks:
130
  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
131
  elif "emotion distribution over time" in input_checks:
 
142
  #'Emotion category': ['neutral', 'anger', 'fear', 'joy', 'love', 'sadness'],
143
  #'Frequency': [10, 8, 2, 15, 3, 4]})
144
 
145
+ f = open("showcase/example_predictions.txt", 'r')
146
  data = f.read().split("\n")
147
  f.close()
148
  data = [line.split("\t") for line in data[1:-1]]
 
170
  width=600).configure_axis(
171
  grid=False).interactive()
172
 
173
+ if "emotion distribution over time" in input_checks or (output_file.name).startswith('/tmp/example_predictions'):
174
  return gr.update(value=plot, visible=True), gr.update(visible=True), gr.update(visible=False), gr.update(visible=False) # next_button_dist becomes available
175
  elif "peaks" in input_checks:
176
  return gr.update(value=plot, visible=True), gr.update(visible=False), gr.update(visible=True), gr.update(visible=False) # next_button_peaks becomes available
 
248
 
249
  plot = (points + lines).properties(width=600, height=350).interactive()
250
 
251
+ if "peaks" in input_checks or (output_file.name).startswith('/tmp/example_predictions'):
252
  return gr.Plot.update(value=plot, visible=True), gr.update(visible=True), gr.update(visible=False) # next_button_peaks becomes available
253
  elif "topics" in input_checks:
254
  return gr.Plot.update(value=plot, visible=True), gr.update(visible=False), gr.update(visible=True) # next_button_topics becomes available
 
341
  '</body>'
342
  '</html>'
343
  )
344
+ if "topics" in input_checks or (output_file.name).startswith('/tmp/example_predictions'):
345
  return gr.update(value=html, visible=True), gr.update(visible=True) # next_button_topics becomes available
346
  else:
347
  return gr.update(value=html, visible=True), gr.update(visible=False) # no next_button becomes available