Pranav4datasc commited on
Commit
605c39b
1 Parent(s): a90d43c

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -7
app.py CHANGED
@@ -28,17 +28,19 @@ def get_answer(image,text):
28
 
29
  st.title("Visual Question Answering App")
30
  st.write("Update an image and enter qustion to get and answer")
 
 
31
 
32
 
33
  col1,col2 = st.columns(2)
34
 
35
  with col1:
36
- uploaded_file = st.file_uploader("Upload your own image",type=['jpg','png','jpeg'])
37
  st.image(uploaded_file,use_column_width=True)
38
 
39
  with col2:
40
  question = st.text_input("Question")
41
-
42
  if uploaded_file and question is not None:
43
  if st.button("Ask Question"):
44
  image = Image.open(uploaded_file)
@@ -46,11 +48,14 @@ with col2:
46
  image.save(image_byte_array,format="JPEG")
47
  image_bytes = image_byte_array.getvalue()
48
 
49
-
50
- answer = get_answer(image_bytes,question)
51
  #st.show(answer)
52
- st.info("Your Question:" + question)
53
- st.success("Answer:" + answer)
54
-
 
 
 
 
55
 
56
 
 
28
 
29
  st.title("Visual Question Answering App")
30
  st.write("Update an image and enter qustion to get and answer")
31
+ st.caption("Sample image...")
32
+ st.image("tulips.jpg",width=600)
33
 
34
 
35
  col1,col2 = st.columns(2)
36
 
37
  with col1:
38
+ uploaded_file = st.file_uploader("Upload your own image or simply drag sample image given above",type=['jpg','png','jpeg'])
39
  st.image(uploaded_file,use_column_width=True)
40
 
41
  with col2:
42
  question = st.text_input("Question")
43
+ #st.text(question)
44
  if uploaded_file and question is not None:
45
  if st.button("Ask Question"):
46
  image = Image.open(uploaded_file)
 
48
  image.save(image_byte_array,format="JPEG")
49
  image_bytes = image_byte_array.getvalue()
50
 
51
+
 
52
  #st.show(answer)
53
+ st.info("Your Question is ..." + question)
54
+ answer = get_answer(image_bytes,question)
55
+ if answer is not None:
56
+ #st.text(answer)
57
+ st.info("Answer is ..."+ answer)
58
+ else:
59
+ st.text("Sorry I am not able to answer that question")
60
 
61