Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -29,8 +29,6 @@ model.eval()
|
|
29 |
view_flag = True
|
30 |
skip = False
|
31 |
|
32 |
-
left_column, right_column = st.columns(2)
|
33 |
-
|
34 |
def predict_image(img):
|
35 |
img = img.convert('RGB')
|
36 |
img_transformed = transform(img)
|
@@ -41,10 +39,9 @@ def predict_image(img):
|
|
41 |
return preds.item()
|
42 |
uploaded_file = st.file_uploader('Choose an image...', type=['jpg', 'png'])
|
43 |
if uploaded_file:
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
pred = predict_image(img)
|
48 |
if pred == 0:
|
49 |
season_type = "็ง"
|
50 |
elif pred == 1:
|
@@ -57,35 +54,43 @@ if uploaded_file:
|
|
57 |
st.session_state.show_video = False
|
58 |
if 'skip' not in st.session_state:
|
59 |
st.session_state.skip = False
|
|
|
|
|
60 |
|
61 |
person_result = st.selectbox(
|
62 |
'็ตๆใฎไฟฎๆญฃ',
|
63 |
('ๆฅ', 'ๅค', '็ง', 'ๅฌ')
|
64 |
-
|
65 |
|
66 |
if person_result:
|
67 |
season_type = person_result
|
68 |
|
69 |
-
|
70 |
-
|
|
|
|
|
|
|
|
|
|
|
71 |
|
72 |
-
|
73 |
view_recommend = st.button("ใใใใใฎๅๅใ่ฆใ")
|
74 |
-
with right_column:
|
75 |
if view_recommend:
|
76 |
st.session_state.show_video = True
|
77 |
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
|
|
|
|
|
29 |
view_flag = True
|
30 |
skip = False
|
31 |
|
|
|
|
|
32 |
def predict_image(img):
|
33 |
img = img.convert('RGB')
|
34 |
img_transformed = transform(img)
|
|
|
39 |
return preds.item()
|
40 |
uploaded_file = st.file_uploader('Choose an image...', type=['jpg', 'png'])
|
41 |
if uploaded_file:
|
42 |
+
img = Image.open(uploaded_file)
|
43 |
+
st.image(img, caption="Uploaded Image", use_column_width=True)
|
44 |
+
pred = predict_image(img)
|
|
|
45 |
if pred == 0:
|
46 |
season_type = "็ง"
|
47 |
elif pred == 1:
|
|
|
54 |
st.session_state.show_video = False
|
55 |
if 'skip' not in st.session_state:
|
56 |
st.session_state.skip = False
|
57 |
+
if 'result' not in st.session_state:
|
58 |
+
st.session_state.result = False
|
59 |
|
60 |
person_result = st.selectbox(
|
61 |
'็ตๆใฎไฟฎๆญฃ',
|
62 |
('ๆฅ', 'ๅค', '็ง', 'ๅฌ')
|
63 |
+
)
|
64 |
|
65 |
if person_result:
|
66 |
season_type = person_result
|
67 |
|
68 |
+
st.write(f"ใใผใฝใใซใซใฉใผใฏ {season_type} ใงใ")
|
69 |
+
|
70 |
+
# ใใใใใฎๅๅใ่ฆใใใฟใณ
|
71 |
+
view_result = st.button("่จบๆญ็ตๆ่ฉณ็ดฐ & ใใใใๅๅใ่ฆใ")
|
72 |
+
if view_result or st.session_state.result:
|
73 |
+
st.session_state.result = True
|
74 |
+
st.image(f"{season_type}.png")
|
75 |
|
76 |
+
if st.session_state.result and not st.session_state.show_video:
|
77 |
view_recommend = st.button("ใใใใใฎๅๅใ่ฆใ")
|
|
|
78 |
if view_recommend:
|
79 |
st.session_state.show_video = True
|
80 |
|
81 |
+
# ในใญใใใใใใซๅ็ปใ่กจ็คบใใ
|
82 |
+
if st.session_state.show_video and not st.session_state.skip:
|
83 |
+
st.video("sample.mp4", start_time=0)
|
84 |
|
85 |
+
# ๅ็ปใฎในใญใใใใฟใณใๆผใใใใใใฌใณใกใณใๆใ่กจ็คบใใ
|
86 |
+
if st.session_state.show_video and not st.session_state.skip:
|
87 |
+
time.sleep(5)
|
88 |
+
st.session_state.show_video = False
|
89 |
+
st.session_state.skip = True
|
90 |
+
if st.session_state.skip:
|
91 |
+
st.write(
|
92 |
+
"""
|
93 |
+
ใใใใใฎๅๅใงใใ
|
94 |
+
""")
|
95 |
+
st.image("ๆ.png")
|
96 |
+
|