Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -708,7 +708,7 @@ def build_ui_with_custom_ui():
|
|
| 708 |
if img:
|
| 709 |
captions = captions + [captioner(img)[0]["generated_text"]]
|
| 710 |
ready = len(images) >= 1 and len(captions) >= 1
|
| 711 |
-
return img, images, captions
|
| 712 |
|
| 713 |
def generate_ds(_, enhancer, images, captions):
|
| 714 |
if not captions:
|
|
@@ -718,7 +718,7 @@ def build_ui_with_custom_ui():
|
|
| 718 |
if img:
|
| 719 |
captions = captions + [captioner(img)[0]["generated_text"]]
|
| 720 |
ready = len(images) >= 1 and len(captions) >= 1
|
| 721 |
-
return img, images, captions, gr.update(interactive=ready), gr.update(interactive=ready)
|
| 722 |
|
| 723 |
|
| 724 |
|
|
@@ -783,15 +783,25 @@ def build_ui_with_custom_ui():
|
|
| 783 |
|
| 784 |
|
| 785 |
# ---------------- Enable Metrics/NLP only when ready ----------------
|
| 786 |
-
|
| 787 |
def enable_metrics_nlp(images, captions):
|
| 788 |
ready = len(images) >= 3 and len(captions) >= 3
|
| 789 |
return (
|
| 790 |
gr.update(interactive=ready),
|
| 791 |
gr.update(interactive=ready)
|
| 792 |
-
)
|
| 793 |
-
|
| 794 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 795 |
|
| 796 |
# ---------------- Step 5: VQA ----------------
|
| 797 |
gr.Markdown("### Visual Question Answering (VQA)", elem_classes="heading-orange")
|
|
|
|
| 708 |
if img:
|
| 709 |
captions = captions + [captioner(img)[0]["generated_text"]]
|
| 710 |
ready = len(images) >= 1 and len(captions) >= 1
|
| 711 |
+
return img, images, captions #,gr.update(interactive=ready), gr.update(interactive=ready)
|
| 712 |
|
| 713 |
def generate_ds(_, enhancer, images, captions):
|
| 714 |
if not captions:
|
|
|
|
| 718 |
if img:
|
| 719 |
captions = captions + [captioner(img)[0]["generated_text"]]
|
| 720 |
ready = len(images) >= 1 and len(captions) >= 1
|
| 721 |
+
return img, images, captions #, gr.update(interactive=ready), gr.update(interactive=ready)
|
| 722 |
|
| 723 |
|
| 724 |
|
|
|
|
| 783 |
|
| 784 |
|
| 785 |
# ---------------- Enable Metrics/NLP only when ready ----------------
|
| 786 |
+
"""
|
| 787 |
def enable_metrics_nlp(images, captions):
|
| 788 |
ready = len(images) >= 3 and len(captions) >= 3
|
| 789 |
return (
|
| 790 |
gr.update(interactive=ready),
|
| 791 |
gr.update(interactive=ready)
|
| 792 |
+
)"""
|
| 793 |
+
|
| 794 |
+
def enable_metrics_nlp(images, captions):
|
| 795 |
+
ready = (
|
| 796 |
+
len(images) == 3 and
|
| 797 |
+
len(captions) == 3 and
|
| 798 |
+
all(c and c != "Caption failed." for c in captions)
|
| 799 |
+
)
|
| 800 |
+
return gr.update(interactive=ready), gr.update(interactive=ready)
|
| 801 |
+
|
| 802 |
+
|
| 803 |
+
|
| 804 |
+
images_state.change(enable_metrics_nlp, [images_state, captions_state], [metrics_btn, nlp_btn])
|
| 805 |
|
| 806 |
# ---------------- Step 5: VQA ----------------
|
| 807 |
gr.Markdown("### Visual Question Answering (VQA)", elem_classes="heading-orange")
|