Update app.py
Browse files
app.py
CHANGED
@@ -364,28 +364,6 @@ def generate_image(
|
|
364 |
|
365 |
return image
|
366 |
|
367 |
-
def create_image_input(index, open=True, indexs_state=None):
|
368 |
-
accordion_state = gr.State(open)
|
369 |
-
with gr.Column():
|
370 |
-
with gr.Accordion(f"Input Image {index + 1}", open=accordion_state.value) as accordion:
|
371 |
-
image = gr.Image(type="filepath", label=f"Image {index + 1}")
|
372 |
-
caption = gr.Textbox(label=f"Caption {index + 1}", value="")
|
373 |
-
id_ip_checkbox = gr.Checkbox(value=False, label=f"ID or not {index + 1}", visible=True)
|
374 |
-
with gr.Row():
|
375 |
-
vlm_btn = gr.Button("Auto Caption")
|
376 |
-
det_btn = gr.Button("Det & Seg")
|
377 |
-
face_btn = gr.Button("Crop Face")
|
378 |
-
accordion.expand(
|
379 |
-
inputs=[indexs_state],
|
380 |
-
fn = lambda x: update_inputs(True, index, x),
|
381 |
-
outputs=[indexs_state, accordion_state],
|
382 |
-
)
|
383 |
-
accordion.collapse(
|
384 |
-
inputs=[indexs_state],
|
385 |
-
fn = lambda x: update_inputs(False, index, x),
|
386 |
-
outputs=[indexs_state, accordion_state],
|
387 |
-
)
|
388 |
-
return image, caption, face_btn, det_btn, vlm_btn, accordion_state, accordion, id_ip_checkbox
|
389 |
|
390 |
|
391 |
def merge_instances(orig_img, indices, ins_bboxes, ins_images):
|
@@ -526,17 +504,24 @@ with gr.Blocks() as demo:
|
|
526 |
|
527 |
clear_btn = gr.Button("清空输入图像")
|
528 |
with gr.Row():
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
540 |
with gr.Column():
|
541 |
output = gr.Image(label="生成的图像")
|
542 |
seed = gr.Number(value=42, label="Seed", info="")
|
@@ -561,12 +546,13 @@ with gr.Blocks() as demo:
|
|
561 |
# 修改清空函数的输出参数
|
562 |
clear_btn.click(clear_images, outputs=images)
|
563 |
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
|
|
570 |
|
571 |
|
572 |
demo.queue().launch(share=True)
|
|
|
364 |
|
365 |
return image
|
366 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
367 |
|
368 |
|
369 |
def merge_instances(orig_img, indices, ins_bboxes, ins_images):
|
|
|
504 |
|
505 |
clear_btn = gr.Button("清空输入图像")
|
506 |
with gr.Row():
|
507 |
+
with gr.Column():
|
508 |
+
image_1 = gr.Image(type="filepath", label=f"Image {index + 1}")
|
509 |
+
caption_1 = gr.Textbox(label=f"Caption {index + 1}", value="")
|
510 |
+
id_ip_checkbox_1 = gr.Checkbox(value=False, label=f"ID or not {index + 1}", visible=True)
|
511 |
+
with gr.Row():
|
512 |
+
vlm_btn_1 = gr.Button("Auto Caption")
|
513 |
+
det_btn_1 = gr.Button("Det & Seg")
|
514 |
+
face_btn_1 = gr.Button("Crop Face")
|
515 |
+
|
516 |
+
with gr.Column():
|
517 |
+
image_2 = gr.Image(type="filepath", label=f"Image {index + 1}")
|
518 |
+
caption_2 = gr.Textbox(label=f"Caption {index + 1}", value="")
|
519 |
+
id_ip_checkbox_2 = gr.Checkbox(value=False, label=f"ID or not {index + 1}", visible=True)
|
520 |
+
with gr.Row():
|
521 |
+
vlm_btn_2 = gr.Button("Auto Caption")
|
522 |
+
det_btn_2 = gr.Button("Det & Seg")
|
523 |
+
face_btn_2 = gr.Button("Crop Face")
|
524 |
+
|
525 |
with gr.Column():
|
526 |
output = gr.Image(label="生成的图像")
|
527 |
seed = gr.Number(value=42, label="Seed", info="")
|
|
|
546 |
# 修改清空函数的输出参数
|
547 |
clear_btn.click(clear_images, outputs=images)
|
548 |
|
549 |
+
face_btns_1.click(crop_face_img, inputs=[image_1], outputs=[image_1])
|
550 |
+
det_btns_1.click(det_seg_img, inputs=[images_1, captions_1], outputs=[images_1])
|
551 |
+
vlm_btns_1.click(vlm_img_caption, inputs=[images_1], outputs=[captions_1])
|
552 |
+
|
553 |
+
face_btns_2.click(crop_face_img, inputs=[image_2], outputs=[image_2])
|
554 |
+
det_btns_2.click(det_seg_img, inputs=[images_2, captions_2], outputs=[images_2])
|
555 |
+
vlm_btns_2.click(vlm_img_caption, inputs=[images_2], outputs=[captions_2])
|
556 |
|
557 |
|
558 |
demo.queue().launch(share=True)
|