Spaces:
Running
Running
truong-xuan-linh
commited on
Commit
•
9301987
1
Parent(s):
c1b4f26
update imagwe
Browse files- app.py +24 -10
- images/000000000008.jpg +0 -0
- images/000000000012.jpg +0 -0
- images/000000000016.jpg +0 -0
- images/000000000019.jpg +0 -0
- images/000000000181.jpg +0 -0
- requirements.txt +3 -1
app.py
CHANGED
@@ -1,12 +1,14 @@
|
|
|
|
1 |
import streamlit as st
|
2 |
-
|
|
|
3 |
|
4 |
#Trick to not init function multitime
|
5 |
-
if "model" not in st.session_state:
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
|
11 |
st.set_page_config(page_title="VQA", layout="wide")
|
12 |
hide_menu_style = """
|
@@ -16,8 +18,16 @@ footer {visibility: hidden;}
|
|
16 |
"""
|
17 |
st.markdown(hide_menu_style, unsafe_allow_html= True)
|
18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
|
20 |
image = st.file_uploader("Choose an image file", type=["jpg", "jpeg", "png", "webp", ])
|
|
|
21 |
|
22 |
if image:
|
23 |
bytes_data = image.getvalue()
|
@@ -25,11 +35,15 @@ if image:
|
|
25 |
f.write(bytes_data)
|
26 |
f.close()
|
27 |
st.session_state.image = "test.png"
|
|
|
|
|
|
|
|
|
28 |
|
29 |
if 'image' in st.session_state:
|
30 |
st.image(st.session_state.image)
|
31 |
-
question = st.text_input("Question: ")
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
|
|
|
1 |
+
import glob
|
2 |
import streamlit as st
|
3 |
+
|
4 |
+
from streamlit_image_select import image_select
|
5 |
|
6 |
#Trick to not init function multitime
|
7 |
+
# if "model" not in st.session_state:
|
8 |
+
# print("INIT MODEL")
|
9 |
+
# from src.model import Model
|
10 |
+
# st.session_state.model = Model()
|
11 |
+
# print("DONE INIT MODEL")
|
12 |
|
13 |
st.set_page_config(page_title="VQA", layout="wide")
|
14 |
hide_menu_style = """
|
|
|
18 |
"""
|
19 |
st.markdown(hide_menu_style, unsafe_allow_html= True)
|
20 |
|
21 |
+
mapper = {
|
22 |
+
"images\\000000000008.jpg": "A",
|
23 |
+
"images\\000000000012.jpg": "B",
|
24 |
+
"images\\000000000016.jpg": "C",
|
25 |
+
"images\\000000000019.jpg": "D",
|
26 |
+
"images\\000000000181.jpg": "E"
|
27 |
+
}
|
28 |
|
29 |
image = st.file_uploader("Choose an image file", type=["jpg", "jpeg", "png", "webp", ])
|
30 |
+
example = image_select("Examples", glob.glob("images/*.jpg"))
|
31 |
|
32 |
if image:
|
33 |
bytes_data = image.getvalue()
|
|
|
35 |
f.write(bytes_data)
|
36 |
f.close()
|
37 |
st.session_state.image = "test.png"
|
38 |
+
st.session_state.question = ""
|
39 |
+
else:
|
40 |
+
st.session_state.question = mapper[example]
|
41 |
+
st.session_state.image = example
|
42 |
|
43 |
if 'image' in st.session_state:
|
44 |
st.image(st.session_state.image)
|
45 |
+
question = st.text_input("Question: ", value=st.session_state.question)
|
46 |
+
# if question:
|
47 |
+
# answer = st.session_state.model.inference(st.session_state.image, question)
|
48 |
+
# st.write(f"Answer: {answer}")
|
49 |
|
images/000000000008.jpg
ADDED
images/000000000012.jpg
ADDED
images/000000000016.jpg
ADDED
images/000000000019.jpg
ADDED
images/000000000181.jpg
ADDED
requirements.txt
CHANGED
@@ -2,4 +2,6 @@ paddlepaddle>=2.3.1
|
|
2 |
paddleocr==2.6.1.3
|
3 |
vietocr>=0.3.8
|
4 |
pillow==9.5.0
|
5 |
-
torchvision==0.18.0
|
|
|
|
|
|
2 |
paddleocr==2.6.1.3
|
3 |
vietocr>=0.3.8
|
4 |
pillow==9.5.0
|
5 |
+
torchvision==0.18.0
|
6 |
+
streamlit==1.35.0
|
7 |
+
transformers==4.41.2
|