Spaces:
Runtime error
Runtime error
Commit
·
5c5bd98
1
Parent(s):
bb74091
app.py
CHANGED
|
@@ -8,56 +8,23 @@ import random
|
|
| 8 |
import io
|
| 9 |
import streamlit.components.v1 as components
|
| 10 |
|
| 11 |
-
|
| 12 |
-
def sample():
|
| 13 |
-
img_set = random.sample(list(set2ids.keys()),1)[0]
|
| 14 |
-
|
| 15 |
prefix = 'https://raw.githubusercontent.com/BennoKrojer/imagecode-val-set/main/image-sets-val/'
|
| 16 |
set2ids = json.load(open('set2ids.json', 'r'))
|
| 17 |
-
descriptions = json.load(open('
|
| 18 |
-
img_set = 'YouCook-video0034-shot13_0'
|
| 19 |
-
descr = list(descriptions[img_set].values())[0]
|
| 20 |
-
|
| 21 |
-
|
| 22 |
st.set_page_config(layout="wide")
|
| 23 |
col1, col2 = st.columns(2)
|
| 24 |
|
|
|
|
|
|
|
|
|
|
| 25 |
images = [prefix+'/'+img_set+'/'+i for i in set2ids[img_set]]
|
|
|
|
| 26 |
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
if sample_button:
|
| 30 |
-
img_set = random.sample(list(set2ids.keys()),1)[0]
|
| 31 |
-
descr = random.sample(list(descriptions[img_set].values()),1)[0]
|
| 32 |
-
col1.subheader(descr)
|
| 33 |
-
index= int(col1.number_input('Image Index from 0 to 9', value=0, min_value=0, max_value=len(images)-1))
|
| 34 |
-
images = [prefix+'/'+img_set+'/'+i for i in set2ids[img_set]]
|
| 35 |
-
img = images[index]
|
| 36 |
-
images[index] = ImageOps.expand(Image.open(io.BytesIO(requests.get(images[index], stream=True).content)),border=10,fill='blue')
|
| 37 |
-
|
| 38 |
-
col1.image(img, use_column_width=True)
|
| 39 |
-
caps = list(range(10))
|
| 40 |
-
col2.image(images, width=175, caption=caps)
|
| 41 |
-
|
| 42 |
-
else:
|
| 43 |
-
col1.subheader(descr)
|
| 44 |
-
index= int(col1.number_input('Image Index from 0 to 9', value=0, min_value=0, max_value=len(images)-1))
|
| 45 |
-
components.html(
|
| 46 |
-
"""
|
| 47 |
-
<script>
|
| 48 |
-
const elements = window.parent.document.querySelectorAll('.stNumberInput div[data-baseweb="input"] > div')
|
| 49 |
-
console.log(elements)
|
| 50 |
-
elements[1].style.backgroundColor = 'red'
|
| 51 |
-
</script>
|
| 52 |
-
""",
|
| 53 |
-
height=0,
|
| 54 |
-
width=0,
|
| 55 |
-
)
|
| 56 |
-
|
| 57 |
|
| 58 |
-
|
| 59 |
-
|
| 60 |
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
|
|
|
| 8 |
import io
|
| 9 |
import streamlit.components.v1 as components
|
| 10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
prefix = 'https://raw.githubusercontent.com/BennoKrojer/imagecode-val-set/main/image-sets-val/'
|
| 12 |
set2ids = json.load(open('set2ids.json', 'r'))
|
| 13 |
+
descriptions = json.load(open('valid_list.json', 'r'))
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
st.set_page_config(layout="wide")
|
| 15 |
col1, col2 = st.columns(2)
|
| 16 |
|
| 17 |
+
example = int()
|
| 18 |
+
example_idx = int(col1.number_input('Sample an example from the validation set', value=0, min_value=0, max_value=len(descriptions)-1))
|
| 19 |
+
img_set, idx, descr = list(descriptions.items())[example_idx]
|
| 20 |
images = [prefix+'/'+img_set+'/'+i for i in set2ids[img_set]]
|
| 21 |
+
index = int(col1.number_input('Image Index from 0 to 9', value=0, min_value=0, max_value=len(images)-1))
|
| 22 |
|
| 23 |
+
col1.subheader(descr)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
|
| 25 |
+
img = images[index]
|
| 26 |
+
images[index] = ImageOps.expand(Image.open(io.BytesIO(requests.get(images[index], stream=True).content)),border=10,fill='blue')
|
| 27 |
|
| 28 |
+
col1.image(img, use_column_width=True)
|
| 29 |
+
caps = list(range(10))
|
| 30 |
+
col2.image(images, width=175, caption=caps)
|