helloworld-S commited on
Commit
6be12ae
·
verified ·
1 Parent(s): cd0606d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -14
app.py CHANGED
@@ -343,20 +343,30 @@ def merge_instances(orig_img, indices, ins_bboxes, ins_images):
343
  return img, bbox
344
 
345
 
346
- def change_accordion(at: bool, index: int, state: list):
347
- print("change_accordion", index, at, state)
348
- indexs = state
349
- if at:
350
- if index not in indexs:
351
- indexs.append(index)
352
- else:
353
- if index in indexs:
354
- indexs.remove(index)
 
 
 
 
 
 
 
 
 
 
355
 
356
- # 确保 indexs 是有序的
357
- indexs.sort()
358
- print("After changed", indexs)
359
- return gr.Accordion(open=at), indexs
360
 
361
  def update_inputs(is_open, index, state: list):
362
  indexs = state
@@ -509,7 +519,6 @@ if __name__ == "__main__":
509
  face_btns[i].click(crop_face_img, inputs=[images[i]], outputs=[images[i]])
510
  det_btns[i].click(det_seg_img, inputs=[images[i], captions[i]], outputs=[images[i]])
511
  vlm_btns[i].click(vlm_img_caption, inputs=[images[i]], outputs=[captions[i]])
512
- 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])
513
 
514
  examples = gr.Examples(
515
  examples=[
 
343
  return img, bbox
344
 
345
 
346
+
347
+ # change_accordionchange_accordion 0 1 [0, 1]
348
+ # After changed[0]
349
+ # After changed [] []
350
+
351
+ # change_accordionchange_accordion 3 2 []
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
 
523
  examples = gr.Examples(
524
  examples=[