Spaces:
Sleeping
Sleeping
usernameisanna
commited on
Commit
•
87729ac
1
Parent(s):
342f42e
address new error - interface object has no attribute style
Browse files
app.py
CHANGED
@@ -53,6 +53,10 @@ 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 with Blocks
|
57 |
with gr.Blocks() as landing_page:
|
58 |
gr.Markdown("# Welcome to the Visual Question Answering Demo")
|
@@ -62,22 +66,18 @@ with gr.Blocks() as landing_page:
|
|
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 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
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()
|
|
|
53 |
|
54 |
return generated_answer[0] # Return the first (and typically only) generated answer
|
55 |
|
56 |
+
# Function to display the demo interface
|
57 |
+
def show_demo():
|
58 |
+
return gr.update(visible=True), gr.update(visible=True), gr.update(visible=True)
|
59 |
+
|
60 |
# Setting up the Gradio interface with Blocks
|
61 |
with gr.Blocks() as landing_page:
|
62 |
gr.Markdown("# Welcome to the Visual Question Answering Demo")
|
|
|
66 |
gr.Markdown("### Model Information: ")
|
67 |
gr.Markdown("The BLIP2 model combines vision and language understanding to generate answer based on the provided image and question.")
|
68 |
|
69 |
+
with gr.Column() as demo_column:
|
70 |
start_demo_button = gr.Button("Start Demo")
|
71 |
+
image_input = gr.Image(label="Upload Image", visible=False)
|
72 |
+
question_input = gr.Textbox(label="Enter your question", visible=False)
|
73 |
+
answer_output = gr.Textbox(label="Generated Answer", visible=False)
|
74 |
+
|
75 |
+
start_demo_button.click(fn=show_demo, inputs=None, outputs=[image_input, question_input, answer_output])
|
76 |
+
|
77 |
+
def generate_and_show_answer(image, question):
|
78 |
+
return generate_answer_blip2(image, question)
|
79 |
+
|
80 |
+
image_input.change(fn=generate_and_show_answer, inputs=[image_input, question_input], outputs=answer_output)
|
|
|
|
|
|
|
|
|
81 |
|
82 |
if __name__ == "__main__":
|
83 |
landing_page.launch()
|