m7mdal7aj commited on
Commit
ad47766
1 Parent(s): c549dc5
Files changed (1) hide show
  1. test.py +29 -0
test.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from transformers import pipline
3
+
4
+ pipe = pipeline("image-to-text", model="Salesforce/blip2-opt-2.7b")
5
+
6
+
7
+
8
+ def answer_question(image, question):
9
+ # Integrate your model logic here
10
+ answer = "This is where the answer will appear."
11
+ return answer
12
+
13
+ st.title("Image Question Answering")
14
+
15
+ # File uploader for the image
16
+ image = st.file_uploader("Upload an image", type=["png", "jpg", "jpeg"])
17
+
18
+ # Text input for the question
19
+ question = st.text_input("Enter your question about the image:")
20
+
21
+ if st.button("Get Answer"):
22
+ if image is not None and question:
23
+ # Display the image
24
+ st.image(image, use_column_width=True)
25
+ # Get and display the answer
26
+ answer = answer_question(image, question)
27
+ st.write(answer)
28
+ else:
29
+ st.write("Please upload an image and enter a question.")