Ankur Goyal commited on
Commit
4472e08
1 Parent(s): 59bf619

Fix clear button next to image preview

Browse files
Files changed (1) hide show
  1. app.py +30 -55
app.py CHANGED
@@ -291,9 +291,7 @@ with gr.Blocks(css=CSS) as demo:
291
  )
292
  submit = gr.Button("Get")
293
  gr.Markdown("— or —")
294
- upload = gr.File(
295
- label=None, interactive=True, elem_id="short-upload-box"
296
- )
297
  gr.Examples(
298
  examples=examples,
299
  inputs=[example_image, example_question],
@@ -319,60 +317,37 @@ with gr.Blocks(css=CSS) as demo:
319
  "Submit", variant="primary", elem_id="submit-button"
320
  )
321
  with gr.Column():
322
- output_text = gr.Textbox(label="Top Answer", visible=False, elem_id="answer")
 
 
323
  output = gr.JSON(label="Output", visible=False)
324
 
325
- img_clear_button.click(
326
- lambda _: (
327
- gr.update(visible=False, value=None),
328
- None,
329
- None,
330
- gr.update(visible=False, value=None),
331
- gr.update(visible=False, value=None),
332
- gr.update(visible=False),
333
- None,
334
- None,
335
- None,
336
- None,
337
- ),
338
- inputs=img_clear_button,
339
- outputs=[
340
- image,
341
- document,
342
- output,
343
- output_text,
344
- img_clear_button,
345
- example_image,
346
- upload,
347
- url,
348
- question,
349
- ],
350
- )
351
- clear_button.click(
352
- lambda _: (
353
- gr.update(visible=False, value=None),
354
- None,
355
- gr.update(visible=False, value=None),
356
- gr.update(visible=False, value=None),
357
- gr.update(visible=False),
358
- None,
359
- None,
360
- None,
361
- None,
362
- ),
363
- inputs=clear_button,
364
- outputs=[
365
- image,
366
- document,
367
- output,
368
- output_text,
369
- img_clear_button,
370
- example_image,
371
- upload,
372
- url,
373
- question,
374
- ],
375
- )
376
 
377
  upload.change(
378
  fn=process_upload,
 
291
  )
292
  submit = gr.Button("Get")
293
  gr.Markdown("— or —")
294
+ upload = gr.File(label=None, interactive=True, elem_id="short-upload-box")
 
 
295
  gr.Examples(
296
  examples=examples,
297
  inputs=[example_image, example_question],
 
317
  "Submit", variant="primary", elem_id="submit-button"
318
  )
319
  with gr.Column():
320
+ output_text = gr.Textbox(
321
+ label="Top Answer", visible=False, elem_id="answer"
322
+ )
323
  output = gr.JSON(label="Output", visible=False)
324
 
325
+ for cb in [img_clear_button, clear_button]:
326
+ cb.click(
327
+ lambda _: (
328
+ gr.update(visible=False, value=None),
329
+ None,
330
+ gr.update(visible=False, value=None),
331
+ gr.update(visible=False, value=None),
332
+ gr.update(visible=False),
333
+ None,
334
+ None,
335
+ None,
336
+ None,
337
+ ),
338
+ inputs=clear_button,
339
+ outputs=[
340
+ image,
341
+ document,
342
+ output,
343
+ output_text,
344
+ img_clear_button,
345
+ example_image,
346
+ upload,
347
+ url,
348
+ question,
349
+ ],
350
+ )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
351
 
352
  upload.change(
353
  fn=process_upload,