Spaces:
Runtime error
Runtime error
update to address error in log
Browse files
app.py
CHANGED
@@ -53,17 +53,7 @@ def generate_answer_blip2(image, question):
|
|
53 |
|
54 |
return generated_answer[0] # Return the first (and typically only) generated answer
|
55 |
|
56 |
-
# Setting up the Gradio interface
|
57 |
-
def show_demo():
|
58 |
-
iface = gr.Interface(
|
59 |
-
fn=generate_answer_blip2,
|
60 |
-
inputs=[gr.Image(label="Upload Image"), gr.Textbox(label="Enter your question")],
|
61 |
-
outputs=gr.Textbox(label="Generated Answer"),
|
62 |
-
title="Visual Question Answering with DeiT-BLIP2 Model",
|
63 |
-
description="Upload an image and type a related question to receive an answer generated by the model."
|
64 |
-
)
|
65 |
-
iface.launch(share=True)
|
66 |
-
|
67 |
with gr.Blocks() as landing_page:
|
68 |
gr.Markdown("# Welcome to the Visual Question Answering Demo")
|
69 |
gr.Markdown("This demo uses the customized BLIP2 model to answer questions about images.")
|
@@ -71,9 +61,23 @@ with gr.Blocks() as landing_page:
|
|
71 |
gr.Markdown("1. Upload an image. \n2. Enter a question related to the image. \n3. Receive the generated answer.")
|
72 |
gr.Markdown("### Model Information: ")
|
73 |
gr.Markdown("The BLIP2 model combines vision and language understanding to generate answer based on the provided image and question.")
|
74 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
|
76 |
-
start_demo_button.click(fn=show_demo)
|
77 |
|
78 |
if __name__ == "__main__":
|
79 |
landing_page.launch()
|
|
|
53 |
|
54 |
return generated_answer[0] # Return the first (and typically only) generated answer
|
55 |
|
56 |
+
# Setting up the Gradio interface with Blocks
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
with gr.Blocks() as landing_page:
|
58 |
gr.Markdown("# Welcome to the Visual Question Answering Demo")
|
59 |
gr.Markdown("This demo uses the customized BLIP2 model to answer questions about images.")
|
|
|
61 |
gr.Markdown("1. Upload an image. \n2. Enter a question related to the image. \n3. Receive the generated answer.")
|
62 |
gr.Markdown("### Model Information: ")
|
63 |
gr.Markdown("The BLIP2 model combines vision and language understanding to generate answer based on the provided image and question.")
|
64 |
+
|
65 |
+
with gr.Column():
|
66 |
+
start_demo_button = gr.Button("Start Demo")
|
67 |
+
|
68 |
+
# Hide the actual demo interface initially
|
69 |
+
demo_interface = gr.Interface(
|
70 |
+
fn=generate_answer_blip2,
|
71 |
+
inputs=[gr.Image(label="Upload Image"), gr.Textbox(label="Enter your question")],
|
72 |
+
outputs=gr.Textbox(label="Generated Answer"),
|
73 |
+
title="Visual Question Answering with DeiT-BLIP2 Model",
|
74 |
+
description="Upload an image and type a related question to receive an answer generated by the model."
|
75 |
+
).style(visible=False)
|
76 |
+
|
77 |
+
def show_demo():
|
78 |
+
demo_interface.update(visible=True)
|
79 |
|
80 |
+
start_demo_button.click(fn=show_demo, inputs=None, outputs=None)
|
81 |
|
82 |
if __name__ == "__main__":
|
83 |
landing_page.launch()
|