gradio-app / gradio

Build and share delightful machine learning apps, all in Python. 🌟 Star to support our work!
http://www.gradio.app
Apache License 2.0
30.56k stars 2.27k forks source link

Add Progress Bar component #2750

Closed aliabid94 closed 1 year ago

aliabid94 commented 1 year ago

Add support for progressbar component. Feel free to leave feedback on API or visual design.

See example in demo/progress/run.py

Snippet for tqdm-like wrapper

def load_set(text, progress=gr.Progress()):
        imgs = [None] * 24
        for img in progress.tqdm(imgs, message="Loading from list"):
            time.sleep(0.1)
        return "done"
    load_set_btn.click(load_set, text, text2)

Snippet for explicit status:

def clean_imgs(text, progress=gr.Progress()):
        progress(0.2, message="Collecting Images")
        time.sleep(1)
        progress(0.5, message="Cleaning Images")
        time.sleep(1.5)
        progress(0.8, message="Sending Images")
        time.sleep(1.5)
        return "done"
    clean_imgs_btn.click(clean_imgs, text, text2)

Recording 2022-11-30 at 18 01 51

Closes: #340

abidlabs commented 1 year ago

Awesome PR @aliabid94! I left a lot of feedback since it's massive PR, but they're mostly pretty minor things. Overall, works great.

github-actions[bot] commented 1 year ago

The demo notebooks don't match the run.py files. Please run this command from the root of the repo and then commit the changes:

pip install nbformat && cd demo && python generate_notebooks.py
github-actions[bot] commented 1 year ago

The demo notebooks don't match the run.py files. Please run this command from the root of the repo and then commit the changes:

pip install nbformat && cd demo && python generate_notebooks.py
github-actions[bot] commented 1 year ago

The demo notebooks don't match the run.py files. Please run this command from the root of the repo and then commit the changes:

pip install nbformat && cd demo && python generate_notebooks.py
github-actions[bot] commented 1 year ago

The demo notebooks don't match the run.py files. Please run this command from the root of the repo and then commit the changes:

pip install nbformat && cd demo && python generate_notebooks.py
github-actions[bot] commented 1 year ago

The demo notebooks don't match the run.py files. Please run this command from the root of the repo and then commit the changes:

pip install nbformat && cd demo && python generate_notebooks.py
github-actions[bot] commented 1 year ago

The demo notebooks don't match the run.py files. Please run this command from the root of the repo and then commit the changes:

pip install nbformat && cd demo && python generate_notebooks.py
github-actions[bot] commented 1 year ago

The demo notebooks don't match the run.py files. Please run this command from the root of the repo and then commit the changes:

pip install nbformat && cd demo && python generate_notebooks.py
aliabid94 commented 1 year ago

I think I addressed every concern @abidlabs @freddyaboulton @aliabd, thanks for the feedback so far. if everything looks good to you guys, I'll merge in tomorrow