BennoKrojer commited on
Commit
4fbf998
1 Parent(s): 238016f
Files changed (1) hide show
  1. app.py +5 -12
app.py CHANGED
@@ -7,29 +7,22 @@ import requests
7
  import random
8
  import io
9
 
10
- index = 0
 
 
11
  def set_back():
12
- global index
13
- index = 0
14
 
15
  st.set_page_config(layout="wide")
16
  st.markdown("**This is a demo of the *ImageCoDe* dataset. Sample an example description with the left +/- button on the right and compare all the images with the +/- button on the right. If you want to know the groundtruth solution, scroll down to the end of the page!**")
17
 
18
  col1, col2 = st.columns(2)
19
 
20
- m = st.markdown("""
21
- <style>
22
- div.stButton > button:first-child {
23
- background-color: rgb(204, 49, 49);
24
- }
25
- </style>""", unsafe_allow_html=True)
26
-
27
  prefix = 'https://raw.githubusercontent.com/BennoKrojer/imagecode-val-set/main/image-sets-val/'
28
  set2ids = json.load(open('set2ids.json', 'r'))
29
  descriptions = json.load(open('valid_list.json', 'r'))
30
 
31
-
32
- example = int()
33
  index = int(col2.number_input('Image Index from 0 to 9', value=0, min_value=0, max_value=9))
34
  example_idx = int(col1.number_input('Sample an example from the validation set', value=0, min_value=0, max_value=len(descriptions)-1, on_change=set_back))
35
  img_set, idx, descr = descriptions[example_idx]
 
7
  import random
8
  import io
9
 
10
+ if 'index' not in st.session_state:
11
+ st.session_state.index = 0
12
+
13
  def set_back():
14
+ st.session_state.index = 0
 
15
 
16
  st.set_page_config(layout="wide")
17
  st.markdown("**This is a demo of the *ImageCoDe* dataset. Sample an example description with the left +/- button on the right and compare all the images with the +/- button on the right. If you want to know the groundtruth solution, scroll down to the end of the page!**")
18
 
19
  col1, col2 = st.columns(2)
20
 
 
 
 
 
 
 
 
21
  prefix = 'https://raw.githubusercontent.com/BennoKrojer/imagecode-val-set/main/image-sets-val/'
22
  set2ids = json.load(open('set2ids.json', 'r'))
23
  descriptions = json.load(open('valid_list.json', 'r'))
24
 
25
+ index = st.session_state.index
 
26
  index = int(col2.number_input('Image Index from 0 to 9', value=0, min_value=0, max_value=9))
27
  example_idx = int(col1.number_input('Sample an example from the validation set', value=0, min_value=0, max_value=len(descriptions)-1, on_change=set_back))
28
  img_set, idx, descr = descriptions[example_idx]