Spaces:
Build error
Build error
taquynhnga
commited on
Commit
·
2ce58e1
1
Parent(s):
efd120a
Update pages/4_ImageNet1k.py
Browse files- pages/4_ImageNet1k.py +15 -9
pages/4_ImageNet1k.py
CHANGED
@@ -32,17 +32,23 @@ with col2:
|
|
32 |
image = None
|
33 |
with st.form("display image"):
|
34 |
img_index = st.text_input('Image ID to display')
|
35 |
-
|
36 |
-
img_index = int(img_index)
|
37 |
-
except:
|
38 |
-
pass
|
39 |
-
|
40 |
submitted = st.form_submit_button('Display this image')
|
|
|
|
|
41 |
if submitted:
|
42 |
-
|
43 |
-
|
44 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
if image != None:
|
46 |
st.image(image)
|
47 |
st.write('**Class label:** ', class_label)
|
48 |
-
st.write('\n**Class id:** ', str(class_id))
|
|
|
32 |
image = None
|
33 |
with st.form("display image"):
|
34 |
img_index = st.text_input('Image ID to display')
|
35 |
+
|
|
|
|
|
|
|
|
|
36 |
submitted = st.form_submit_button('Display this image')
|
37 |
+
error_container = st.empty()
|
38 |
+
|
39 |
if submitted:
|
40 |
+
try:
|
41 |
+
img_index = int(img_index)
|
42 |
+
if img_index > 50000 or img_index < 0:
|
43 |
+
error_container.error('The Image ID must be in range from 0 to 50000', icon="🚫")
|
44 |
+
else:
|
45 |
+
image = dataset_dict[img_index//10_000][img_index%10_000]['image']
|
46 |
+
class_label = dataset_dict[img_index//10_000][img_index%10_000]['label']
|
47 |
+
class_id = dataset_dict[img_index//10_000][img_index%10_000]['id']
|
48 |
+
except ValueError:
|
49 |
+
error_container.error('Please enter an integer number for Image ID', icon = "🚫")
|
50 |
+
|
51 |
if image != None:
|
52 |
st.image(image)
|
53 |
st.write('**Class label:** ', class_label)
|
54 |
+
st.write('\n**Class id:** ', str(class_id))
|