diffusers
diffusers copied to clipboard
Add options to disable/hide progress bar
Is your feature request related to a problem? Please describe.
This is a minor thing, but I find the progress bar annoying when I run inference with pipeline successively.
See this screenshot for example.
In this case, I generated 10 images using DDIMPipeline and used tqdm myself, but the progress bars coming from __call__ of the pipeline are stacking up and annoying.
Describe the solution you'd like
It would be nice if disable and leave options of tqdm were available with pipelines. Keyword arguments (say, disable_tqdm and leave_tqdm?) could be added to __call__ methods and passed to tqdm. These are the relevant lines in case of DDPMPipeline:
https://github.com/huggingface/diffusers/blob/92b6dbba1a25ed27b0bae38b089715132c7e6bcc/src/diffusers/pipelines/ddpm/pipeline_ddpm.py#L31
https://github.com/huggingface/diffusers/blob/92b6dbba1a25ed27b0bae38b089715132c7e6bcc/src/diffusers/pipelines/ddpm/pipeline_ddpm.py#L47
I found something that might be relevant in the logging module, but it's not used in the pipeline modules. Maybe this can be used.
Thank you for opening the issue. I think it makes sense, the progress bars can be annoying when doing multiple generations. Think we can allow disabling progress bars. cc @anton-l @patrickvonplaten
Yes agree! I'd be in favor of adding a function for this I think (dis/enable_progress_bar(...))
@hysts would you like to try to make a PR for it? Think we could just just change:
for t in tqdm(self.scheduler.timesteps):
with:
for t in self.progress_bar(self.scheduler.timesteps):
and then have a function in general Pipelines that does:
def progress_bar(self, iterable):
if self._is_progress_bar_enabled:
return tqdm(iterable)
else:
return iterable
And then we just need a enable and disable function :-)
Also cc @pcuenca @ydshieh in case you would be interested in taking a look here :-)
I can take this as an exercise for using tqdm, unless @hysts would like to make a PR.
Sure. I'll look into it and make a PR.
Let's also make sure that we can handle additional arguments to tqdm (like total=) with **kwargs like so:
def progress_bar(self, iterable, **kwargs):
if self._is_progress_bar_enabled:
return tqdm(iterable, **kwargs)
else:
return iterable
for i, t in tqdm(enumerate(self.scheduler.timesteps), total=self.scheduler.num_inference_steps):