Spaces:
Runtime error
Runtime error
File size: 1,372 Bytes
61c7634 e15dae8 c9911aa 17bb1f6 fae45ed 61c7634 236866f fae45ed 61c7634 e15dae8 62635cf 17bb1f6 61c7634 62635cf 236866f a19e716 0b7b279 61c7634 62635cf 61c7634 4b1c134 236866f 62635cf c3ace54 be96cc4 c9911aa c3ace54 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
from turtle import color, onclick
import streamlit as st
from PIL import Image, ImageOps
import glob
import json
import requests
import random
import io
import streamlit.components.v1 as components
def sample():
img_set = random.sample(list(set2ids.keys()),1)[0]
prefix = 'https://raw.githubusercontent.com/BennoKrojer/imagecode-val-set/main/image-sets-val/'
set2ids = json.load(open('set2ids.json', 'r'))
img_set = random.sample(list(set2ids.keys()),1)[0]
st.set_page_config(layout="wide")
col1, col2 = st.columns(2)
images = [prefix+'/'+img_set+'/'+i for i in set2ids['MSR-VTT-videoTestVideo_video7016-shot1_2']]
if st.button('Sample set of images with contextual description'):
img_set = random.sample(list(set2ids.keys()),1)[0]
index= int(col1.number_input('Image Index from 0 to 9', value=0, min_value=0, max_value=len(images)-1))
# components.html(
# """
# <script>
# const elements = window.parent.document.querySelectorAll('.stNumberInput div[data-baseweb="input"] > div')
# console.log(elements)
# elements[1].style.backgroundColor = 'red'
# </script>
# """,
# height=0,
# width=0,
# )
img = images[index]
images[index] = ImageOps.expand(Image.open(io.BytesIO(requests.get(images[index], stream=True).content)),border=10,fill='blue')
col1.image(img, use_column_width=True)
col2.image(images, width=150, caption=list(range(10)))
|