SilvusTV commited on
Commit
64a6ef4
1 Parent(s): cc6cbbe

change response and reformat code

Browse files
Files changed (2) hide show
  1. app.py +3 -2
  2. image.py +3 -4
app.py CHANGED
@@ -1,5 +1,6 @@
1
  from image import *
2
  import streamlit as st
 
3
  # url = "https://i.imgur.com/qs0CxjE_d.webp?maxwidth=760&fidelity=grand"
4
  # text = "What is the two color's car ?"
5
 
@@ -8,5 +9,5 @@ st.write('Application starting...')
8
  text = st.text_input('Posez votre question (en anglais)')
9
  url = st.text_input('mettez le liens de votre image')
10
 
11
- if st.button('générer') :
12
- st.write(image(url, text))
 
1
  from image import *
2
  import streamlit as st
3
+
4
  # url = "https://i.imgur.com/qs0CxjE_d.webp?maxwidth=760&fidelity=grand"
5
  # text = "What is the two color's car ?"
6
 
 
9
  text = st.text_input('Posez votre question (en anglais)')
10
  url = st.text_input('mettez le liens de votre image')
11
 
12
+ if st.button('générer'):
13
+ st.write('response is :', image(url, text))
image.py CHANGED
@@ -1,6 +1,8 @@
1
  from transformers import ViltProcessor, ViltForQuestionAnswering
2
  import requests
3
  from PIL import Image
 
 
4
  def image(url, text):
5
  image = Image.open(requests.get(url, stream=True).raw)
6
  processor = ViltProcessor.from_pretrained("dandelin/vilt-b32-finetuned-vqa")
@@ -17,9 +19,6 @@ def image(url, text):
17
  print("image link:", url)
18
  print("Predicted answer:", model.config.id2label[idx])
19
 
20
- return "Predicted answer:", model.config.id2label[idx]
21
-
22
-
23
 
24
  # prepare image + question
25
-
 
1
  from transformers import ViltProcessor, ViltForQuestionAnswering
2
  import requests
3
  from PIL import Image
4
+
5
+
6
  def image(url, text):
7
  image = Image.open(requests.get(url, stream=True).raw)
8
  processor = ViltProcessor.from_pretrained("dandelin/vilt-b32-finetuned-vqa")
 
19
  print("image link:", url)
20
  print("Predicted answer:", model.config.id2label[idx])
21
 
22
+ return model.config.id2label[idx]
 
 
23
 
24
  # prepare image + question