Spaces:
Running
Running
Commit
·
8f08788
1
Parent(s):
73fa676
Update app.py
Browse files
app.py
CHANGED
@@ -127,7 +127,7 @@ def file(input_file, input_checks):
|
|
127 |
else:
|
128 |
return gr.update(value=output, visible=True), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False) # no next_button becomes available
|
129 |
|
130 |
-
def
|
131 |
#preds_dict = {"neutral": 10, "anger": 8, "fear": 2, "joy": 15, "love": 3, "sadness": 4}
|
132 |
#bars = list(preds_dict.keys())
|
133 |
#height = list(preds_dict.values())
|
@@ -150,6 +150,33 @@ def freq(output_file, input_checks):
|
|
150 |
else:
|
151 |
return gr.update(simple,x="Emotion categories",y="Frequencies",title="Emotion frequencies",tooltip=['Emotion category', 'Frequency'],y_lim=[20, 100], visible=True), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False) # no next_button becomes available
|
152 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
153 |
def dist(output_file, input_checks):
|
154 |
dataframe = pd.DataFrame({'date_of_week': np.array([datetime.datetime(2021, 11, i+1) for i in range(7)]),'classes': [5, 6, 8, 2, 3, 7, 4]})
|
155 |
# Plotting the time series of given dataframe
|
@@ -214,7 +241,7 @@ with gr.Blocks() as demo:
|
|
214 |
output_file = gr.File(label="Predictions", visible=False)
|
215 |
next_button_freq = gr.Button("Show emotion frequencies", visible=False)
|
216 |
|
217 |
-
output_plot = gr.
|
218 |
next_button_dist = gr.Button("Show emotion distribution over time", visible=False)
|
219 |
|
220 |
output_dist = gr.Plot(label="Emotion distribution over time", visible=False)
|
|
|
127 |
else:
|
128 |
return gr.update(value=output, visible=True), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False) # no next_button becomes available
|
129 |
|
130 |
+
def freq2(output_file, input_checks):
|
131 |
#preds_dict = {"neutral": 10, "anger": 8, "fear": 2, "joy": 15, "love": 3, "sadness": 4}
|
132 |
#bars = list(preds_dict.keys())
|
133 |
#height = list(preds_dict.values())
|
|
|
150 |
else:
|
151 |
return gr.update(simple,x="Emotion categories",y="Frequencies",title="Emotion frequencies",tooltip=['Emotion category', 'Frequency'],y_lim=[20, 100], visible=True), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False) # no next_button becomes available
|
152 |
|
153 |
+
def freq(output_file, input_checks):
|
154 |
+
simple = pd.DataFrame({
|
155 |
+
'Emotion category': ['neutral', 'anger', 'fear', 'joy', 'love', 'sadness'],
|
156 |
+
'Frequency': [10, 8, 2, 15, 3, 4]})
|
157 |
+
|
158 |
+
domain = ['neutral', 'anger', 'fear', 'joy', 'love', 'sadness']
|
159 |
+
range_ = ['#999999', '#b22222', '#663399', '#ffcc00', '#db7093', '#6495ed']
|
160 |
+
n = max(simple['Frequency'])
|
161 |
+
|
162 |
+
plot = alt.Chart(simple, title="Emotion frequencies").mark_bar().encode(
|
163 |
+
x=alt.X("Emotion category", sort=['neutral', 'anger', 'fear', 'joy', 'love', 'sadness']),
|
164 |
+
y=alt.Y("Frequency", axis=alt.Axis(grid=False), scale=alt.Scale(domain=[0, (n + 9) // 10 * 10])),
|
165 |
+
color=alt.Color("Emotion category", scale=alt.Scale(domain=domain, range=range_), legend=None),
|
166 |
+
tooltip=['Emotion category', 'Frequency']).properties(
|
167 |
+
width=300).configure_axis(
|
168 |
+
grid=False).interactive()
|
169 |
+
|
170 |
+
if "emotion distribution over time" in input_checks:
|
171 |
+
return gr.update(value=plot, visible=True), gr.update(visible=True), gr.update(visible=False), gr.update(visible=False) # next_button_dist becomes available
|
172 |
+
elif "peaks" in input_checks:
|
173 |
+
return gr.update(value=plot, visible=True), gr.update(visible=False), gr.update(visible=True), gr.update(visible=False) # next_button_peaks becomes available
|
174 |
+
elif "topics" in input_checks:
|
175 |
+
return gr.update(value=plot, visible=True), gr.update(visible=False), gr.update(visible=False), gr.update(visible=True) # next_button_topics becomes available
|
176 |
+
else:
|
177 |
+
return gr.update(value=plot, visible=True), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False) # no next_button becomes available
|
178 |
+
|
179 |
+
|
180 |
def dist(output_file, input_checks):
|
181 |
dataframe = pd.DataFrame({'date_of_week': np.array([datetime.datetime(2021, 11, i+1) for i in range(7)]),'classes': [5, 6, 8, 2, 3, 7, 4]})
|
182 |
# Plotting the time series of given dataframe
|
|
|
241 |
output_file = gr.File(label="Predictions", visible=False)
|
242 |
next_button_freq = gr.Button("Show emotion frequencies", visible=False)
|
243 |
|
244 |
+
output_plot = gr.Plot(show_label=False, visible=False).style(container=True)
|
245 |
next_button_dist = gr.Button("Show emotion distribution over time", visible=False)
|
246 |
|
247 |
output_dist = gr.Plot(label="Emotion distribution over time", visible=False)
|