-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Progress Bar component #2750
Conversation
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 |
All the demos for this PR have been deployed at https://huggingface.co/spaces/gradio-pr-deploys/pr-2750-all-demos |
gradio/components.py
Outdated
): | ||
""" | ||
Parameters: | ||
value: Default text for the button to display. If callable, the function will be called whenever the app loads to set the initial value of the component. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
value: Default text for the button to display. If callable, the function will be called whenever the app loads to set the initial value of the component. | |
value: value of the progress bar -- should be a `float` between 0 or 1. |
gradio/components.py
Outdated
|
||
def __init__( | ||
self, | ||
value: float | None = 0, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does None
do?
That was fast @aliabid94! Backend code looks good (left some nits), but will let @pngwn or @gary149 advise on the frontend and design. Can we release a beta version with this so that @apolinario can use it for dreambooth? |
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 |
Discussed further with @aliabid94 and we're rethinking this approach. Rather than That being said, we've released |
First of all: thanks for turning this around in record time! Some thoughts:
|
Oh I really like the idea of tqdm integration, will look into that! |
+1 on the tqdm integration Not sure about having two different ways of showing progress bars though. I prefer having a single way unless there is a strong advantage to have a separate progress bar component. I know AUTOMATIC1111 GUI has a progress bar, but wouldn't it be better if the progress bar is incorporated into the output component itself, as is our current status tracker? |
I'm a bit confused here. The I thought the requests we have had a few times is for a separate |
This has really been my position all along but as above, the |
Yes so to summarize my takeaways:
How does that sound @aliabid94? |
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 |
Thing is with tqdm is that this isn't really true:
We would have to pass that information down to the component and render it in some way, so we'd need to support a vast array of inputs in the UI. We aren't just taking the default tqdm output and rendering it directly into the webpage somehow, we need to take the data is spits out and do something with it. I'm strongly against dumping the stdout text into the page, i think it looks really bad and goes against the whole point of gradio. These UIs are for anyone, not just people familiar with typical CLI outputs. This needs designing properly before being included. cc @gary149 If we are going to add this can we get some API + design proposals as well as breakdown of the various possible bits of UI that we would render based on the tqdm options the user passes? |
Not sure I follow @pngwn. We wouldn't display the raw progress bar that tqdm prints. We would extract the information and plug that into our existing status tracker. So the output would look pretty much the same. |
But even dumping the text isn't great either, what works in a CLI tool isn't a great experience for end users. And that means we need to match the |
@pngwn there's a TQDM Notebook class that afaik exposes some of the outputs for the programs to use, I don't really know how it works under the hood but could potentially be used for this: https://tqdm.github.io/docs/notebook/ Regarding the progress bar. I still see how it could be interesting for users to choose whether their output is in a progress bar or on the output field. I think there's room for both, but I agree this may make sense as a custom/user component. But just FYI if I had to choose between a custom progress bar or a native one on the output field for this particular demo I would choose a custom progress bar |
The big issue with a custom component ProgressBar is that we currently don't have a mechanism to pass anything but the output components the current progress of a request/ queue request. We'll need to build in more flexibility to be able to do that. |
To summarize:
Here's a possible implementation: import gradio as gr
import img_model
with gr.Blocks() as demo:
prompt = gr.Textbox(label="Enter text")
img = gr.Image()
def load_image(data):
total_steps = 50
for step in img_model.load():
# ...
yield gr.Status(step / total_steps, text="Loading model")
return img_model(data[prompt])
prompt.submit(load_image, {prompt}, img)
demo.queue().launch() which would look something like: For a tqdm-like wrapper, we could have: import gradio as gr
import img_model
with gr.Blocks() as demo:
prompt = gr.Textbox(label="Enter text")
img = gr.Image()
def load_image(data):
total_steps = 50
for _ in gr.Track(img_model.load()):
# ...
yield gr.Status(text="Loading model")
return img_model(data[prompt])
prompt.submit(load_image, {prompt}, img)
demo.queue().launch() where the |
For the tqdm integration, it would be better if users can somehow return or yield the tqdm object itself so that people don’t have to learn a new syntax. Users are already using tqdm in their code so it would be better if we integrated with tqdm instead of offering a replacement |
Yeah I thought about that but in the syntax for obj in tqdm(objects):
yield ... there isn't really access to the tqdm object within the loop, so not sure how to yield it |
Co-authored-by: Abubakar Abid <abubakar@huggingface.co>
Co-authored-by: Abubakar Abid <abubakar@huggingface.co>
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 |
1 similar comment
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 |
Co-authored-by: Abubakar Abid <abubakar@huggingface.co>
Co-authored-by: Abubakar Abid <abubakar@huggingface.co>
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 |
1 similar comment
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 |
Co-authored-by: Abubakar Abid <abubakar@huggingface.co>
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 |
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 |
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 |
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 |
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
Snippet for explicit status:
Closes: #340