Spaces:
Runtime error
Runtime error
Commit
·
34700d7
1
Parent(s):
8465f52
app.py
CHANGED
|
@@ -10,8 +10,11 @@ import io
|
|
| 10 |
if 'show' not in st.session_state:
|
| 11 |
st.session_state.show = False
|
| 12 |
|
|
|
|
|
|
|
|
|
|
| 13 |
st.set_page_config(layout="wide")
|
| 14 |
-
st.markdown("**This is a demo of the *ImageCoDe* dataset. Sample an example
|
| 15 |
|
| 16 |
col1, col2 = st.columns(2)
|
| 17 |
|
|
@@ -21,15 +24,18 @@ descriptions = json.load(open('valid_list.json', 'r'))
|
|
| 21 |
|
| 22 |
if col1.button('Show groundtruth target image'):
|
| 23 |
st.session_state.show = True
|
| 24 |
-
if
|
| 25 |
st.session_state.show = False
|
| 26 |
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
|
|
|
| 30 |
idx = int(idx)
|
| 31 |
images = [prefix+'/'+img_set+'/'+i for i in set2ids[img_set]]
|
| 32 |
img_urls = images.copy()
|
|
|
|
|
|
|
| 33 |
|
| 34 |
col1.markdown(f'**Description**:')
|
| 35 |
col1.markdown(descr)
|
|
@@ -51,17 +57,3 @@ else:
|
|
| 51 |
|
| 52 |
col1.image(img, use_column_width=True, caption=cap)
|
| 53 |
col2.image(images, width=175, caption=caps)
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
# st.markdown('#')
|
| 58 |
-
# st.markdown('#')
|
| 59 |
-
# st.markdown('#')
|
| 60 |
-
# st.markdown('#')
|
| 61 |
-
# st.markdown('#')
|
| 62 |
-
# st.markdown('#')
|
| 63 |
-
# st.markdown('#')
|
| 64 |
-
# st.markdown('#')
|
| 65 |
-
# st.markdown('#')
|
| 66 |
-
# st.markdown('#')
|
| 67 |
-
# st.markdown(f'**The correct target image index is: {idx}**')
|
|
|
|
| 10 |
if 'show' not in st.session_state:
|
| 11 |
st.session_state.show = False
|
| 12 |
|
| 13 |
+
if 'example_idx' not in st.session_state:
|
| 14 |
+
st.sesseion_state.example_idx = 0
|
| 15 |
+
|
| 16 |
st.set_page_config(layout="wide")
|
| 17 |
+
st.markdown("**This is a demo of the *ImageCoDe* dataset. Sample an example with the counter on the right and compare all the images with index counter on the right. Toggle the buttons to show/hide the groundtruth target image!**")
|
| 18 |
|
| 19 |
col1, col2 = st.columns(2)
|
| 20 |
|
|
|
|
| 24 |
|
| 25 |
if col1.button('Show groundtruth target image'):
|
| 26 |
st.session_state.show = True
|
| 27 |
+
if col2.button('Hide groundtruth target image'):
|
| 28 |
st.session_state.show = False
|
| 29 |
|
| 30 |
+
# example_idx = int(col1.number_input('Sample an example (description + corresponding images) from the validation set', value=0, min_value=0, max_value=len(descriptions)-1))
|
| 31 |
+
if col1.button('Sample an example (description + corresponding images) from the validation set'):
|
| 32 |
+
st.session_state.example_idx = random.randint(0, len(descriptions)-1)
|
| 33 |
+
img_set, idx, descr = descriptions[st.session_state.example_idx]
|
| 34 |
idx = int(idx)
|
| 35 |
images = [prefix+'/'+img_set+'/'+i for i in set2ids[img_set]]
|
| 36 |
img_urls = images.copy()
|
| 37 |
+
index = int(col2.number_input('Image Index from 0 to 9', value=0, min_value=0, max_value=9))
|
| 38 |
+
|
| 39 |
|
| 40 |
col1.markdown(f'**Description**:')
|
| 41 |
col1.markdown(descr)
|
|
|
|
| 57 |
|
| 58 |
col1.image(img, use_column_width=True, caption=cap)
|
| 59 |
col2.image(images, width=175, caption=caps)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|