Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
renzhc
diffusers_dcu
Commits
99f60821
Unverified
Commit
99f60821
authored
Oct 03, 2024
by
YiYi Xu
Committed by
GitHub
Oct 03, 2024
Browse files
[sd3] make sure height and size are divisible by `16` (#9573)
* check size * up
parent
7f323f0f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
6 deletions
+33
-6
src/diffusers/pipelines/controlnet_sd3/pipeline_stable_diffusion_3_controlnet_inpainting.py
..._sd3/pipeline_stable_diffusion_3_controlnet_inpainting.py
+11
-2
src/diffusers/pipelines/pag/pipeline_pag_sd_3.py
src/diffusers/pipelines/pag/pipeline_pag_sd_3.py
+11
-2
src/diffusers/pipelines/stable_diffusion_3/pipeline_stable_diffusion_3.py
...pelines/stable_diffusion_3/pipeline_stable_diffusion_3.py
+11
-2
No files found.
src/diffusers/pipelines/controlnet_sd3/pipeline_stable_diffusion_3_controlnet_inpainting.py
View file @
99f60821
...
@@ -251,6 +251,9 @@ class StableDiffusion3ControlNetInpaintingPipeline(DiffusionPipeline, SD3LoraLoa
...
@@ -251,6 +251,9 @@ class StableDiffusion3ControlNetInpaintingPipeline(DiffusionPipeline, SD3LoraLoa
if
hasattr
(
self
,
"transformer"
)
and
self
.
transformer
is
not
None
if
hasattr
(
self
,
"transformer"
)
and
self
.
transformer
is
not
None
else
128
else
128
)
)
self
.
patch_size
=
(
self
.
transformer
.
config
.
patch_size
if
hasattr
(
self
,
"transformer"
)
and
self
.
transformer
is
not
None
else
2
)
# Copied from diffusers.pipelines.stable_diffusion_3.pipeline_stable_diffusion_3.StableDiffusion3Pipeline._get_t5_prompt_embeds
# Copied from diffusers.pipelines.stable_diffusion_3.pipeline_stable_diffusion_3.StableDiffusion3Pipeline._get_t5_prompt_embeds
def
_get_t5_prompt_embeds
(
def
_get_t5_prompt_embeds
(
...
@@ -577,8 +580,14 @@ class StableDiffusion3ControlNetInpaintingPipeline(DiffusionPipeline, SD3LoraLoa
...
@@ -577,8 +580,14 @@ class StableDiffusion3ControlNetInpaintingPipeline(DiffusionPipeline, SD3LoraLoa
callback_on_step_end_tensor_inputs
=
None
,
callback_on_step_end_tensor_inputs
=
None
,
max_sequence_length
=
None
,
max_sequence_length
=
None
,
):
):
if
height
%
8
!=
0
or
width
%
8
!=
0
:
if
(
raise
ValueError
(
f
"`height` and `width` have to be divisible by 8 but are
{
height
}
and
{
width
}
."
)
height
%
(
self
.
vae_scale_factor
*
self
.
patch_size
)
!=
0
or
width
%
(
self
.
vae_scale_factor
*
self
.
patch_size
)
!=
0
):
raise
ValueError
(
f
"`height` and `width` have to be divisible by
{
self
.
vae_scale_factor
*
self
.
patch_size
}
but are
{
height
}
and
{
width
}
."
f
"You can use height
{
height
-
height
%
(
self
.
vae_scale_factor
*
self
.
patch_size
)
}
and width
{
width
-
width
%
(
self
.
vae_scale_factor
*
self
.
patch_size
)
}
."
)
if
callback_on_step_end_tensor_inputs
is
not
None
and
not
all
(
if
callback_on_step_end_tensor_inputs
is
not
None
and
not
all
(
k
in
self
.
_callback_tensor_inputs
for
k
in
callback_on_step_end_tensor_inputs
k
in
self
.
_callback_tensor_inputs
for
k
in
callback_on_step_end_tensor_inputs
...
...
src/diffusers/pipelines/pag/pipeline_pag_sd_3.py
View file @
99f60821
...
@@ -212,6 +212,9 @@ class StableDiffusion3PAGPipeline(DiffusionPipeline, SD3LoraLoaderMixin, FromSin
...
@@ -212,6 +212,9 @@ class StableDiffusion3PAGPipeline(DiffusionPipeline, SD3LoraLoaderMixin, FromSin
if
hasattr
(
self
,
"transformer"
)
and
self
.
transformer
is
not
None
if
hasattr
(
self
,
"transformer"
)
and
self
.
transformer
is
not
None
else
128
else
128
)
)
self
.
patch_size
=
(
self
.
transformer
.
config
.
patch_size
if
hasattr
(
self
,
"transformer"
)
and
self
.
transformer
is
not
None
else
2
)
self
.
set_pag_applied_layers
(
self
.
set_pag_applied_layers
(
pag_applied_layers
,
pag_attn_processors
=
(
PAGCFGJointAttnProcessor2_0
(),
PAGJointAttnProcessor2_0
())
pag_applied_layers
,
pag_attn_processors
=
(
PAGCFGJointAttnProcessor2_0
(),
PAGJointAttnProcessor2_0
())
...
@@ -542,8 +545,14 @@ class StableDiffusion3PAGPipeline(DiffusionPipeline, SD3LoraLoaderMixin, FromSin
...
@@ -542,8 +545,14 @@ class StableDiffusion3PAGPipeline(DiffusionPipeline, SD3LoraLoaderMixin, FromSin
callback_on_step_end_tensor_inputs
=
None
,
callback_on_step_end_tensor_inputs
=
None
,
max_sequence_length
=
None
,
max_sequence_length
=
None
,
):
):
if
height
%
8
!=
0
or
width
%
8
!=
0
:
if
(
raise
ValueError
(
f
"`height` and `width` have to be divisible by 8 but are
{
height
}
and
{
width
}
."
)
height
%
(
self
.
vae_scale_factor
*
self
.
patch_size
)
!=
0
or
width
%
(
self
.
vae_scale_factor
*
self
.
patch_size
)
!=
0
):
raise
ValueError
(
f
"`height` and `width` have to be divisible by
{
self
.
vae_scale_factor
*
self
.
patch_size
}
but are
{
height
}
and
{
width
}
."
f
"You can use height
{
height
-
height
%
(
self
.
vae_scale_factor
*
self
.
patch_size
)
}
and width
{
width
-
width
%
(
self
.
vae_scale_factor
*
self
.
patch_size
)
}
."
)
if
callback_on_step_end_tensor_inputs
is
not
None
and
not
all
(
if
callback_on_step_end_tensor_inputs
is
not
None
and
not
all
(
k
in
self
.
_callback_tensor_inputs
for
k
in
callback_on_step_end_tensor_inputs
k
in
self
.
_callback_tensor_inputs
for
k
in
callback_on_step_end_tensor_inputs
...
...
src/diffusers/pipelines/stable_diffusion_3/pipeline_stable_diffusion_3.py
View file @
99f60821
...
@@ -203,6 +203,9 @@ class StableDiffusion3Pipeline(DiffusionPipeline, SD3LoraLoaderMixin, FromSingle
...
@@ -203,6 +203,9 @@ class StableDiffusion3Pipeline(DiffusionPipeline, SD3LoraLoaderMixin, FromSingle
if
hasattr
(
self
,
"transformer"
)
and
self
.
transformer
is
not
None
if
hasattr
(
self
,
"transformer"
)
and
self
.
transformer
is
not
None
else
128
else
128
)
)
self
.
patch_size
=
(
self
.
transformer
.
config
.
patch_size
if
hasattr
(
self
,
"transformer"
)
and
self
.
transformer
is
not
None
else
2
)
def
_get_t5_prompt_embeds
(
def
_get_t5_prompt_embeds
(
self
,
self
,
...
@@ -525,8 +528,14 @@ class StableDiffusion3Pipeline(DiffusionPipeline, SD3LoraLoaderMixin, FromSingle
...
@@ -525,8 +528,14 @@ class StableDiffusion3Pipeline(DiffusionPipeline, SD3LoraLoaderMixin, FromSingle
callback_on_step_end_tensor_inputs
=
None
,
callback_on_step_end_tensor_inputs
=
None
,
max_sequence_length
=
None
,
max_sequence_length
=
None
,
):
):
if
height
%
8
!=
0
or
width
%
8
!=
0
:
if
(
raise
ValueError
(
f
"`height` and `width` have to be divisible by 8 but are
{
height
}
and
{
width
}
."
)
height
%
(
self
.
vae_scale_factor
*
self
.
patch_size
)
!=
0
or
width
%
(
self
.
vae_scale_factor
*
self
.
patch_size
)
!=
0
):
raise
ValueError
(
f
"`height` and `width` have to be divisible by
{
self
.
vae_scale_factor
*
self
.
patch_size
}
but are
{
height
}
and
{
width
}
."
f
"You can use height
{
height
-
height
%
(
self
.
vae_scale_factor
*
self
.
patch_size
)
}
and width
{
width
-
width
%
(
self
.
vae_scale_factor
*
self
.
patch_size
)
}
."
)
if
callback_on_step_end_tensor_inputs
is
not
None
and
not
all
(
if
callback_on_step_end_tensor_inputs
is
not
None
and
not
all
(
k
in
self
.
_callback_tensor_inputs
for
k
in
callback_on_step_end_tensor_inputs
k
in
self
.
_callback_tensor_inputs
for
k
in
callback_on_step_end_tensor_inputs
...
...
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