Spaces:
Running
Running
Commit
Β·
eed1c43
1
Parent(s):
ab937a1
Update app.py
Browse files
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 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
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'))
|