Update pipeline (#50)

This commit is contained in:
Bubbliiiing
2024-07-12 17:47:47 +08:00
committed by GitHub
parent 3cc15c456a
commit fbbfc818ea
2 changed files with 14 additions and 0 deletions
@@ -633,6 +633,7 @@ class EasyAnimatePipeline(DiffusionPipeline):
callback_steps: int = 1,
clean_caption: bool = True,
max_sequence_length: int = 120,
comfyui_progressbar: bool = False,
**kwargs,
) -> Union[EasyAnimatePipelineOutput, Tuple]:
"""
@@ -783,6 +784,9 @@ class EasyAnimatePipeline(DiffusionPipeline):
# 7. Denoising loop
num_warmup_steps = max(len(timesteps) - num_inference_steps * self.scheduler.order, 0)
if comfyui_progressbar:
from comfy.utils import ProgressBar
pbar = ProgressBar(num_inference_steps)
with self.progress_bar(total=num_inference_steps) as progress_bar:
for i, t in enumerate(timesteps):
latent_model_input = torch.cat([latents] * 2) if do_classifier_free_guidance else latents
@@ -834,6 +838,9 @@ class EasyAnimatePipeline(DiffusionPipeline):
step_idx = i // getattr(self.scheduler, "order", 1)
callback(step_idx, t, latents)
if comfyui_progressbar:
pbar.update(1)
# Post-processing
video = self.decode_latents(latents)
@@ -779,6 +779,8 @@ class EasyAnimateInpaintPipeline(DiffusionPipeline):
max_sequence_length: int = 120,
clip_image: Image = None,
clip_apply_ratio: float = 0.50,
comfyui_progressbar: bool = False,
**kwargs,
) -> Union[EasyAnimatePipelineOutput, Tuple]:
"""
Function invoked when calling the pipeline for generation.
@@ -1061,6 +1063,9 @@ class EasyAnimateInpaintPipeline(DiffusionPipeline):
# 10. Denoising loop
num_warmup_steps = len(timesteps) - num_inference_steps * self.scheduler.order
self._num_timesteps = len(timesteps)
if comfyui_progressbar:
from comfy.utils import ProgressBar
pbar = ProgressBar(num_inference_steps)
with self.progress_bar(total=num_inference_steps) as progress_bar:
for i, t in enumerate(timesteps):
latent_model_input = torch.cat([latents] * 2) if do_classifier_free_guidance else latents
@@ -1130,6 +1135,8 @@ class EasyAnimateInpaintPipeline(DiffusionPipeline):
step_idx = i // getattr(self.scheduler, "order", 1)
callback(step_idx, t, latents)
if comfyui_progressbar:
pbar.update(1)
gc.collect()
torch.cuda.empty_cache()
torch.cuda.ipc_collect()