helloworld-S commited on
Commit
10713a0
·
verified ·
1 Parent(s): ea7754d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -14
app.py CHANGED
@@ -352,21 +352,21 @@ def merge_instances(orig_img, indices, ins_bboxes, ins_images):
352
  # After changed [] []
353
  # After changed []
354
 
355
- # def change_accordion(at: bool, index: int, state: list):
356
- # print("change_accordion", index, state)
357
- # print("at:", at)
358
- # indexs = state
359
- # if at:
360
- # if index not in indexs:
361
- # indexs.append(index)
362
- # else:
363
- # if index in indexs:
364
- # indexs.remove(index)
365
 
366
- # # 确保 indexs 是有序的
367
- # indexs.sort()
368
- # print("After changed", indexs)
369
- # return gr.Accordion(open=at), indexs
370
 
371
  def update_inputs(is_open, index, state: list):
372
  indexs = state
@@ -519,6 +519,8 @@ if __name__ == "__main__":
519
  face_btns[i].click(crop_face_img, inputs=[images[i]], outputs=[images[i]])
520
  det_btns[i].click(det_seg_img, inputs=[images[i], captions[i]], outputs=[images[i]])
521
  vlm_btns[i].click(vlm_img_caption, inputs=[images[i]], outputs=[captions[i]])
 
 
522
 
523
  examples = gr.Examples(
524
  examples=[
 
352
  # After changed [] []
353
  # After changed []
354
 
355
+ def change_accordion(at: bool, index: int, state: list):
356
+ print("change_accordion", index, state)
357
+ print("at:", at)
358
+ indexs = state
359
+ if at:
360
+ if index not in indexs:
361
+ indexs.append(index)
362
+ else:
363
+ if index in indexs:
364
+ indexs.remove(index)
365
 
366
+ # 确保 indexs 是有序的
367
+ indexs.sort()
368
+ print("After changed", indexs)
369
+ return gr.Accordion(open=at), indexs
370
 
371
  def update_inputs(is_open, index, state: list):
372
  indexs = state
 
519
  face_btns[i].click(crop_face_img, inputs=[images[i]], outputs=[images[i]])
520
  det_btns[i].click(det_seg_img, inputs=[images[i], captions[i]], outputs=[images[i]])
521
  vlm_btns[i].click(vlm_img_caption, inputs=[images[i]], outputs=[captions[i]])
522
+ accordion_states[i].change(fn=lambda x, state, index=i: change_accordion(x, index, state), inputs=[accordion_states[i], indexs_state], outputs=[accordions[i], indexs_state])
523
+
524
 
525
  examples = gr.Examples(
526
  examples=[