Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -304,7 +304,7 @@ def generate_image(
|
|
304 |
def create_image_input(index, open=True, indexs_state=None):
|
305 |
accordion_state = gr.State(open)
|
306 |
with gr.Column():
|
307 |
-
with gr.Accordion(f"Input Image {index + 1}", open=accordion_state) as accordion:
|
308 |
image = gr.Image(type="filepath", label=f"Image {index + 1}")
|
309 |
caption = gr.Textbox(label=f"Caption {index + 1}", value="")
|
310 |
id_ip_checkbox = gr.Checkbox(value=False, label=f"ID or not {index + 1}", visible=True)
|
@@ -342,21 +342,21 @@ def merge_instances(orig_img, indices, ins_bboxes, ins_images):
|
|
342 |
img = final_img.crop(bbox)
|
343 |
return img, bbox
|
344 |
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
#
|
349 |
-
#
|
350 |
-
#
|
351 |
-
#
|
352 |
-
#
|
353 |
-
#
|
354 |
-
#
|
355 |
|
356 |
-
#
|
357 |
-
#
|
358 |
-
#
|
359 |
-
#
|
360 |
|
361 |
def update_inputs(is_open, index, state: list):
|
362 |
indexs = state
|
@@ -509,7 +509,7 @@ 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 |
-
|
513 |
|
514 |
|
515 |
examples = gr.Examples(
|
|
|
304 |
def create_image_input(index, open=True, indexs_state=None):
|
305 |
accordion_state = gr.State(open)
|
306 |
with gr.Column():
|
307 |
+
with gr.Accordion(f"Input Image {index + 1}", open=accordion_state.value) as accordion:
|
308 |
image = gr.Image(type="filepath", label=f"Image {index + 1}")
|
309 |
caption = gr.Textbox(label=f"Caption {index + 1}", value="")
|
310 |
id_ip_checkbox = gr.Checkbox(value=False, label=f"ID or not {index + 1}", visible=True)
|
|
|
342 |
img = final_img.crop(bbox)
|
343 |
return img, bbox
|
344 |
|
345 |
+
def change_accordion(at: bool, index: int, state: list):
|
346 |
+
print("change_accordion", index, state)
|
347 |
+
print("at:", at)
|
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 |
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])
|
513 |
|
514 |
|
515 |
examples = gr.Examples(
|