Polo123 commited on
Commit
affae7d
1 Parent(s): d3bad0d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -1
app.py CHANGED
@@ -5,7 +5,7 @@ from logic import *
5
  model, processor= load_Model()
6
 
7
  def load_image(img):
8
- im = Image.open(img)
9
  return im
10
 
11
  st.title('Ask Image Questions UDOP')
@@ -15,6 +15,15 @@ if uploaded_file is not None:
15
  img = load_image(uploaded_file)
16
  st.image(img)
17
  st.write("Image Uploaded Successfully")
 
 
 
 
 
 
 
 
 
18
 
19
 
20
 
 
5
  model, processor= load_Model()
6
 
7
  def load_image(img):
8
+ im = Image.open(img).convert("RGB")
9
  return im
10
 
11
  st.title('Ask Image Questions UDOP')
 
15
  img = load_image(uploaded_file)
16
  st.image(img)
17
  st.write("Image Uploaded Successfully")
18
+ with st.form("my_form"):
19
+ user_query = st.text_input("Ask the image")
20
+
21
+ new_submitted = st.form_submit_button("Submit")
22
+ if new_submitted:
23
+ encoding = processor(images=img, text=user_query, return_tensors="pt")
24
+ outputs = model.generate(**encoding, max_new_tokens=20)
25
+ generated_text = processor.batch_decode(outputs, skip_special_tokens=True)[0]
26
+ st.write(generated_text)
27
 
28
 
29