Spaces:
Sleeping
Sleeping
#!/usr/bin/env python | |
import pathlib | |
import gradio as gr | |
paths = [path.as_posix() for path in sorted(pathlib.Path('images').glob('*'))] | |
def fn(data: gr.SelectData) -> int: | |
return data.index | |
with gr.Blocks() as demo: | |
images = gr.Gallery(value=paths).style(grid=3) | |
selected = gr.Text(label='selected index') | |
images.select(fn=fn, outputs=selected) | |
demo.queue(api_open=False).launch() | |