Spaces:
Running
Running
Commit
·
3ed8b4b
1
Parent(s):
abfc6cb
Update app.py
Browse files
app.py
CHANGED
@@ -165,6 +165,24 @@ def file(input_file, input_checks):
|
|
165 |
else:
|
166 |
return gr.update(value=output, visible=True), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False) # next_button_freq becomes available
|
167 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
168 |
|
169 |
|
170 |
with gr.Blocks() as demo:
|
@@ -211,6 +229,7 @@ with gr.Blocks() as demo:
|
|
211 |
|
212 |
#send_btn.click(fn=inference_dataset1, inputs=input_file, outputs=[output_file,next_button_freq]) # next_button_freq becomes visible
|
213 |
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])
|
|
|
214 |
|
215 |
""""
|
216 |
if "emotion frequencies" in input_checks:
|
|
|
165 |
else:
|
166 |
return gr.update(value=output, visible=True), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False) # next_button_freq becomes available
|
167 |
|
168 |
+
def freq(output_file, input_checks):
|
169 |
+
preds_dict = {"neutral": 0, "anger": 0, "fear": 0, "joy": 0, "love": 0, "sadness": 0}
|
170 |
+
for pred in preds:
|
171 |
+
preds_dict[pred] = preds_dict[pred] + 1
|
172 |
+
bars = list(preds_dict.keys())
|
173 |
+
height = list(preds_dict.values())
|
174 |
+
|
175 |
+
x_pos = np.arange(len(bars))
|
176 |
+
plt.bar(x_pos, height, color=['lightgrey', 'firebrick', 'rebeccapurple', 'orange', 'palevioletred', 'cornflowerblue'])
|
177 |
+
plt.xticks(x_pos, bars)
|
178 |
+
if "emotion distribution over time" in input_checks:
|
179 |
+
return gr.update(value=plt, visible=True), gr.update(visible=True), gr.update(visible=False), gr.update(visible=False) # next_button_dist becomes available
|
180 |
+
elif "peaks" in input_checks:
|
181 |
+
return gr.update(value=plt, visible=True), gr.update(visible=False), gr.update(visible=True), gr.update(visible=False) # next_button_peaks becomes available
|
182 |
+
elif "topics" in input_checks:
|
183 |
+
return gr.update(value=plt, visible=True), gr.update(visible=False), gr.update(visible=False), gr.update(visible=True) # next_button_peaks becomes available
|
184 |
+
else:
|
185 |
+
return gr.update(value=plt, visible=True), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False) # next_button_freq becomes available
|
186 |
|
187 |
|
188 |
with gr.Blocks() as demo:
|
|
|
229 |
|
230 |
#send_btn.click(fn=inference_dataset1, inputs=input_file, outputs=[output_file,next_button_freq]) # next_button_freq becomes visible
|
231 |
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])
|
232 |
+
next_button_freq.click(fn=freq, inputs=[output_file,input_checks], outputs=[output_plot,next_button_dist,next_button_peaks,next_button_topics])
|
233 |
|
234 |
""""
|
235 |
if "emotion frequencies" in input_checks:
|