Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
OpenDAS
diffusers
Commits
bdd16116
Unverified
Commit
bdd16116
authored
Oct 02, 2023
by
Patrick von Platen
Committed by
GitHub
Oct 02, 2023
Browse files
[Schedulers] Fix callback steps (#5261)
* fix all * make fix copies * make fix copies
parent
c8b0f0eb
Changes
87
Show whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
40 additions
and
20 deletions
+40
-20
examples/community/stable_diffusion_repaint.py
examples/community/stable_diffusion_repaint.py
+2
-1
examples/community/stable_diffusion_xl_reference.py
examples/community/stable_diffusion_xl_reference.py
+2
-1
examples/community/wildcard_stable_diffusion.py
examples/community/wildcard_stable_diffusion.py
+2
-1
examples/research_projects/rdm/pipeline_rdm.py
examples/research_projects/rdm/pipeline_rdm.py
+2
-1
src/diffusers/pipelines/alt_diffusion/pipeline_alt_diffusion.py
...ffusers/pipelines/alt_diffusion/pipeline_alt_diffusion.py
+2
-1
src/diffusers/pipelines/alt_diffusion/pipeline_alt_diffusion_img2img.py
...pipelines/alt_diffusion/pipeline_alt_diffusion_img2img.py
+2
-1
src/diffusers/pipelines/audioldm/pipeline_audioldm.py
src/diffusers/pipelines/audioldm/pipeline_audioldm.py
+2
-1
src/diffusers/pipelines/audioldm2/pipeline_audioldm2.py
src/diffusers/pipelines/audioldm2/pipeline_audioldm2.py
+2
-1
src/diffusers/pipelines/controlnet/pipeline_controlnet.py
src/diffusers/pipelines/controlnet/pipeline_controlnet.py
+2
-1
src/diffusers/pipelines/controlnet/pipeline_controlnet_img2img.py
...users/pipelines/controlnet/pipeline_controlnet_img2img.py
+2
-1
src/diffusers/pipelines/controlnet/pipeline_controlnet_inpaint.py
...users/pipelines/controlnet/pipeline_controlnet_inpaint.py
+2
-1
src/diffusers/pipelines/controlnet/pipeline_controlnet_inpaint_sd_xl.py
...pipelines/controlnet/pipeline_controlnet_inpaint_sd_xl.py
+2
-1
src/diffusers/pipelines/controlnet/pipeline_controlnet_sd_xl.py
...ffusers/pipelines/controlnet/pipeline_controlnet_sd_xl.py
+2
-1
src/diffusers/pipelines/controlnet/pipeline_controlnet_sd_xl_img2img.py
...pipelines/controlnet/pipeline_controlnet_sd_xl_img2img.py
+2
-1
src/diffusers/pipelines/kandinsky/pipeline_kandinsky.py
src/diffusers/pipelines/kandinsky/pipeline_kandinsky.py
+2
-1
src/diffusers/pipelines/kandinsky/pipeline_kandinsky_img2img.py
...ffusers/pipelines/kandinsky/pipeline_kandinsky_img2img.py
+2
-1
src/diffusers/pipelines/kandinsky/pipeline_kandinsky_inpaint.py
...ffusers/pipelines/kandinsky/pipeline_kandinsky_inpaint.py
+2
-1
src/diffusers/pipelines/kandinsky2_2/pipeline_kandinsky2_2.py
...diffusers/pipelines/kandinsky2_2/pipeline_kandinsky2_2.py
+2
-1
src/diffusers/pipelines/kandinsky2_2/pipeline_kandinsky2_2_controlnet.py
...ipelines/kandinsky2_2/pipeline_kandinsky2_2_controlnet.py
+2
-1
src/diffusers/pipelines/kandinsky2_2/pipeline_kandinsky2_2_controlnet_img2img.py
.../kandinsky2_2/pipeline_kandinsky2_2_controlnet_img2img.py
+2
-1
No files found.
examples/community/stable_diffusion_repaint.py
View file @
bdd16116
...
...
@@ -932,7 +932,8 @@ class StableDiffusionRepaintPipeline(DiffusionPipeline, TextualInversionLoaderMi
# 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
...
...
examples/community/stable_diffusion_xl_reference.py
View file @
bdd16116
...
...
@@ -771,7 +771,8 @@ class StableDiffusionXLReferencePipeline(StableDiffusionXLPipeline):
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
...
...
examples/community/wildcard_stable_diffusion.py
View file @
bdd16116
...
...
@@ -389,7 +389,8 @@ class WildcardStableDiffusionPipeline(DiffusionPipeline):
# 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
...
...
examples/research_projects/rdm/pipeline_rdm.py
View file @
bdd16116
...
...
@@ -432,7 +432,8 @@ class RDMPipeline(DiffusionPipeline):
# 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
:
...
...
src/diffusers/pipelines/alt_diffusion/pipeline_alt_diffusion.py
View file @
bdd16116
...
...
@@ -736,7 +736,8 @@ class AltDiffusionPipeline(DiffusionPipeline, TextualInversionLoaderMixin, LoraL
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
]
...
...
src/diffusers/pipelines/alt_diffusion/pipeline_alt_diffusion_img2img.py
View file @
bdd16116
...
...
@@ -765,7 +765,8 @@ class AltDiffusionImg2ImgPipeline(
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
]
...
...
src/diffusers/pipelines/audioldm/pipeline_audioldm.py
View file @
bdd16116
...
...
@@ -542,7 +542,8 @@ class AudioLDMPipeline(DiffusionPipeline):
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
)
...
...
src/diffusers/pipelines/audioldm2/pipeline_audioldm2.py
View file @
bdd16116
...
...
@@ -945,7 +945,8 @@ class AudioLDM2Pipeline(DiffusionPipeline):
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
()
...
...
src/diffusers/pipelines/controlnet/pipeline_controlnet.py
View file @
bdd16116
...
...
@@ -1005,7 +1005,8 @@ class StableDiffusionControlNetPipeline(
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
...
...
src/diffusers/pipelines/controlnet/pipeline_controlnet_img2img.py
View file @
bdd16116
...
...
@@ -1087,7 +1087,8 @@ class StableDiffusionControlNetImg2ImgPipeline(
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
...
...
src/diffusers/pipelines/controlnet/pipeline_controlnet_inpaint.py
View file @
bdd16116
...
...
@@ -1351,7 +1351,8 @@ class StableDiffusionControlNetInpaintPipeline(
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
...
...
src/diffusers/pipelines/controlnet/pipeline_controlnet_inpaint_sd_xl.py
View file @
bdd16116
...
...
@@ -1507,7 +1507,8 @@ class StableDiffusionXLControlNetInpaintPipeline(
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
:
...
...
src/diffusers/pipelines/controlnet/pipeline_controlnet_sd_xl.py
View file @
bdd16116
...
...
@@ -1158,7 +1158,8 @@ class StableDiffusionXLControlNetPipeline(
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
:
...
...
src/diffusers/pipelines/controlnet/pipeline_controlnet_sd_xl_img2img.py
View file @
bdd16116
...
...
@@ -1344,7 +1344,8 @@ class StableDiffusionXLControlNetImg2ImgPipeline(
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
...
...
src/diffusers/pipelines/kandinsky/pipeline_kandinsky.py
View file @
bdd16116
...
...
@@ -382,7 +382,8 @@ class KandinskyPipeline(DiffusionPipeline):
).
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"
]
...
...
src/diffusers/pipelines/kandinsky/pipeline_kandinsky_img2img.py
View file @
bdd16116
...
...
@@ -475,7 +475,8 @@ class KandinskyImg2ImgPipeline(DiffusionPipeline):
).
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"
]
...
...
src/diffusers/pipelines/kandinsky/pipeline_kandinsky_inpaint.py
View file @
bdd16116
...
...
@@ -610,7 +610,8 @@ class KandinskyInpaintPipeline(DiffusionPipeline):
).
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"
]
...
...
src/diffusers/pipelines/kandinsky2_2/pipeline_kandinsky2_2.py
View file @
bdd16116
...
...
@@ -244,7 +244,8 @@ class KandinskyV22Pipeline(DiffusionPipeline):
)[
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"
]
...
...
src/diffusers/pipelines/kandinsky2_2/pipeline_kandinsky2_2_controlnet.py
View file @
bdd16116
...
...
@@ -295,7 +295,8 @@ class KandinskyV22ControlnetPipeline(DiffusionPipeline):
)[
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"
]
...
...
src/diffusers/pipelines/kandinsky2_2/pipeline_kandinsky2_2_controlnet_img2img.py
View file @
bdd16116
...
...
@@ -355,7 +355,8 @@ class KandinskyV22ControlnetImg2ImgPipeline(DiffusionPipeline):
)[
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"
]
...
...
Prev
1
2
3
4
5
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment