Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| def func(iters, progress=gr.Progress()): | |
| print(f"iters: {iters}, type: {type(iters)}") | |
| for i in progress.tqdm(range(iters), desc="Looping"): | |
| print(f"i: {i}, type: {type(i)}") | |
| if not isinstance(i, int): | |
| return f"BUG! i is {type(i)}" | |
| return "OK" | |
| with gr.Blocks() as demo: | |
| gr.Markdown("Bug Reproduction: `gr.Progress.tqdm` with `gr.Examples`\n") | |
| iters_input = gr.Number(value=3, label="Iterations") | |
| out = gr.Textbox(label="Output") | |
| btn = gr.Button() | |
| btn.click(func, [iters_input], out) | |
| gr.Examples( | |
| examples=[[5], [2]], | |
| inputs=[iters_input], | |
| outputs=[out], | |
| fn=func | |
| ) | |
| demo.launch() |