usernameisanna commited on
Commit
b85d146
·
verified ·
1 Parent(s): bafc67a

update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -8
app.py CHANGED
@@ -54,13 +54,26 @@ def generate_answer_blip2(image, question):
54
  return generated_answer[0] # Return the first (and typically only) generated answer
55
 
56
  # Setting up the Gradio interface
57
- iface = gr.Interface(
58
- fn=generate_answer_blip2,
59
- inputs=[gr.Image(label="Upload Image"), gr.Textbox(label="Enter your question")],
60
- outputs=gr.Textbox(label="Generated Answer"),
61
- title="Visual Question Answering with DeiT-BLIP2 Model",
62
- description="Upload an image and type a related question to receive an answer generated by the model."
63
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
64
 
65
  if __name__ == "__main__":
66
- iface.launch()
 
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.")
70
+ gr.Markdown("### How to Use: ")
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
+ start_demo_button = gr.Button("Start Demo")
75
+
76
+ start_demo_button.click(fn=show_demo)
77
 
78
  if __name__ == "__main__":
79
+ landing_page.launch()