Spaces:
Runtime error
Runtime error
Commit
·
9ee262c
1
Parent(s):
45781ff
app.py
CHANGED
|
@@ -14,7 +14,9 @@ def sample():
|
|
| 14 |
|
| 15 |
prefix = 'https://raw.githubusercontent.com/BennoKrojer/imagecode-val-set/main/image-sets-val/'
|
| 16 |
set2ids = json.load(open('set2ids.json', 'r'))
|
|
|
|
| 17 |
img_set = 'YouCook-video0034-shot13_0'
|
|
|
|
| 18 |
|
| 19 |
|
| 20 |
st.set_page_config(layout="wide")
|
|
@@ -22,23 +24,24 @@ col1, col2 = st.columns(2)
|
|
| 22 |
|
| 23 |
images = [prefix+'/'+img_set+'/'+i for i in set2ids[img_set]]
|
| 24 |
|
| 25 |
-
|
|
|
|
| 26 |
|
| 27 |
if sample_button:
|
| 28 |
img_set = random.sample(list(set2ids.keys()),1)[0]
|
| 29 |
|
| 30 |
index= int(col1.number_input('Image Index from 0 to 9', value=0, min_value=0, max_value=len(images)-1))
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
|
| 43 |
|
| 44 |
img = images[index]
|
|
@@ -46,4 +49,4 @@ images[index] = ImageOps.expand(Image.open(io.BytesIO(requests.get(images[index]
|
|
| 46 |
|
| 47 |
col1.image(img, use_column_width=True)
|
| 48 |
caps = list(range(10))
|
| 49 |
-
col2.image(images, width=
|
|
|
|
| 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('valid_data.json', 'r'))
|
| 18 |
img_set = 'YouCook-video0034-shot13_0'
|
| 19 |
+
descr = list(descriptions[img_set].values())[0]
|
| 20 |
|
| 21 |
|
| 22 |
st.set_page_config(layout="wide")
|
|
|
|
| 24 |
|
| 25 |
images = [prefix+'/'+img_set+'/'+i for i in set2ids[img_set]]
|
| 26 |
|
| 27 |
+
col1.subheader(descr)
|
| 28 |
+
sample_button = col1.button('Sample set of images with contextual description')
|
| 29 |
|
| 30 |
if sample_button:
|
| 31 |
img_set = random.sample(list(set2ids.keys()),1)[0]
|
| 32 |
|
| 33 |
index= int(col1.number_input('Image Index from 0 to 9', value=0, min_value=0, max_value=len(images)-1))
|
| 34 |
+
components.html(
|
| 35 |
+
"""
|
| 36 |
+
<script>
|
| 37 |
+
const elements = window.parent.document.querySelectorAll('.stNumberInput div[data-baseweb="input"] > div')
|
| 38 |
+
console.log(elements)
|
| 39 |
+
elements[1].style.backgroundColor = 'red'
|
| 40 |
+
</script>
|
| 41 |
+
""",
|
| 42 |
+
height=0,
|
| 43 |
+
width=0,
|
| 44 |
+
)
|
| 45 |
|
| 46 |
|
| 47 |
img = images[index]
|
|
|
|
| 49 |
|
| 50 |
col1.image(img, use_column_width=True)
|
| 51 |
caps = list(range(10))
|
| 52 |
+
col2.image(images, width=175, caption=caps)
|