Spaces:
Runtime error
Runtime error
BennoKrojer
commited on
Commit
•
236866f
1
Parent(s):
4b1c134
app.py
CHANGED
@@ -5,6 +5,9 @@ import glob
|
|
5 |
import json
|
6 |
import requests
|
7 |
import random
|
|
|
|
|
|
|
8 |
|
9 |
def sample():
|
10 |
img_set = random.sample(list(set2ids.keys()),1)[0]
|
@@ -13,6 +16,7 @@ prefix = 'https://raw.githubusercontent.com/BennoKrojer/imagecode-val-set/main/i
|
|
13 |
set2ids = json.load(open('set2ids.json', 'r'))
|
14 |
img_set = random.sample(list(set2ids.keys()),1)[0]
|
15 |
|
|
|
16 |
st.set_page_config(layout="wide")
|
17 |
col1, col2 = st.columns(2)
|
18 |
|
@@ -22,9 +26,21 @@ if st.button('Sample set of images with contextual description'):
|
|
22 |
img_set = random.sample(list(set2ids.keys()),1)[0]
|
23 |
|
24 |
index= int(col1.number_input('Image Index from 0 to 9', value=0, min_value=0, max_value=len(images)-1))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
|
26 |
img = images[index]
|
27 |
-
images[index] = ImageOps.expand(Image.open(requests.get(images[index], stream=True)
|
28 |
|
29 |
col1.image(img, use_column_width=True)
|
30 |
col2.image(images, width=150, caption=list(range(10)))
|
|
|
5 |
import json
|
6 |
import requests
|
7 |
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]
|
|
|
16 |
set2ids = json.load(open('set2ids.json', 'r'))
|
17 |
img_set = random.sample(list(set2ids.keys()),1)[0]
|
18 |
|
19 |
+
|
20 |
st.set_page_config(layout="wide")
|
21 |
col1, col2 = st.columns(2)
|
22 |
|
|
|
26 |
img_set = random.sample(list(set2ids.keys()),1)[0]
|
27 |
|
28 |
index= int(col1.number_input('Image Index from 0 to 9', value=0, min_value=0, max_value=len(images)-1))
|
29 |
+
# components.html(
|
30 |
+
# """
|
31 |
+
# <script>
|
32 |
+
# const elements = window.parent.document.querySelectorAll('.stNumberInput div[data-baseweb="input"] > div')
|
33 |
+
# console.log(elements)
|
34 |
+
# elements[1].style.backgroundColor = 'red'
|
35 |
+
# </script>
|
36 |
+
# """,
|
37 |
+
# height=0,
|
38 |
+
# width=0,
|
39 |
+
# )
|
40 |
+
|
41 |
|
42 |
img = images[index]
|
43 |
+
images[index] = ImageOps.expand(Image.open(io.BytesIO(requests.get(images[index], stream=True))),border=10,fill='blue')
|
44 |
|
45 |
col1.image(img, use_column_width=True)
|
46 |
col2.image(images, width=150, caption=list(range(10)))
|