Spaces:
Running
Running
Commit
·
c7ec0f1
1
Parent(s):
3489df6
Update app.py
Browse files
app.py
CHANGED
@@ -123,9 +123,9 @@ def file(input_file, input_checks):
|
|
123 |
elif "peaks" in input_checks:
|
124 |
return gr.update(value=output, visible=True), gr.update(visible=False), gr.update(visible=False), gr.update(visible=True), gr.update(visible=False) # next_button_peaks becomes available
|
125 |
elif "topics" in input_checks:
|
126 |
-
return gr.update(value=output, visible=True), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), gr.update(visible=True) #
|
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) #
|
129 |
|
130 |
def freq(output_file, input_checks):
|
131 |
preds_dict = {"neutral": 10, "anger": 8, "fear": 2, "joy": 15, "love": 3, "sadness": 4}
|
@@ -140,9 +140,9 @@ def freq(output_file, input_checks):
|
|
140 |
elif "peaks" in input_checks:
|
141 |
return gr.update(value=plt, visible=True), gr.update(visible=False), gr.update(visible=True), gr.update(visible=False) # next_button_peaks becomes available
|
142 |
elif "topics" in input_checks:
|
143 |
-
return gr.update(value=plt, visible=True), gr.update(visible=False), gr.update(visible=False), gr.update(visible=True) #
|
144 |
else:
|
145 |
-
return gr.update(value=plt, visible=True), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False) #
|
146 |
|
147 |
def dist(output_file, input_checks):
|
148 |
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]})
|
@@ -162,9 +162,20 @@ def dist(output_file, input_checks):
|
|
162 |
if "peaks" in input_checks:
|
163 |
return gr.update(value=plt, visible=True), gr.update(visible=True), gr.update(visible=False) # next_button_peaks becomes available
|
164 |
elif "topics" in input_checks:
|
165 |
-
return gr.update(value=plt, visible=True), gr.update(visible=False), gr.update(visible=True) #
|
166 |
else:
|
167 |
-
return gr.update(value=plt, visible=True), gr.update(visible=False), gr.update(visible=False) #
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
168 |
|
169 |
with gr.Blocks() as demo:
|
170 |
with gr.Tab("Sentence"):
|
@@ -211,6 +222,8 @@ with gr.Blocks() as demo:
|
|
211 |
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])
|
212 |
next_button_freq.click(fn=freq, inputs=[output_file,input_checks], outputs=[output_plot,next_button_dist,next_button_peaks,next_button_topics])
|
213 |
next_button_dist.click(fn=dist, inputs=[output_file,input_checks], outputs=[output_dist,next_button_peaks,next_button_topics])
|
|
|
|
|
214 |
|
215 |
|
216 |
demo.launch()
|
|
|
123 |
elif "peaks" in input_checks:
|
124 |
return gr.update(value=output, visible=True), gr.update(visible=False), gr.update(visible=False), gr.update(visible=True), gr.update(visible=False) # next_button_peaks becomes available
|
125 |
elif "topics" in input_checks:
|
126 |
+
return gr.update(value=output, visible=True), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), gr.update(visible=True) # next_button_topics becomes available
|
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 freq(output_file, input_checks):
|
131 |
preds_dict = {"neutral": 10, "anger": 8, "fear": 2, "joy": 15, "love": 3, "sadness": 4}
|
|
|
140 |
elif "peaks" in input_checks:
|
141 |
return gr.update(value=plt, visible=True), gr.update(visible=False), gr.update(visible=True), gr.update(visible=False) # next_button_peaks becomes available
|
142 |
elif "topics" in input_checks:
|
143 |
+
return gr.update(value=plt, visible=True), gr.update(visible=False), gr.update(visible=False), gr.update(visible=True) # next_button_topics becomes available
|
144 |
else:
|
145 |
+
return gr.update(value=plt, visible=True), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False) # no next_button becomes available
|
146 |
|
147 |
def dist(output_file, input_checks):
|
148 |
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]})
|
|
|
162 |
if "peaks" in input_checks:
|
163 |
return gr.update(value=plt, visible=True), gr.update(visible=True), gr.update(visible=False) # next_button_peaks becomes available
|
164 |
elif "topics" in input_checks:
|
165 |
+
return gr.update(value=plt, visible=True), gr.update(visible=False), gr.update(visible=True) # next_button_topics becomes available
|
166 |
else:
|
167 |
+
return gr.update(value=plt, visible=True), gr.update(visible=False), gr.update(visible=False) # no next_button becomes available
|
168 |
+
|
169 |
+
def peaks(output_file, input_checks):
|
170 |
+
output = "There are peaks on some dates."
|
171 |
+
if "topics" in input_checks:
|
172 |
+
return gr.update(value=output, visible=True), gr.update(visible=True) # next_button_topics becomes available
|
173 |
+
else:
|
174 |
+
return gr.update(value=output, visible=True), gr.update(visible=False) # no next_button becomes available
|
175 |
+
|
176 |
+
def topics(output_file, input_checks):
|
177 |
+
output = "Some topics are found."
|
178 |
+
return gr.update(value=output, visible=True) # no next_button becomes available
|
179 |
|
180 |
with gr.Blocks() as demo:
|
181 |
with gr.Tab("Sentence"):
|
|
|
222 |
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])
|
223 |
next_button_freq.click(fn=freq, inputs=[output_file,input_checks], outputs=[output_plot,next_button_dist,next_button_peaks,next_button_topics])
|
224 |
next_button_dist.click(fn=dist, inputs=[output_file,input_checks], outputs=[output_dist,next_button_peaks,next_button_topics])
|
225 |
+
next_button_peaks.click(fn=peaks, inputs=[output_file,input_checks], outputs=[output_peaks,next_button_topics])
|
226 |
+
next_button_topics.click(fn=topics, inputs=[output_file,input_checks], outputs=output_topics)
|
227 |
|
228 |
|
229 |
demo.launch()
|