Spaces:
Running
Running
Commit
·
bc251bf
1
Parent(s):
8034ef9
Update app.py
Browse files
app.py
CHANGED
@@ -105,10 +105,12 @@ iface = gr.TabbedInterface([iface_sentence, iface_dataset], ["Sentence", "Datase
|
|
105 |
iface.queue().launch()
|
106 |
"""
|
107 |
|
|
|
108 |
def inference_sentence(text):
|
109 |
output = "This sentence will be processed:\n" + text
|
110 |
return output
|
111 |
|
|
|
112 |
def inference_dataset1(input_file):
|
113 |
output = "output.txt"
|
114 |
f = open(output, 'w')
|
@@ -128,7 +130,6 @@ def inference_dataset2(input_file, input_checks):
|
|
128 |
else:
|
129 |
return None
|
130 |
|
131 |
-
|
132 |
def inference_dataset3(input_file, input_checks):
|
133 |
if "emotion distribution over time" in input_checks:
|
134 |
return gr.update(value="This option was selected.", visible=True)
|
@@ -146,6 +147,23 @@ def inference_dataset5(input_file, input_checks):
|
|
146 |
return gr.update(value="This option was selected.", visible=True)
|
147 |
else:
|
148 |
return gr.update(value="This option was not selected.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
149 |
|
150 |
|
151 |
with gr.Blocks() as demo:
|
@@ -177,15 +195,44 @@ with gr.Blocks() as demo:
|
|
177 |
send_btn = gr.Button("Send")
|
178 |
with gr.Column():
|
179 |
output_file = gr.File(label="Predictions", visible=False)
|
180 |
-
|
|
|
181 |
output_plot = gr.Plot(label="Emotion frequencies", visible=False)
|
182 |
-
|
|
|
183 |
output_dist = gr.Textbox(label="Emotion distribution over time", visible=False)
|
184 |
-
|
|
|
185 |
output_peaks = gr.Textbox(label="Peaks", visible=False)
|
186 |
-
|
|
|
187 |
output_topics = gr.Textbox(label="Topics", visible=False)
|
188 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
189 |
#output_file.change(fn=inference_dataset2, inputs=[input_file,input_checks], outputs=output_plot).then(fn=inference_dataset3, inputs=[input_file,input_checks], outputs=output_dist)
|
190 |
#output_plot.change(fn=inference_dataset3, inputs=[input_file,input_checks], outputs=output_dist)
|
191 |
#output_dist.change(fn=inference_dataset4, inputs=[input_file,input_checks], outputs=output_peaks)
|
|
|
105 |
iface.queue().launch()
|
106 |
"""
|
107 |
|
108 |
+
|
109 |
def inference_sentence(text):
|
110 |
output = "This sentence will be processed:\n" + text
|
111 |
return output
|
112 |
|
113 |
+
"""
|
114 |
def inference_dataset1(input_file):
|
115 |
output = "output.txt"
|
116 |
f = open(output, 'w')
|
|
|
130 |
else:
|
131 |
return None
|
132 |
|
|
|
133 |
def inference_dataset3(input_file, input_checks):
|
134 |
if "emotion distribution over time" in input_checks:
|
135 |
return gr.update(value="This option was selected.", visible=True)
|
|
|
147 |
return gr.update(value="This option was selected.", visible=True)
|
148 |
else:
|
149 |
return gr.update(value="This option was not selected.")
|
150 |
+
"""
|
151 |
+
|
152 |
+
def file(input_file):
|
153 |
+
output = "output.txt"
|
154 |
+
f = open(output, 'w')
|
155 |
+
f.write("The predictions come here.")
|
156 |
+
f.close()
|
157 |
+
return gr.update(value=output, visible=True)
|
158 |
+
|
159 |
+
def file_next(input_file):
|
160 |
+
output = "output.txt"
|
161 |
+
f = open(output, 'w')
|
162 |
+
f.write("The predictions come here.")
|
163 |
+
f.close()
|
164 |
+
return gr.update(value=output, visible=True), gr.update(visible=True) # next_button becomes available
|
165 |
+
|
166 |
+
|
167 |
|
168 |
|
169 |
with gr.Blocks() as demo:
|
|
|
195 |
send_btn = gr.Button("Send")
|
196 |
with gr.Column():
|
197 |
output_file = gr.File(label="Predictions", visible=False)
|
198 |
+
next_button_freq = gr.Button("Next_button freq", visible=False)
|
199 |
+
|
200 |
output_plot = gr.Plot(label="Emotion frequencies", visible=False)
|
201 |
+
next_button_dist = gr.Button("Next_button dist", visible=False)
|
202 |
+
|
203 |
output_dist = gr.Textbox(label="Emotion distribution over time", visible=False)
|
204 |
+
next_button_peaks = gr.Button("Next_button peaks", visible=False)
|
205 |
+
|
206 |
output_peaks = gr.Textbox(label="Peaks", visible=False)
|
207 |
+
next_button_topics = gr.Button("Next_button topics", visible=False)
|
208 |
+
|
209 |
output_topics = gr.Textbox(label="Topics", visible=False)
|
210 |
+
|
211 |
+
#send_btn.click(fn=inference_dataset1, inputs=input_file, outputs=[output_file,next_button_freq]) # next_button_freq becomes visible
|
212 |
+
|
213 |
+
if "emotion frequencies" in input_checks:
|
214 |
+
send_btn.click(fn=file_next, inputs=input_file, outputs=[output_file,next_button_freq]) # next_button_freq becomes visible
|
215 |
+
elif "emotion distribution over time" in input_checks:
|
216 |
+
send_btn.click(fn=file_next, inputs=input_file, outputs=[output_file,next_button_dist]) # next_button_dist becomes visible
|
217 |
+
elif "peaks" in input_checks:
|
218 |
+
send_btn.click(fn=file_next, inputs=input_file, outputs=[output_file,next_button_peaks]) # next_button_peaks becomes visible
|
219 |
+
elif "topics" in input_checks:
|
220 |
+
send_btn.click(fn=file_next, inputs=input_file, outputs=[output_file,next_button_topics]) # next_button_topics becomes visible
|
221 |
+
else:
|
222 |
+
send_btn.click(fn=file, inputs=input_file, outputs=output_file) # no next_button becomes available
|
223 |
+
|
224 |
+
""""
|
225 |
+
if "emotion frequencies" in input_checks:
|
226 |
+
next_button_freq.click(fn=freq_freq, inputs=[output_file,input_checks], outputs=[output_plot,next_button_dist]) # next_button_dist becomes visible
|
227 |
+
else:
|
228 |
+
if "emotion distribution over time" in input_checks:
|
229 |
+
next_button_freq.click(fn=freq_dist, inputs=[output_file,input_checks], outputs=[output_dist,next_peaks]) # nex_button_peaks becomes visible
|
230 |
+
else:
|
231 |
+
if "peaks" in input_checks:
|
232 |
+
next_button_freq.click(fn=freq_peaks, inputs=[output_file,input_checks], outputs=[output_,next_peaks]) # nex_button_peaks becomes visible
|
233 |
+
"""
|
234 |
+
|
235 |
+
|
236 |
#output_file.change(fn=inference_dataset2, inputs=[input_file,input_checks], outputs=output_plot).then(fn=inference_dataset3, inputs=[input_file,input_checks], outputs=output_dist)
|
237 |
#output_plot.change(fn=inference_dataset3, inputs=[input_file,input_checks], outputs=output_dist)
|
238 |
#output_dist.change(fn=inference_dataset4, inputs=[input_file,input_checks], outputs=output_peaks)
|