Commit
·
cc3f6fe
1
Parent(s):
13ca93e
Update app.py
Browse files
app.py
CHANGED
@@ -233,28 +233,26 @@ with gr.Blocks() as demo:
|
|
233 |
)
|
234 |
gr.Markdown("Click on start to play again!")
|
235 |
|
|
|
|
|
|
|
236 |
with gr.Column(visible=False) as gallery_view:
|
237 |
counter = gr.Markdown(f" ### 1/{NUM_QUESTIONS}")
|
238 |
prompt = gr.Markdown(PROMPT_FORMAT.format(""))
|
239 |
with gr.Blocks():
|
240 |
with gr.Row() as images:
|
241 |
-
with gr.Column:
|
242 |
image_1 = gr.Image(interactive=False)
|
243 |
image_1_button = gr.Button("Select 1").style(full_width=True)
|
244 |
-
with gr.Column:
|
245 |
image_2 = gr.Image(interactive=False)
|
246 |
image_2_button = gr.Button("Select 2").style(full_width=True)
|
247 |
-
with gr.Column:
|
248 |
image_3 = gr.Image(interactive=False)
|
249 |
image_3_button = gr.Button("Select 3").style(full_width=True)
|
250 |
-
with gr.Column:
|
251 |
image_3 = gr.Image(interactive=False)
|
252 |
image_3_button = gr.Button("Select 4").style(full_width=True)
|
253 |
-
|
254 |
-
next_button = gr.Button("Confirm").style(full_width=True)
|
255 |
-
|
256 |
-
with gr.Column(visible=False):
|
257 |
-
selected_image = gr.Number(label="Selected index", value=-1, precision=0)
|
258 |
|
259 |
start_button.click(
|
260 |
fn=start,
|
@@ -273,32 +271,27 @@ with gr.Blocks() as demo:
|
|
273 |
fn=process, inputs=[dataframe], outputs=[image_1, image_2, image_3, image_4, prompt, counter]
|
274 |
)
|
275 |
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
).then(
|
299 |
-
fn=refresh,
|
300 |
-
inputs=[row_number, dataframe],
|
301 |
-
outputs=[dataframe],
|
302 |
-
)
|
303 |
|
304 |
demo.launch()
|
|
|
233 |
)
|
234 |
gr.Markdown("Click on start to play again!")
|
235 |
|
236 |
+
with gr.Column(visible=False):
|
237 |
+
selected_image = gr.Number(label="Selected index", value=-1, precision=0)
|
238 |
+
|
239 |
with gr.Column(visible=False) as gallery_view:
|
240 |
counter = gr.Markdown(f" ### 1/{NUM_QUESTIONS}")
|
241 |
prompt = gr.Markdown(PROMPT_FORMAT.format(""))
|
242 |
with gr.Blocks():
|
243 |
with gr.Row() as images:
|
244 |
+
with gr.Column():
|
245 |
image_1 = gr.Image(interactive=False)
|
246 |
image_1_button = gr.Button("Select 1").style(full_width=True)
|
247 |
+
with gr.Column():
|
248 |
image_2 = gr.Image(interactive=False)
|
249 |
image_2_button = gr.Button("Select 2").style(full_width=True)
|
250 |
+
with gr.Column():
|
251 |
image_3 = gr.Image(interactive=False)
|
252 |
image_3_button = gr.Button("Select 3").style(full_width=True)
|
253 |
+
with gr.Column():
|
254 |
image_3 = gr.Image(interactive=False)
|
255 |
image_3_button = gr.Button("Select 4").style(full_width=True)
|
|
|
|
|
|
|
|
|
|
|
256 |
|
257 |
start_button.click(
|
258 |
fn=start,
|
|
|
271 |
fn=process, inputs=[dataframe], outputs=[image_1, image_2, image_3, image_4, prompt, counter]
|
272 |
)
|
273 |
|
274 |
+
for i, button in enumerate([image_1_button, image_2_button, image_3_button, image_4_button]):
|
275 |
+
button.click(
|
276 |
+
fn=write_result,
|
277 |
+
inputs=[i, row_number, dataframe],
|
278 |
+
outputs=[row_number, dataframe],
|
279 |
+
).then(
|
280 |
+
fn=change_view,
|
281 |
+
inputs=[row_number, dataframe],
|
282 |
+
outputs=[intro_view, result_view, gallery_view, result]
|
283 |
+
).then(
|
284 |
+
fn=process,
|
285 |
+
inputs=[dataframe, row_number],
|
286 |
+
outputs=[image_1, image_2, image_3, image_4, prompt, counter]
|
287 |
+
).then(
|
288 |
+
fn=lambda x: 0 if x == NUM_QUESTIONS else x,
|
289 |
+
inputs=[row_number],
|
290 |
+
outputs=[row_number],
|
291 |
+
).then(
|
292 |
+
fn=refresh,
|
293 |
+
inputs=[row_number, dataframe],
|
294 |
+
outputs=[dataframe],
|
295 |
+
)
|
|
|
|
|
|
|
|
|
|
|
296 |
|
297 |
demo.launch()
|