Spaces:
Runtime error
Runtime error
Commit ·
a99f6a6
1
Parent(s): 31fec50
20 unmodified lines21222324252627283 unmodified lines323334353637381 unmodified line404142434445464748495051525354555620 unmodified linesset2ids = json.load(open('set2ids.json', 'r'))descriptions = json.load(open('valid_list.json', 'r'))show = col1.button("Show groundtruth image index")hide = col2.button('Hide groundtruth image index')example = int()example_idx = int(col1.number_input('Sample an example from the validation set', value=0, min_value=0, max_value=len(descriptions)-1))3 unmodified linesimg_urls = images.copy()index = int(col2.number_input('Image Index from 0 to 9', value=0, min_value=0, max_value=len(images)-1))col1.subheader(descr)img = images[index]images[index] = ImageOps.expand(Image.open(io.BytesIO(requests.get(images[index], stream=True).content)),border=20,fill='blue')1 unmodified linecaps = list(range(10))cap = str(index)if show:if index == idx:cap = f'{index} (GROUNDTRUTH)'caps[idx] = f'{idx} (GROUNDTRUTH)'images[idx] = ImageOps.expand(Image.open(io.BytesIO(requests.get(img_urls[index], stream=True).content)),border=50,fill='green')if hide:if index == idx:cap = f'{index}'caps[idx] = f'{idx}'images[idx] = Image.open(io.BytesIO(requests.get(img_urls[index], stream=True).content))# shown = True if len(caps[idx]) > 2 else False# if showncol1.image(img, use_column_width=True, caption=cap)col2.image(images, width=175, caption=caps)20 unmodified lines212223242526273 unmodified lines313233343536371 unmodified line3940414243444520 unmodified linesset2ids = json.load(open('set2ids.json', 'r'))descriptions = json.load(open('valid_list.json', 'r'))st.markdown("This is a demo of the *ImageCoDe* dataset. Sample an example description with the left +/- button on the right and compare all the images with the +/- button on the right. If you want to know the groundtruth solution, scroll down to the end of the page!")example = int()example_idx = int(col1.number_input('Sample an example from the validation set', value=0, min_value=0, max_value=len(descriptions)-1))3 unmodified linesimg_urls = images.copy()index = int(col2.number_input('Image Index from 0 to 9', value=0, min_value=0, max_value=len(images)-1))col1.text(f'Description: {descr}')img = images[index]images[index] = ImageOps.expand(Image.open(io.BytesIO(requests.get(images[index], stream=True).content)),border=20,fill='blue')1 unmodified linecaps = list(range(10))cap = str(index)col1.image(img, use_column_width=True, caption=cap)col2.image(images, width=175, caption=caps)st.markdown('#')
app.py+4-15