Spaces:
Runtime error
Runtime error
BennoKrojer
commited on
Commit
•
1c0adda
1
Parent(s):
4fbf998
app.py
CHANGED
@@ -22,8 +22,7 @@ prefix = 'https://raw.githubusercontent.com/BennoKrojer/imagecode-val-set/main/i
|
|
22 |
set2ids = json.load(open('set2ids.json', 'r'))
|
23 |
descriptions = json.load(open('valid_list.json', 'r'))
|
24 |
|
25 |
-
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]
|
29 |
idx = int(idx)
|
@@ -33,11 +32,11 @@ img_urls = images.copy()
|
|
33 |
col1.markdown(f'**Description**:')
|
34 |
col1.markdown(descr)
|
35 |
|
36 |
-
img = images[index]
|
37 |
-
images[index] = ImageOps.expand(Image.open(io.BytesIO(requests.get(images[index], stream=True).content)),border=20,fill='blue')
|
38 |
|
39 |
caps = list(range(10))
|
40 |
-
cap = str(index)
|
41 |
|
42 |
col1.image(img, use_column_width=True, caption=cap)
|
43 |
col2.image(images, width=175, caption=caps)
|
|
|
22 |
set2ids = json.load(open('set2ids.json', 'r'))
|
23 |
descriptions = json.load(open('valid_list.json', 'r'))
|
24 |
|
25 |
+
st.session_state.index = int(col2.number_input('Image Index from 0 to 9', value=0, min_value=0, max_value=9))
|
|
|
26 |
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))
|
27 |
img_set, idx, descr = descriptions[example_idx]
|
28 |
idx = int(idx)
|
|
|
32 |
col1.markdown(f'**Description**:')
|
33 |
col1.markdown(descr)
|
34 |
|
35 |
+
img = images[st.session_state.index]
|
36 |
+
images[st.session_state.index] = ImageOps.expand(Image.open(io.BytesIO(requests.get(images[st.session_state.index], stream=True).content)),border=20,fill='blue')
|
37 |
|
38 |
caps = list(range(10))
|
39 |
+
cap = str(st.session_state.index)
|
40 |
|
41 |
col1.image(img, use_column_width=True, caption=cap)
|
42 |
col2.image(images, width=175, caption=caps)
|