lunadebruyne commited on
Commit
eed1c43
Β·
1 Parent(s): ab937a1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -85
app.py CHANGED
@@ -260,91 +260,11 @@ def dist(output_file, input_checks):
260
  return gr.Plot.update(value=plot, visible=True), gr.update(visible=False), gr.update(visible=False) # no next_button becomes available
261
 
262
  def peaks(output_file, input_checks):
263
- 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"}
264
- 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"}
265
- peaks_joy = {"13/3/2020": "up", "4/4/2020": "up", "19/6/2020": "up", "26/6/2020": "up"}
266
- peaks_love = {"12/3/2020": "up", "5/5/2020": "down", "26/6/2020": "up", "7/8/2020": "up",}
267
- 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"}
268
-
269
- text_anger = ", ".join([str(key) + " (↑)" if value == "up" else str(key) + " (↓)" for key, value in peaks_anger.items()])
270
- text_fear = ", ".join([str(key) + " (↑)" if value == "up" else str(key) + " (↓)" for key, value in peaks_fear.items()])
271
- text_joy = ", ".join([str(key) + " (↑)" if value == "up" else str(key) + " (↓)" for key, value in peaks_joy.items()])
272
- text_love = ", ".join([str(key) + " (↑)" if value == "up" else str(key) + " (↓)" for key, value in peaks_love.items()])
273
- text_sadness = ", ".join([str(key) + " (↑)" if value == "up" else str(key) + " (↓)" for key, value in peaks_sadness.items()])
274
-
275
- html = (
276
- '<html>'
277
- '<head>'
278
- '<meta name="viewport" content="width=device-width, initial-scale=1">'
279
- '<style>'
280
- '.dot_neutral {'
281
- 'height: 11px;'
282
- 'width: 11px;'
283
- 'background-color: #999999;'
284
- 'border-radius: 50%;'
285
- 'display: inline-block;'
286
- '}'
287
- '.dot_anger {'
288
- 'height: 11px;'
289
- 'width: 11px;'
290
- 'background-color: #b22222;'
291
- 'border-radius: 50%;'
292
- 'display: inline-block;'
293
- '}'
294
- '.dot_fear {'
295
- 'height: 11px;'
296
- 'width: 11px;'
297
- 'background-color: #663399;'
298
- 'border-radius: 50%;'
299
- 'display: inline-block;'
300
- '}'
301
- '.dot_joy {'
302
- 'height: 11px;'
303
- 'width: 11px;'
304
- 'background-color: #ffcc00;'
305
- 'border-radius: 50%;'
306
- 'display: inline-block;'
307
- '}'
308
- '.dot_love {'
309
- 'height: 11px;'
310
- 'width: 11px;'
311
- 'background-color: #db7093;'
312
- 'border-radius: 50%;'
313
- 'display: inline-block;'
314
- '}'
315
- '.dot_sadness {'
316
- 'height: 11px;'
317
- 'width: 11px;'
318
- 'background-color: #6495ed;'
319
- 'border-radius: 50%;'
320
- 'display: inline-block;'
321
- '}'
322
- '.tab {'
323
- 'padding-left: 1em;'
324
- '}'
325
- '</style>'
326
- '</head>'
327
- '<body>'
328
- '<div>'
329
- '<p>These significant fluctuations were found:</p>'
330
- '<p><span class="dot_anger"></span> anger:</p>'
331
- '<p class="tab">' + text_anger + '<p>'
332
- '<p><span class="dot_fear"></span> fear:</p>'
333
- '<p class="tab">' + text_fear + '<p>'
334
- '<p><span class="dot_joy"></span> joy:</p>'
335
- '<p class="tab">' + text_joy + '<p>'
336
- '<p><span class="dot_love"></span> love:</p>'
337
- '<p class="tab">' + text_love + '<p>'
338
- '<p><span class="dot_sadness"></span> sadness:</p>'
339
- '<p class="tab">' + text_sadness + '<p>'
340
- '</div>'
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
348
 
349
  def topics(output_file, input_checks):
350
  plot = pickle.load(open('showcase/vis_classes_covid.p', 'rb'))
 
260
  return gr.Plot.update(value=plot, visible=True), gr.update(visible=False), gr.update(visible=False) # no next_button becomes available
261
 
262
  def peaks(output_file, input_checks):
263
+ plot = pickle.load(open('showcase/peaks_covid.p', 'rb'))
264
+ if "topics" in input_checks or (output_file.name).startswith('/tmp/example_predictions'):
265
+ return gr.Plot.update(value=plot, visible=True), gr.update(visible=True) # next_button_topics becomes available
266
+ else:
267
+ return gr.Plot.update(value=plot, visible=True), gr.update(visible=False) # no next_button becomes available
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
268
 
269
  def topics(output_file, input_checks):
270
  plot = pickle.load(open('showcase/vis_classes_covid.p', 'rb'))