Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion examples/community/composable_stable_diffusion.py
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,8 @@ def __call__(
if i == len(timesteps) - 1 or ((i + 1) > num_warmup_steps and (i + 1) % self.scheduler.order == 0):
progress_bar.update()
if callback is not None and i % callback_steps == 0:
callback(i, t, latents)
step_idx = i // getattr(self.scheduler, "order", 1)
callback(step_idx, t, latents)

# 8. Post-processing
image = self.decode_latents(latents)
Expand Down
3 changes: 2 additions & 1 deletion examples/community/img2img_inpainting.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,8 @@ def __call__(

# call the callback, if provided
if callback is not None and i % callback_steps == 0:
callback(i, t, latents)
step_idx = i // getattr(self.scheduler, "order", 1)
callback(step_idx, t, latents)

latents = 1 / 0.18215 * latents
image = self.vae.decode(latents).sample
Expand Down
3 changes: 2 additions & 1 deletion examples/community/interpolate_stable_diffusion.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,8 @@ def __call__(

# call the callback, if provided
if callback is not None and i % callback_steps == 0:
callback(i, t, latents)
step_idx = i // getattr(self.scheduler, "order", 1)
callback(step_idx, t, latents)

latents = 1 / 0.18215 * latents
image = self.vae.decode(latents).sample
Expand Down
3 changes: 2 additions & 1 deletion examples/community/lpw_stable_diffusion.py
Original file line number Diff line number Diff line change
Expand Up @@ -1088,7 +1088,8 @@ def __call__(
progress_bar.update()
if i % callback_steps == 0:
if callback is not None:
callback(i, t, latents)
step_idx = i // getattr(self.scheduler, "order", 1)
callback(step_idx, t, latents)
if is_cancelled_callback is not None and is_cancelled_callback():
return None

Expand Down
3 changes: 2 additions & 1 deletion examples/community/lpw_stable_diffusion_onnx.py
Original file line number Diff line number Diff line change
Expand Up @@ -846,7 +846,8 @@ def __call__(
# call the callback, if provided
if i % callback_steps == 0:
if callback is not None:
callback(i, t, latents)
step_idx = i // getattr(self.scheduler, "order", 1)
callback(step_idx, t, latents)
if is_cancelled_callback is not None and is_cancelled_callback():
return None

Expand Down
3 changes: 2 additions & 1 deletion examples/community/lpw_stable_diffusion_xl.py
Original file line number Diff line number Diff line change
Expand Up @@ -1182,7 +1182,8 @@ def __call__(
if i == len(timesteps) - 1 or ((i + 1) > num_warmup_steps and (i + 1) % self.scheduler.order == 0):
progress_bar.update()
if callback is not None and i % callback_steps == 0:
callback(i, t, latents)
step_idx = i // getattr(self.scheduler, "order", 1)
callback(step_idx, t, latents)

if not output_type == "latent":
# make sure the VAE is in float32 mode, as it overflows in float16
Expand Down
3 changes: 2 additions & 1 deletion examples/community/masked_stable_diffusion_img2img.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,8 @@ def __call__(
if i == len(timesteps) - 1 or ((i + 1) > num_warmup_steps and (i + 1) % self.scheduler.order == 0):
progress_bar.update()
if callback is not None and i % callback_steps == 0:
callback(i, t, latents)
step_idx = i // getattr(self.scheduler, "order", 1)
callback(step_idx, t, latents)

if not output_type == "latent":
scaled = latents / self.vae.config.scaling_factor
Expand Down
3 changes: 2 additions & 1 deletion examples/community/multilingual_stable_diffusion.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,8 @@ def __call__(

# call the callback, if provided
if callback is not None and i % callback_steps == 0:
callback(i, t, latents)
step_idx = i // getattr(self.scheduler, "order", 1)
callback(step_idx, t, latents)

latents = 1 / 0.18215 * latents
image = self.vae.decode(latents).sample
Expand Down
3 changes: 2 additions & 1 deletion examples/community/pipeline_prompt2prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,8 @@ def __call__(
if i == len(timesteps) - 1 or ((i + 1) > num_warmup_steps and (i + 1) % self.scheduler.order == 0):
progress_bar.update()
if callback is not None and i % callback_steps == 0:
callback(i, t, latents)
step_idx = i // getattr(self.scheduler, "order", 1)
callback(step_idx, t, latents)

# 8. Post-processing
if not output_type == "latent":
Expand Down
3 changes: 2 additions & 1 deletion examples/community/pipeline_zero1to3.py
Original file line number Diff line number Diff line change
Expand Up @@ -865,7 +865,8 @@ def __call__(
if i == len(timesteps) - 1 or ((i + 1) > num_warmup_steps and (i + 1) % self.scheduler.order == 0):
progress_bar.update()
if callback is not None and i % callback_steps == 0:
callback(i, t, latents)
step_idx = i // getattr(self.scheduler, "order", 1)
callback(step_idx, t, latents)

# 8. Post-processing
has_nsfw_concept = None
Expand Down
3 changes: 2 additions & 1 deletion examples/community/run_onnx_controlnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -815,7 +815,8 @@ def __call__(
if i == len(timesteps) - 1 or ((i + 1) > num_warmup_steps and (i + 1) % self.scheduler.order == 0):
progress_bar.update()
if callback is not None and i % callback_steps == 0:
callback(i, t, latents)
step_idx = i // getattr(self.scheduler, "order", 1)
callback(step_idx, t, latents)

if not output_type == "latent":
_latents = latents.cpu().detach().numpy() / 0.18215
Expand Down
3 changes: 2 additions & 1 deletion examples/community/run_tensorrt_controlnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -919,7 +919,8 @@ def __call__(
if i == len(timesteps) - 1 or ((i + 1) > num_warmup_steps and (i + 1) % self.scheduler.order == 0):
progress_bar.update()
if callback is not None and i % callback_steps == 0:
callback(i, t, latents)
step_idx = i // getattr(self.scheduler, "order", 1)
callback(step_idx, t, latents)

if not output_type == "latent":
_latents = latents.cpu().detach().numpy() / 0.18215
Expand Down
3 changes: 2 additions & 1 deletion examples/community/seed_resize_stable_diffusion.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,8 @@ def __call__(

# call the callback, if provided
if callback is not None and i % callback_steps == 0:
callback(i, t, latents)
step_idx = i // getattr(self.scheduler, "order", 1)
callback(step_idx, t, latents)

latents = 1 / 0.18215 * latents
image = self.vae.decode(latents).sample
Expand Down
3 changes: 2 additions & 1 deletion examples/community/speech_to_image_diffusion.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,8 @@ def __call__(

# call the callback, if provided
if callback is not None and i % callback_steps == 0:
callback(i, t, latents)
step_idx = i // getattr(self.scheduler, "order", 1)
callback(step_idx, t, latents)

latents = 1 / 0.18215 * latents
image = self.vae.decode(latents).sample
Expand Down
3 changes: 2 additions & 1 deletion examples/community/stable_diffusion_controlnet_img2img.py
Original file line number Diff line number Diff line change
Expand Up @@ -951,7 +951,8 @@ def __call__(
if i == len(timesteps) - 1 or ((i + 1) > num_warmup_steps and (i + 1) % self.scheduler.order == 0):
progress_bar.update()
if callback is not None and i % callback_steps == 0:
callback(i, t, latents)
step_idx = i // getattr(self.scheduler, "order", 1)
callback(step_idx, t, latents)

# If we do sequential model offloading, let's offload unet and controlnet
# manually for max memory savings
Expand Down
3 changes: 2 additions & 1 deletion examples/community/stable_diffusion_controlnet_inpaint.py
Original file line number Diff line number Diff line change
Expand Up @@ -1100,7 +1100,8 @@ def __call__(
if i == len(timesteps) - 1 or ((i + 1) > num_warmup_steps and (i + 1) % self.scheduler.order == 0):
progress_bar.update()
if callback is not None and i % callback_steps == 0:
callback(i, t, latents)
step_idx = i // getattr(self.scheduler, "order", 1)
callback(step_idx, t, latents)

# If we do sequential model offloading, let's offload unet and controlnet
# manually for max memory savings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1081,7 +1081,8 @@ def __call__(
if i == len(timesteps) - 1 or ((i + 1) > num_warmup_steps and (i + 1) % self.scheduler.order == 0):
progress_bar.update()
if callback is not None and i % callback_steps == 0:
callback(i, t, latents)
step_idx = i // getattr(self.scheduler, "order", 1)
callback(step_idx, t, latents)

# If we do sequential model offloading, let's offload unet and controlnet
# manually for max memory savings
Expand Down
3 changes: 2 additions & 1 deletion examples/community/stable_diffusion_controlnet_reference.py
Original file line number Diff line number Diff line change
Expand Up @@ -802,7 +802,8 @@ def hacked_UpBlock2D_forward(self, hidden_states, res_hidden_states_tuple, temb=
if i == len(timesteps) - 1 or ((i + 1) > num_warmup_steps and (i + 1) % self.scheduler.order == 0):
progress_bar.update()
if callback is not None and i % callback_steps == 0:
callback(i, t, latents)
step_idx = i // getattr(self.scheduler, "order", 1)
callback(step_idx, t, latents)

# If we do sequential model offloading, let's offload unet and controlnet
# manually for max memory savings
Expand Down
3 changes: 2 additions & 1 deletion examples/community/stable_diffusion_ipex.py
Original file line number Diff line number Diff line change
Expand Up @@ -817,7 +817,8 @@ def __call__(
if i == len(timesteps) - 1 or ((i + 1) > num_warmup_steps and (i + 1) % self.scheduler.order == 0):
progress_bar.update()
if callback is not None and i % callback_steps == 0:
callback(i, t, latents)
step_idx = i // getattr(self.scheduler, "order", 1)
callback(step_idx, t, latents)

if output_type == "latent":
image = latents
Expand Down
3 changes: 2 additions & 1 deletion examples/community/stable_diffusion_reference.py
Original file line number Diff line number Diff line change
Expand Up @@ -770,7 +770,8 @@ def hacked_UpBlock2D_forward(self, hidden_states, res_hidden_states_tuple, temb=
if i == len(timesteps) - 1 or ((i + 1) > num_warmup_steps and (i + 1) % self.scheduler.order == 0):
progress_bar.update()
if callback is not None and i % callback_steps == 0:
callback(i, t, latents)
step_idx = i // getattr(self.scheduler, "order", 1)
callback(step_idx, t, latents)

if not output_type == "latent":
image = self.vae.decode(latents / self.vae.config.scaling_factor, return_dict=False)[0]
Expand Down
3 changes: 2 additions & 1 deletion examples/community/stable_diffusion_repaint.py
Original file line number Diff line number Diff line change
Expand Up @@ -932,7 +932,8 @@ def __call__(
# call the callback, if provided
progress_bar.update()
if callback is not None and i % callback_steps == 0:
callback(i, t, latents)
step_idx = i // getattr(self.scheduler, "order", 1)
callback(step_idx, t, latents)

t_last = t

Expand Down
3 changes: 2 additions & 1 deletion examples/community/stable_diffusion_xl_reference.py
Original file line number Diff line number Diff line change
Expand Up @@ -771,7 +771,8 @@ def hacked_UpBlock2D_forward(self, hidden_states, res_hidden_states_tuple, temb=
if i == len(timesteps) - 1 or ((i + 1) > num_warmup_steps and (i + 1) % self.scheduler.order == 0):
progress_bar.update()
if callback is not None and i % callback_steps == 0:
callback(i, t, latents)
step_idx = i // getattr(self.scheduler, "order", 1)
callback(step_idx, t, latents)

if not output_type == "latent":
# make sure the VAE is in float32 mode, as it overflows in float16
Expand Down
3 changes: 2 additions & 1 deletion examples/community/wildcard_stable_diffusion.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,8 @@ def __call__(

# call the callback, if provided
if callback is not None and i % callback_steps == 0:
callback(i, t, latents)
step_idx = i // getattr(self.scheduler, "order", 1)
callback(step_idx, t, latents)

latents = 1 / 0.18215 * latents
image = self.vae.decode(latents).sample
Expand Down
3 changes: 2 additions & 1 deletion examples/research_projects/rdm/pipeline_rdm.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,8 @@ def __call__(

# call the callback, if provided
if callback is not None and i % callback_steps == 0:
callback(i, t, latents)
step_idx = i // getattr(self.scheduler, "order", 1)
callback(step_idx, t, latents)
if not output_type == "latent":
image = self.vae.decode(latents / self.vae.config.scaling_factor, return_dict=False)[0]
else:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,8 @@ def __call__(
if i == len(timesteps) - 1 or ((i + 1) > num_warmup_steps and (i + 1) % self.scheduler.order == 0):
progress_bar.update()
if callback is not None and i % callback_steps == 0:
callback(i, t, latents)
step_idx = i // getattr(self.scheduler, "order", 1)
callback(step_idx, t, latents)

if not output_type == "latent":
image = self.vae.decode(latents / self.vae.config.scaling_factor, return_dict=False)[0]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,8 @@ def __call__(
if i == len(timesteps) - 1 or ((i + 1) > num_warmup_steps and (i + 1) % self.scheduler.order == 0):
progress_bar.update()
if callback is not None and i % callback_steps == 0:
callback(i, t, latents)
step_idx = i // getattr(self.scheduler, "order", 1)
callback(step_idx, t, latents)

if not output_type == "latent":
image = self.vae.decode(latents / self.vae.config.scaling_factor, return_dict=False)[0]
Expand Down
3 changes: 2 additions & 1 deletion src/diffusers/pipelines/audioldm/pipeline_audioldm.py
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,8 @@ def __call__(
if i == len(timesteps) - 1 or ((i + 1) > num_warmup_steps and (i + 1) % self.scheduler.order == 0):
progress_bar.update()
if callback is not None and i % callback_steps == 0:
callback(i, t, latents)
step_idx = i // getattr(self.scheduler, "order", 1)
callback(step_idx, t, latents)

# 8. Post-processing
mel_spectrogram = self.decode_latents(latents)
Expand Down
3 changes: 2 additions & 1 deletion src/diffusers/pipelines/audioldm2/pipeline_audioldm2.py
Original file line number Diff line number Diff line change
Expand Up @@ -945,7 +945,8 @@ def __call__(
if i == len(timesteps) - 1 or ((i + 1) > num_warmup_steps and (i + 1) % self.scheduler.order == 0):
progress_bar.update()
if callback is not None and i % callback_steps == 0:
callback(i, t, latents)
step_idx = i // getattr(self.scheduler, "order", 1)
callback(step_idx, t, latents)

self.maybe_free_model_hooks()

Expand Down
3 changes: 2 additions & 1 deletion src/diffusers/pipelines/controlnet/pipeline_controlnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -1005,7 +1005,8 @@ def __call__(
if i == len(timesteps) - 1 or ((i + 1) > num_warmup_steps and (i + 1) % self.scheduler.order == 0):
progress_bar.update()
if callback is not None and i % callback_steps == 0:
callback(i, t, latents)
step_idx = i // getattr(self.scheduler, "order", 1)
callback(step_idx, t, latents)

# If we do sequential model offloading, let's offload unet and controlnet
# manually for max memory savings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1087,7 +1087,8 @@ def __call__(
if i == len(timesteps) - 1 or ((i + 1) > num_warmup_steps and (i + 1) % self.scheduler.order == 0):
progress_bar.update()
if callback is not None and i % callback_steps == 0:
callback(i, t, latents)
step_idx = i // getattr(self.scheduler, "order", 1)
callback(step_idx, t, latents)

# If we do sequential model offloading, let's offload unet and controlnet
# manually for max memory savings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1351,7 +1351,8 @@ def __call__(
if i == len(timesteps) - 1 or ((i + 1) > num_warmup_steps and (i + 1) % self.scheduler.order == 0):
progress_bar.update()
if callback is not None and i % callback_steps == 0:
callback(i, t, latents)
step_idx = i // getattr(self.scheduler, "order", 1)
callback(step_idx, t, latents)

# If we do sequential model offloading, let's offload unet and controlnet
# manually for max memory savings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1507,7 +1507,8 @@ def denoising_value_valid(dnv):
if i == len(timesteps) - 1 or ((i + 1) > num_warmup_steps and (i + 1) % self.scheduler.order == 0):
progress_bar.update()
if callback is not None and i % callback_steps == 0:
callback(i, t, latents)
step_idx = i // getattr(self.scheduler, "order", 1)
callback(step_idx, t, latents)

# make sure the VAE is in float32 mode, as it overflows in float16
if self.vae.dtype == torch.float16 and self.vae.config.force_upcast:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1158,7 +1158,8 @@ def __call__(
if i == len(timesteps) - 1 or ((i + 1) > num_warmup_steps and (i + 1) % self.scheduler.order == 0):
progress_bar.update()
if callback is not None and i % callback_steps == 0:
callback(i, t, latents)
step_idx = i // getattr(self.scheduler, "order", 1)
callback(step_idx, t, latents)

# manually for max memory savings
if self.vae.dtype == torch.float16 and self.vae.config.force_upcast:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1344,7 +1344,8 @@ def __call__(
if i == len(timesteps) - 1 or ((i + 1) > num_warmup_steps and (i + 1) % self.scheduler.order == 0):
progress_bar.update()
if callback is not None and i % callback_steps == 0:
callback(i, t, latents)
step_idx = i // getattr(self.scheduler, "order", 1)
callback(step_idx, t, latents)

# If we do sequential model offloading, let's offload unet and controlnet
# manually for max memory savings
Expand Down
3 changes: 2 additions & 1 deletion src/diffusers/pipelines/kandinsky/pipeline_kandinsky.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,8 @@ def __call__(
).prev_sample

if callback is not None and i % callback_steps == 0:
callback(i, t, latents)
step_idx = i // getattr(self.scheduler, "order", 1)
callback(step_idx, t, latents)

# post-processing
image = self.movq.decode(latents, force_not_quantize=True)["sample"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,8 @@ def __call__(
).prev_sample

if callback is not None and i % callback_steps == 0:
callback(i, t, latents)
step_idx = i // getattr(self.scheduler, "order", 1)
callback(step_idx, t, latents)

# 7. post-processing
image = self.movq.decode(latents, force_not_quantize=True)["sample"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,8 @@ def __call__(
).prev_sample

if callback is not None and i % callback_steps == 0:
callback(i, t, latents)
step_idx = i // getattr(self.scheduler, "order", 1)
callback(step_idx, t, latents)

# post-processing
image = self.movq.decode(latents, force_not_quantize=True)["sample"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,8 @@ def __call__(
)[0]

if callback is not None and i % callback_steps == 0:
callback(i, t, latents)
step_idx = i // getattr(self.scheduler, "order", 1)
callback(step_idx, t, latents)
# post-processing
image = self.movq.decode(latents, force_not_quantize=True)["sample"]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,8 @@ def __call__(
)[0]

if callback is not None and i % callback_steps == 0:
callback(i, t, latents)
step_idx = i // getattr(self.scheduler, "order", 1)
callback(step_idx, t, latents)
# post-processing
image = self.movq.decode(latents, force_not_quantize=True)["sample"]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,8 @@ def __call__(
)[0]

if callback is not None and i % callback_steps == 0:
callback(i, t, latents)
step_idx = i // getattr(self.scheduler, "order", 1)
callback(step_idx, t, latents)

# post-processing
image = self.movq.decode(latents, force_not_quantize=True)["sample"]
Expand Down
Loading