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
edc154da
Unverified
Commit
edc154da
authored
Apr 09, 2025
by
Dhruv Nair
Committed by
GitHub
Apr 09, 2025
Browse files
Update Ruff to latest Version (#10919)
* update * update * update * update
parent
552cd320
Changes
200
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
46 additions
and
46 deletions
+46
-46
examples/advanced_diffusion_training/train_dreambooth_lora_flux_advanced.py
...diffusion_training/train_dreambooth_lora_flux_advanced.py
+4
-4
examples/advanced_diffusion_training/train_dreambooth_lora_sd15_advanced.py
...diffusion_training/train_dreambooth_lora_sd15_advanced.py
+9
-8
examples/advanced_diffusion_training/train_dreambooth_lora_sdxl_advanced.py
...diffusion_training/train_dreambooth_lora_sdxl_advanced.py
+7
-7
examples/amused/train_amused.py
examples/amused/train_amused.py
+1
-1
examples/cogvideo/train_cogvideox_image_to_video_lora.py
examples/cogvideo/train_cogvideox_image_to_video_lora.py
+1
-1
examples/cogvideo/train_cogvideox_lora.py
examples/cogvideo/train_cogvideox_lora.py
+1
-1
examples/community/adaptive_mask_inpainting.py
examples/community/adaptive_mask_inpainting.py
+1
-1
examples/community/hd_painter.py
examples/community/hd_painter.py
+1
-1
examples/community/img2img_inpainting.py
examples/community/img2img_inpainting.py
+1
-1
examples/community/llm_grounded_diffusion.py
examples/community/llm_grounded_diffusion.py
+2
-2
examples/community/mod_controlnet_tile_sr_sdxl.py
examples/community/mod_controlnet_tile_sr_sdxl.py
+1
-1
examples/community/pipeline_flux_differential_img2img.py
examples/community/pipeline_flux_differential_img2img.py
+2
-2
examples/community/pipeline_prompt2prompt.py
examples/community/pipeline_prompt2prompt.py
+6
-6
examples/community/pipeline_sdxl_style_aligned.py
examples/community/pipeline_sdxl_style_aligned.py
+1
-1
examples/community/pipeline_stable_diffusion_upscale_ldm3d.py
...ples/community/pipeline_stable_diffusion_upscale_ldm3d.py
+1
-1
examples/community/pipeline_stable_diffusion_xl_attentive_eraser.py
...ommunity/pipeline_stable_diffusion_xl_attentive_eraser.py
+3
-3
examples/community/pipeline_stable_diffusion_xl_controlnet_adapter_inpaint.py
...ipeline_stable_diffusion_xl_controlnet_adapter_inpaint.py
+1
-1
examples/community/scheduling_ufogen.py
examples/community/scheduling_ufogen.py
+1
-2
examples/consistency_distillation/train_lcm_distill_lora_sd_wds.py
...consistency_distillation/train_lcm_distill_lora_sd_wds.py
+1
-1
examples/consistency_distillation/train_lcm_distill_lora_sdxl.py
...s/consistency_distillation/train_lcm_distill_lora_sdxl.py
+1
-1
No files found.
examples/advanced_diffusion_training/train_dreambooth_lora_flux_advanced.py
View file @
edc154da
...
@@ -839,9 +839,9 @@ class TokenEmbeddingsHandler:
...
@@ -839,9 +839,9 @@ class TokenEmbeddingsHandler:
idx
=
0
idx
=
0
for
tokenizer
,
text_encoder
in
zip
(
self
.
tokenizers
,
self
.
text_encoders
):
for
tokenizer
,
text_encoder
in
zip
(
self
.
tokenizers
,
self
.
text_encoders
):
assert
isinstance
(
inserting_toks
,
list
),
"inserting_toks should be a list of strings."
assert
isinstance
(
inserting_toks
,
list
),
"inserting_toks should be a list of strings."
assert
all
(
assert
all
(
isinstance
(
tok
,
str
)
for
tok
in
inserting_toks
),
(
isinstance
(
tok
,
str
)
for
tok
in
inserting_toks
"All elements in inserting_toks should be strings."
)
,
"All elements in inserting_toks should be strings."
)
self
.
inserting_toks
=
inserting_toks
self
.
inserting_toks
=
inserting_toks
special_tokens_dict
=
{
"additional_special_tokens"
:
self
.
inserting_toks
}
special_tokens_dict
=
{
"additional_special_tokens"
:
self
.
inserting_toks
}
...
@@ -1605,7 +1605,7 @@ def main(args):
...
@@ -1605,7 +1605,7 @@ def main(args):
lora_state_dict
=
FluxPipeline
.
lora_state_dict
(
input_dir
)
lora_state_dict
=
FluxPipeline
.
lora_state_dict
(
input_dir
)
transformer_state_dict
=
{
transformer_state_dict
=
{
f
'
{
k
.
replace
(
"
transformer.
"
,
""
)
}
'
:
v
for
k
,
v
in
lora_state_dict
.
items
()
if
k
.
startswith
(
"transformer."
)
f
"
{
k
.
replace
(
'
transformer.
'
,
''
)
}
"
:
v
for
k
,
v
in
lora_state_dict
.
items
()
if
k
.
startswith
(
"transformer."
)
}
}
transformer_state_dict
=
convert_unet_state_dict_to_peft
(
transformer_state_dict
)
transformer_state_dict
=
convert_unet_state_dict_to_peft
(
transformer_state_dict
)
incompatible_keys
=
set_peft_model_state_dict
(
transformer_
,
transformer_state_dict
,
adapter_name
=
"default"
)
incompatible_keys
=
set_peft_model_state_dict
(
transformer_
,
transformer_state_dict
,
adapter_name
=
"default"
)
...
...
examples/advanced_diffusion_training/train_dreambooth_lora_sd15_advanced.py
View file @
edc154da
...
@@ -200,7 +200,8 @@ Special VAE used for training: {vae_path}.
...
@@ -200,7 +200,8 @@ Special VAE used for training: {vae_path}.
"diffusers"
,
"diffusers"
,
"diffusers-training"
,
"diffusers-training"
,
lora
,
lora
,
"template:sd-lora"
"stable-diffusion"
,
"template:sd-lora"
,
"stable-diffusion"
,
"stable-diffusion-diffusers"
,
"stable-diffusion-diffusers"
,
]
]
model_card
=
populate_model_card
(
model_card
,
tags
=
tags
)
model_card
=
populate_model_card
(
model_card
,
tags
=
tags
)
...
@@ -724,9 +725,9 @@ class TokenEmbeddingsHandler:
...
@@ -724,9 +725,9 @@ class TokenEmbeddingsHandler:
idx
=
0
idx
=
0
for
tokenizer
,
text_encoder
in
zip
(
self
.
tokenizers
,
self
.
text_encoders
):
for
tokenizer
,
text_encoder
in
zip
(
self
.
tokenizers
,
self
.
text_encoders
):
assert
isinstance
(
inserting_toks
,
list
),
"inserting_toks should be a list of strings."
assert
isinstance
(
inserting_toks
,
list
),
"inserting_toks should be a list of strings."
assert
all
(
assert
all
(
isinstance
(
tok
,
str
)
for
tok
in
inserting_toks
),
(
isinstance
(
tok
,
str
)
for
tok
in
inserting_toks
"All elements in inserting_toks should be strings."
)
,
"All elements in inserting_toks should be strings."
)
self
.
inserting_toks
=
inserting_toks
self
.
inserting_toks
=
inserting_toks
special_tokens_dict
=
{
"additional_special_tokens"
:
self
.
inserting_toks
}
special_tokens_dict
=
{
"additional_special_tokens"
:
self
.
inserting_toks
}
...
@@ -746,9 +747,9 @@ class TokenEmbeddingsHandler:
...
@@ -746,9 +747,9 @@ class TokenEmbeddingsHandler:
.
to
(
dtype
=
self
.
dtype
)
.
to
(
dtype
=
self
.
dtype
)
*
std_token_embedding
*
std_token_embedding
)
)
self
.
embeddings_settings
[
self
.
embeddings_settings
[
f
"original_embeddings_
{
idx
}
"
]
=
(
f
"original_embeddings_
{
idx
}
"
text_encoder
.
text_model
.
embeddings
.
token_embedding
.
weight
.
data
.
clone
()
]
=
text_encoder
.
text_model
.
embeddings
.
token_embedding
.
weight
.
data
.
clone
(
)
)
self
.
embeddings_settings
[
f
"std_token_embedding_
{
idx
}
"
]
=
std_token_embedding
self
.
embeddings_settings
[
f
"std_token_embedding_
{
idx
}
"
]
=
std_token_embedding
inu
=
torch
.
ones
((
len
(
tokenizer
),),
dtype
=
torch
.
bool
)
inu
=
torch
.
ones
((
len
(
tokenizer
),),
dtype
=
torch
.
bool
)
...
@@ -1322,7 +1323,7 @@ def main(args):
...
@@ -1322,7 +1323,7 @@ def main(args):
lora_state_dict
,
network_alphas
=
StableDiffusionPipeline
.
lora_state_dict
(
input_dir
)
lora_state_dict
,
network_alphas
=
StableDiffusionPipeline
.
lora_state_dict
(
input_dir
)
unet_state_dict
=
{
f
'
{
k
.
replace
(
"
unet.
"
,
""
)
}
'
:
v
for
k
,
v
in
lora_state_dict
.
items
()
if
k
.
startswith
(
"unet."
)}
unet_state_dict
=
{
f
"
{
k
.
replace
(
'
unet.
'
,
''
)
}
"
:
v
for
k
,
v
in
lora_state_dict
.
items
()
if
k
.
startswith
(
"unet."
)}
unet_state_dict
=
convert_unet_state_dict_to_peft
(
unet_state_dict
)
unet_state_dict
=
convert_unet_state_dict_to_peft
(
unet_state_dict
)
incompatible_keys
=
set_peft_model_state_dict
(
unet_
,
unet_state_dict
,
adapter_name
=
"default"
)
incompatible_keys
=
set_peft_model_state_dict
(
unet_
,
unet_state_dict
,
adapter_name
=
"default"
)
if
incompatible_keys
is
not
None
:
if
incompatible_keys
is
not
None
:
...
...
examples/advanced_diffusion_training/train_dreambooth_lora_sdxl_advanced.py
View file @
edc154da
...
@@ -890,9 +890,9 @@ class TokenEmbeddingsHandler:
...
@@ -890,9 +890,9 @@ class TokenEmbeddingsHandler:
idx
=
0
idx
=
0
for
tokenizer
,
text_encoder
in
zip
(
self
.
tokenizers
,
self
.
text_encoders
):
for
tokenizer
,
text_encoder
in
zip
(
self
.
tokenizers
,
self
.
text_encoders
):
assert
isinstance
(
inserting_toks
,
list
),
"inserting_toks should be a list of strings."
assert
isinstance
(
inserting_toks
,
list
),
"inserting_toks should be a list of strings."
assert
all
(
assert
all
(
isinstance
(
tok
,
str
)
for
tok
in
inserting_toks
),
(
isinstance
(
tok
,
str
)
for
tok
in
inserting_toks
"All elements in inserting_toks should be strings."
)
,
"All elements in inserting_toks should be strings."
)
self
.
inserting_toks
=
inserting_toks
self
.
inserting_toks
=
inserting_toks
special_tokens_dict
=
{
"additional_special_tokens"
:
self
.
inserting_toks
}
special_tokens_dict
=
{
"additional_special_tokens"
:
self
.
inserting_toks
}
...
@@ -912,9 +912,9 @@ class TokenEmbeddingsHandler:
...
@@ -912,9 +912,9 @@ class TokenEmbeddingsHandler:
.
to
(
dtype
=
self
.
dtype
)
.
to
(
dtype
=
self
.
dtype
)
*
std_token_embedding
*
std_token_embedding
)
)
self
.
embeddings_settings
[
self
.
embeddings_settings
[
f
"original_embeddings_
{
idx
}
"
]
=
(
f
"original_embeddings_
{
idx
}
"
text_encoder
.
text_model
.
embeddings
.
token_embedding
.
weight
.
data
.
clone
()
]
=
text_encoder
.
text_model
.
embeddings
.
token_embedding
.
weight
.
data
.
clone
(
)
)
self
.
embeddings_settings
[
f
"std_token_embedding_
{
idx
}
"
]
=
std_token_embedding
self
.
embeddings_settings
[
f
"std_token_embedding_
{
idx
}
"
]
=
std_token_embedding
inu
=
torch
.
ones
((
len
(
tokenizer
),),
dtype
=
torch
.
bool
)
inu
=
torch
.
ones
((
len
(
tokenizer
),),
dtype
=
torch
.
bool
)
...
@@ -1647,7 +1647,7 @@ def main(args):
...
@@ -1647,7 +1647,7 @@ def main(args):
lora_state_dict
,
network_alphas
=
StableDiffusionLoraLoaderMixin
.
lora_state_dict
(
input_dir
)
lora_state_dict
,
network_alphas
=
StableDiffusionLoraLoaderMixin
.
lora_state_dict
(
input_dir
)
unet_state_dict
=
{
f
'
{
k
.
replace
(
"
unet.
"
,
""
)
}
'
:
v
for
k
,
v
in
lora_state_dict
.
items
()
if
k
.
startswith
(
"unet."
)}
unet_state_dict
=
{
f
"
{
k
.
replace
(
'
unet.
'
,
''
)
}
"
:
v
for
k
,
v
in
lora_state_dict
.
items
()
if
k
.
startswith
(
"unet."
)}
unet_state_dict
=
convert_unet_state_dict_to_peft
(
unet_state_dict
)
unet_state_dict
=
convert_unet_state_dict_to_peft
(
unet_state_dict
)
incompatible_keys
=
set_peft_model_state_dict
(
unet_
,
unet_state_dict
,
adapter_name
=
"default"
)
incompatible_keys
=
set_peft_model_state_dict
(
unet_
,
unet_state_dict
,
adapter_name
=
"default"
)
if
incompatible_keys
is
not
None
:
if
incompatible_keys
is
not
None
:
...
...
examples/amused/train_amused.py
View file @
edc154da
...
@@ -720,7 +720,7 @@ def main(args):
...
@@ -720,7 +720,7 @@ def main(args):
# Train!
# Train!
logger
.
info
(
"***** Running training *****"
)
logger
.
info
(
"***** Running training *****"
)
logger
.
info
(
f
" Num training steps =
{
args
.
max_train_steps
}
"
)
logger
.
info
(
f
" Num training steps =
{
args
.
max_train_steps
}
"
)
logger
.
info
(
f
" Instantaneous batch size per device =
{
args
.
train_batch_size
}
"
)
logger
.
info
(
f
" Instantaneous batch size per device =
{
args
.
train_batch_size
}
"
)
logger
.
info
(
f
" Total train batch size (w. parallel, distributed & accumulation) =
{
total_batch_size
}
"
)
logger
.
info
(
f
" Total train batch size (w. parallel, distributed & accumulation) =
{
total_batch_size
}
"
)
logger
.
info
(
f
" Gradient Accumulation steps =
{
args
.
gradient_accumulation_steps
}
"
)
logger
.
info
(
f
" Gradient Accumulation steps =
{
args
.
gradient_accumulation_steps
}
"
)
...
...
examples/cogvideo/train_cogvideox_image_to_video_lora.py
View file @
edc154da
...
@@ -1138,7 +1138,7 @@ def main(args):
...
@@ -1138,7 +1138,7 @@ def main(args):
lora_state_dict
=
CogVideoXImageToVideoPipeline
.
lora_state_dict
(
input_dir
)
lora_state_dict
=
CogVideoXImageToVideoPipeline
.
lora_state_dict
(
input_dir
)
transformer_state_dict
=
{
transformer_state_dict
=
{
f
'
{
k
.
replace
(
"
transformer.
"
,
""
)
}
'
:
v
for
k
,
v
in
lora_state_dict
.
items
()
if
k
.
startswith
(
"transformer."
)
f
"
{
k
.
replace
(
'
transformer.
'
,
''
)
}
"
:
v
for
k
,
v
in
lora_state_dict
.
items
()
if
k
.
startswith
(
"transformer."
)
}
}
transformer_state_dict
=
convert_unet_state_dict_to_peft
(
transformer_state_dict
)
transformer_state_dict
=
convert_unet_state_dict_to_peft
(
transformer_state_dict
)
incompatible_keys
=
set_peft_model_state_dict
(
transformer_
,
transformer_state_dict
,
adapter_name
=
"default"
)
incompatible_keys
=
set_peft_model_state_dict
(
transformer_
,
transformer_state_dict
,
adapter_name
=
"default"
)
...
...
examples/cogvideo/train_cogvideox_lora.py
View file @
edc154da
...
@@ -1159,7 +1159,7 @@ def main(args):
...
@@ -1159,7 +1159,7 @@ def main(args):
lora_state_dict
=
CogVideoXPipeline
.
lora_state_dict
(
input_dir
)
lora_state_dict
=
CogVideoXPipeline
.
lora_state_dict
(
input_dir
)
transformer_state_dict
=
{
transformer_state_dict
=
{
f
'
{
k
.
replace
(
"
transformer.
"
,
""
)
}
'
:
v
for
k
,
v
in
lora_state_dict
.
items
()
if
k
.
startswith
(
"transformer."
)
f
"
{
k
.
replace
(
'
transformer.
'
,
''
)
}
"
:
v
for
k
,
v
in
lora_state_dict
.
items
()
if
k
.
startswith
(
"transformer."
)
}
}
transformer_state_dict
=
convert_unet_state_dict_to_peft
(
transformer_state_dict
)
transformer_state_dict
=
convert_unet_state_dict_to_peft
(
transformer_state_dict
)
incompatible_keys
=
set_peft_model_state_dict
(
transformer_
,
transformer_state_dict
,
adapter_name
=
"default"
)
incompatible_keys
=
set_peft_model_state_dict
(
transformer_
,
transformer_state_dict
,
adapter_name
=
"default"
)
...
...
examples/community/adaptive_mask_inpainting.py
View file @
edc154da
...
@@ -1103,7 +1103,7 @@ class AdaptiveMaskInpaintPipeline(
...
@@ -1103,7 +1103,7 @@ class AdaptiveMaskInpaintPipeline(
f
"Incorrect configuration settings! The config of `pipeline.unet`:
{
self
.
unet
.
config
}
expects"
f
"Incorrect configuration settings! The config of `pipeline.unet`:
{
self
.
unet
.
config
}
expects"
f
"
{
self
.
unet
.
config
.
in_channels
}
but received `num_channels_latents`:
{
num_channels_latents
}
+"
f
"
{
self
.
unet
.
config
.
in_channels
}
but received `num_channels_latents`:
{
num_channels_latents
}
+"
f
" `num_channels_mask`:
{
num_channels_mask
}
+ `num_channels_masked_image`:
{
num_channels_masked_image
}
"
f
" `num_channels_mask`:
{
num_channels_mask
}
+ `num_channels_masked_image`:
{
num_channels_masked_image
}
"
f
" =
{
num_channels_latents
+
num_channels_masked_image
+
num_channels_mask
}
. Please verify the config of"
f
" =
{
num_channels_latents
+
num_channels_masked_image
+
num_channels_mask
}
. Please verify the config of"
" `pipeline.unet` or your `default_mask_image` or `image` input."
" `pipeline.unet` or your `default_mask_image` or `image` input."
)
)
elif
num_channels_unet
!=
4
:
elif
num_channels_unet
!=
4
:
...
...
examples/community/hd_painter.py
View file @
edc154da
...
@@ -686,7 +686,7 @@ class StableDiffusionHDPainterPipeline(StableDiffusionInpaintPipeline):
...
@@ -686,7 +686,7 @@ class StableDiffusionHDPainterPipeline(StableDiffusionInpaintPipeline):
f
"Incorrect configuration settings! The config of `pipeline.unet`:
{
self
.
unet
.
config
}
expects"
f
"Incorrect configuration settings! The config of `pipeline.unet`:
{
self
.
unet
.
config
}
expects"
f
"
{
self
.
unet
.
config
.
in_channels
}
but received `num_channels_latents`:
{
num_channels_latents
}
+"
f
"
{
self
.
unet
.
config
.
in_channels
}
but received `num_channels_latents`:
{
num_channels_latents
}
+"
f
" `num_channels_mask`:
{
num_channels_mask
}
+ `num_channels_masked_image`:
{
num_channels_masked_image
}
"
f
" `num_channels_mask`:
{
num_channels_mask
}
+ `num_channels_masked_image`:
{
num_channels_masked_image
}
"
f
" =
{
num_channels_latents
+
num_channels_masked_image
+
num_channels_mask
}
. Please verify the config of"
f
" =
{
num_channels_latents
+
num_channels_masked_image
+
num_channels_mask
}
. Please verify the config of"
" `pipeline.unet` or your `mask_image` or `image` input."
" `pipeline.unet` or your `mask_image` or `image` input."
)
)
elif
num_channels_unet
!=
4
:
elif
num_channels_unet
!=
4
:
...
...
examples/community/img2img_inpainting.py
View file @
edc154da
...
@@ -362,7 +362,7 @@ class ImageToImageInpaintingPipeline(DiffusionPipeline):
...
@@ -362,7 +362,7 @@ class ImageToImageInpaintingPipeline(DiffusionPipeline):
f
"Incorrect configuration settings! The config of `pipeline.unet`:
{
self
.
unet
.
config
}
expects"
f
"Incorrect configuration settings! The config of `pipeline.unet`:
{
self
.
unet
.
config
}
expects"
f
"
{
self
.
unet
.
config
.
in_channels
}
but received `num_channels_latents`:
{
num_channels_latents
}
+"
f
"
{
self
.
unet
.
config
.
in_channels
}
but received `num_channels_latents`:
{
num_channels_latents
}
+"
f
" `num_channels_mask`:
{
num_channels_mask
}
+ `num_channels_masked_image`:
{
num_channels_masked_image
}
"
f
" `num_channels_mask`:
{
num_channels_mask
}
+ `num_channels_masked_image`:
{
num_channels_masked_image
}
"
f
" =
{
num_channels_latents
+
num_channels_masked_image
+
num_channels_mask
}
. Please verify the config of"
f
" =
{
num_channels_latents
+
num_channels_masked_image
+
num_channels_mask
}
. Please verify the config of"
" `pipeline.unet` or your `mask_image` or `image` input."
" `pipeline.unet` or your `mask_image` or `image` input."
)
)
...
...
examples/community/llm_grounded_diffusion.py
View file @
edc154da
...
@@ -1120,7 +1120,7 @@ class LLMGroundedDiffusionPipeline(
...
@@ -1120,7 +1120,7 @@ class LLMGroundedDiffusionPipeline(
if
verbose
:
if
verbose
:
logger
.
info
(
logger
.
info
(
f
"time index
{
index
}
, loss:
{
loss
.
item
()
/
loss_scale
:.
3
f
}
(de-scaled with scale
{
loss_scale
:.
1
f
}
), loss threshold:
{
loss_threshold
:.
3
f
}
"
f
"time index
{
index
}
, loss:
{
loss
.
item
()
/
loss_scale
:.
3
f
}
(de-scaled with scale
{
loss_scale
:.
1
f
}
), loss threshold:
{
loss_threshold
:.
3
f
}
"
)
)
try
:
try
:
...
@@ -1184,7 +1184,7 @@ class LLMGroundedDiffusionPipeline(
...
@@ -1184,7 +1184,7 @@ class LLMGroundedDiffusionPipeline(
if
verbose
:
if
verbose
:
logger
.
info
(
logger
.
info
(
f
"time index
{
index
}
, loss:
{
loss
.
item
()
/
loss_scale
:.
3
f
}
, loss threshold:
{
loss_threshold
:.
3
f
}
, iteration:
{
iteration
}
"
f
"time index
{
index
}
, loss:
{
loss
.
item
()
/
loss_scale
:.
3
f
}
, loss threshold:
{
loss_threshold
:.
3
f
}
, iteration:
{
iteration
}
"
)
)
finally
:
finally
:
...
...
examples/community/mod_controlnet_tile_sr_sdxl.py
View file @
edc154da
...
@@ -701,7 +701,7 @@ class StableDiffusionXLControlNetTileSRPipeline(
...
@@ -701,7 +701,7 @@ class StableDiffusionXLControlNetTileSRPipeline(
raise
ValueError
(
"`max_tile_size` cannot be None."
)
raise
ValueError
(
"`max_tile_size` cannot be None."
)
elif
not
isinstance
(
max_tile_size
,
int
)
or
max_tile_size
not
in
(
1024
,
1280
):
elif
not
isinstance
(
max_tile_size
,
int
)
or
max_tile_size
not
in
(
1024
,
1280
):
raise
ValueError
(
raise
ValueError
(
f
"`max_tile_size` has to be in 1024 or 1280 but is
{
max_tile_size
}
of type
"
f
"
{
type
(
max_tile_size
)
}
."
f
"`max_tile_size` has to be in 1024 or 1280 but is
{
max_tile_size
}
of type
{
type
(
max_tile_size
)
}
."
)
)
if
tile_gaussian_sigma
is
None
:
if
tile_gaussian_sigma
is
None
:
raise
ValueError
(
"`tile_gaussian_sigma` cannot be None."
)
raise
ValueError
(
"`tile_gaussian_sigma` cannot be None."
)
...
...
examples/community/pipeline_flux_differential_img2img.py
View file @
edc154da
...
@@ -488,7 +488,7 @@ class FluxDifferentialImg2ImgPipeline(DiffusionPipeline, FluxLoraLoaderMixin):
...
@@ -488,7 +488,7 @@ class FluxDifferentialImg2ImgPipeline(DiffusionPipeline, FluxLoraLoaderMixin):
if
padding_mask_crop
is
not
None
:
if
padding_mask_crop
is
not
None
:
if
not
isinstance
(
image
,
PIL
.
Image
.
Image
):
if
not
isinstance
(
image
,
PIL
.
Image
.
Image
):
raise
ValueError
(
raise
ValueError
(
f
"The image should be a PIL image when inpainting mask crop, but is of type
"
f
"
{
type
(
image
)
}
."
f
"The image should be a PIL image when inpainting mask crop, but is of type
{
type
(
image
)
}
."
)
)
if
not
isinstance
(
mask_image
,
PIL
.
Image
.
Image
):
if
not
isinstance
(
mask_image
,
PIL
.
Image
.
Image
):
raise
ValueError
(
raise
ValueError
(
...
@@ -496,7 +496,7 @@ class FluxDifferentialImg2ImgPipeline(DiffusionPipeline, FluxLoraLoaderMixin):
...
@@ -496,7 +496,7 @@ class FluxDifferentialImg2ImgPipeline(DiffusionPipeline, FluxLoraLoaderMixin):
f
"
{
type
(
mask_image
)
}
."
f
"
{
type
(
mask_image
)
}
."
)
)
if
output_type
!=
"pil"
:
if
output_type
!=
"pil"
:
raise
ValueError
(
f
"The output type should be PIL when inpainting mask crop, but is
"
f
"
{
output_type
}
."
)
raise
ValueError
(
f
"The output type should be PIL when inpainting mask crop, but is
{
output_type
}
."
)
if
max_sequence_length
is
not
None
and
max_sequence_length
>
512
:
if
max_sequence_length
is
not
None
and
max_sequence_length
>
512
:
raise
ValueError
(
f
"`max_sequence_length` cannot be greater than 512 but is
{
max_sequence_length
}
"
)
raise
ValueError
(
f
"`max_sequence_length` cannot be greater than 512 but is
{
max_sequence_length
}
"
)
...
...
examples/community/pipeline_prompt2prompt.py
View file @
edc154da
...
@@ -907,12 +907,12 @@ def create_controller(
...
@@ -907,12 +907,12 @@ def create_controller(
# reweight
# reweight
if
edit_type
==
"reweight"
:
if
edit_type
==
"reweight"
:
assert
(
assert
equalizer_words
is
not
None
and
equalizer_strengths
is
not
None
,
(
equalizer_words
is
not
None
and
equalizer_strengths
is
not
None
"To use reweight edit, please specify
equalizer_words and equalizer_strengths
."
)
,
"To use reweight edit, please specify equalizer_words and equalizer_strengths."
)
assert
len
(
equalizer_words
)
==
len
(
assert
len
(
equalizer_words
)
==
len
(
equalizer_strengths
),
(
equalizer_strengths
"equalizer_words and equalizer_strengths must be of same length."
)
,
"equalizer_words and equalizer_strengths must be of same length."
)
equalizer
=
get_equalizer
(
prompts
[
1
],
equalizer_words
,
equalizer_strengths
,
tokenizer
=
tokenizer
)
equalizer
=
get_equalizer
(
prompts
[
1
],
equalizer_words
,
equalizer_strengths
,
tokenizer
=
tokenizer
)
return
AttentionReweight
(
return
AttentionReweight
(
prompts
,
prompts
,
...
...
examples/community/pipeline_sdxl_style_aligned.py
View file @
edc154da
...
@@ -1738,7 +1738,7 @@ class StyleAlignedSDXLPipeline(
...
@@ -1738,7 +1738,7 @@ class StyleAlignedSDXLPipeline(
f
"Incorrect configuration settings! The config of `pipeline.unet`:
{
self
.
unet
.
config
}
expects"
f
"Incorrect configuration settings! The config of `pipeline.unet`:
{
self
.
unet
.
config
}
expects"
f
"
{
self
.
unet
.
config
.
in_channels
}
but received `num_channels_latents`:
{
num_channels_latents
}
+"
f
"
{
self
.
unet
.
config
.
in_channels
}
but received `num_channels_latents`:
{
num_channels_latents
}
+"
f
" `num_channels_mask`:
{
num_channels_mask
}
+ `num_channels_masked_image`:
{
num_channels_masked_image
}
"
f
" `num_channels_mask`:
{
num_channels_mask
}
+ `num_channels_masked_image`:
{
num_channels_masked_image
}
"
f
" =
{
num_channels_latents
+
num_channels_masked_image
+
num_channels_mask
}
. Please verify the config of"
f
" =
{
num_channels_latents
+
num_channels_masked_image
+
num_channels_mask
}
. Please verify the config of"
" `pipeline.unet` or your `mask_image` or `image` input."
" `pipeline.unet` or your `mask_image` or `image` input."
)
)
elif
num_channels_unet
!=
4
:
elif
num_channels_unet
!=
4
:
...
...
examples/community/pipeline_stable_diffusion_upscale_ldm3d.py
View file @
edc154da
...
@@ -689,7 +689,7 @@ class StableDiffusionUpscaleLDM3DPipeline(
...
@@ -689,7 +689,7 @@ class StableDiffusionUpscaleLDM3DPipeline(
f
"Incorrect configuration settings! The config of `pipeline.unet`:
{
self
.
unet
.
config
}
expects"
f
"Incorrect configuration settings! The config of `pipeline.unet`:
{
self
.
unet
.
config
}
expects"
f
"
{
self
.
unet
.
config
.
in_channels
}
but received `num_channels_latents`:
{
num_channels_latents
}
+"
f
"
{
self
.
unet
.
config
.
in_channels
}
but received `num_channels_latents`:
{
num_channels_latents
}
+"
f
" `num_channels_image`:
{
num_channels_image
}
"
f
" `num_channels_image`:
{
num_channels_image
}
"
f
" =
{
num_channels_latents
+
num_channels_image
}
. Please verify the config of"
f
" =
{
num_channels_latents
+
num_channels_image
}
. Please verify the config of"
" `pipeline.unet` or your `image` input."
" `pipeline.unet` or your `image` input."
)
)
...
...
examples/community/pipeline_stable_diffusion_xl_attentive_eraser.py
View file @
edc154da
...
@@ -1028,7 +1028,7 @@ class StableDiffusionXL_AE_Pipeline(
...
@@ -1028,7 +1028,7 @@ class StableDiffusionXL_AE_Pipeline(
if
padding_mask_crop
is
not
None
:
if
padding_mask_crop
is
not
None
:
if
not
isinstance
(
image
,
PIL
.
Image
.
Image
):
if
not
isinstance
(
image
,
PIL
.
Image
.
Image
):
raise
ValueError
(
raise
ValueError
(
f
"The image should be a PIL image when inpainting mask crop, but is of type
"
f
"
{
type
(
image
)
}
."
f
"The image should be a PIL image when inpainting mask crop, but is of type
{
type
(
image
)
}
."
)
)
if
not
isinstance
(
mask_image
,
PIL
.
Image
.
Image
):
if
not
isinstance
(
mask_image
,
PIL
.
Image
.
Image
):
raise
ValueError
(
raise
ValueError
(
...
@@ -1036,7 +1036,7 @@ class StableDiffusionXL_AE_Pipeline(
...
@@ -1036,7 +1036,7 @@ class StableDiffusionXL_AE_Pipeline(
f
"
{
type
(
mask_image
)
}
."
f
"
{
type
(
mask_image
)
}
."
)
)
if
output_type
!=
"pil"
:
if
output_type
!=
"pil"
:
raise
ValueError
(
f
"The output type should be PIL when inpainting mask crop, but is
"
f
"
{
output_type
}
."
)
raise
ValueError
(
f
"The output type should be PIL when inpainting mask crop, but is
{
output_type
}
."
)
if
ip_adapter_image
is
not
None
and
ip_adapter_image_embeds
is
not
None
:
if
ip_adapter_image
is
not
None
and
ip_adapter_image_embeds
is
not
None
:
raise
ValueError
(
raise
ValueError
(
...
@@ -2050,7 +2050,7 @@ class StableDiffusionXL_AE_Pipeline(
...
@@ -2050,7 +2050,7 @@ class StableDiffusionXL_AE_Pipeline(
f
"Incorrect configuration settings! The config of `pipeline.unet`:
{
self
.
unet
.
config
}
expects"
f
"Incorrect configuration settings! The config of `pipeline.unet`:
{
self
.
unet
.
config
}
expects"
f
"
{
self
.
unet
.
config
.
in_channels
}
but received `num_channels_latents`:
{
num_channels_latents
}
+"
f
"
{
self
.
unet
.
config
.
in_channels
}
but received `num_channels_latents`:
{
num_channels_latents
}
+"
f
" `num_channels_mask`:
{
num_channels_mask
}
+ `num_channels_masked_image`:
{
num_channels_masked_image
}
"
f
" `num_channels_mask`:
{
num_channels_mask
}
+ `num_channels_masked_image`:
{
num_channels_masked_image
}
"
f
" =
{
num_channels_latents
+
num_channels_masked_image
+
num_channels_mask
}
. Please verify the config of"
f
" =
{
num_channels_latents
+
num_channels_masked_image
+
num_channels_mask
}
. Please verify the config of"
" `pipeline.unet` or your `mask_image` or `image` input."
" `pipeline.unet` or your `mask_image` or `image` input."
)
)
elif
num_channels_unet
!=
4
:
elif
num_channels_unet
!=
4
:
...
...
examples/community/pipeline_stable_diffusion_xl_controlnet_adapter_inpaint.py
View file @
edc154da
...
@@ -1578,7 +1578,7 @@ class StableDiffusionXLControlNetAdapterInpaintPipeline(
...
@@ -1578,7 +1578,7 @@ class StableDiffusionXLControlNetAdapterInpaintPipeline(
f
"Incorrect configuration settings! The config of `pipeline.unet`:
{
self
.
unet
.
config
}
expects"
f
"Incorrect configuration settings! The config of `pipeline.unet`:
{
self
.
unet
.
config
}
expects"
f
"
{
self
.
unet
.
config
.
in_channels
}
but received `num_channels_latents`:
{
num_channels_latents
}
+"
f
"
{
self
.
unet
.
config
.
in_channels
}
but received `num_channels_latents`:
{
num_channels_latents
}
+"
f
" `num_channels_mask`:
{
num_channels_mask
}
+ `num_channels_masked_image`:
{
num_channels_masked_image
}
"
f
" `num_channels_mask`:
{
num_channels_mask
}
+ `num_channels_masked_image`:
{
num_channels_masked_image
}
"
f
" =
{
num_channels_latents
+
num_channels_masked_image
+
num_channels_mask
}
. Please verify the config of"
f
" =
{
num_channels_latents
+
num_channels_masked_image
+
num_channels_mask
}
. Please verify the config of"
" `pipeline.unet` or your `mask_image` or `image` input."
" `pipeline.unet` or your `mask_image` or `image` input."
)
)
elif
num_channels_unet
!=
4
:
elif
num_channels_unet
!=
4
:
...
...
examples/community/scheduling_ufogen.py
View file @
edc154da
...
@@ -288,8 +288,7 @@ class UFOGenScheduler(SchedulerMixin, ConfigMixin):
...
@@ -288,8 +288,7 @@ class UFOGenScheduler(SchedulerMixin, ConfigMixin):
if
timesteps
[
0
]
>=
self
.
config
.
num_train_timesteps
:
if
timesteps
[
0
]
>=
self
.
config
.
num_train_timesteps
:
raise
ValueError
(
raise
ValueError
(
f
"`timesteps` must start before `self.config.train_timesteps`:"
f
"`timesteps` must start before `self.config.train_timesteps`:
{
self
.
config
.
num_train_timesteps
}
."
f
"
{
self
.
config
.
num_train_timesteps
}
."
)
)
timesteps
=
np
.
array
(
timesteps
,
dtype
=
np
.
int64
)
timesteps
=
np
.
array
(
timesteps
,
dtype
=
np
.
int64
)
...
...
examples/consistency_distillation/train_lcm_distill_lora_sd_wds.py
View file @
edc154da
...
@@ -89,7 +89,7 @@ def get_module_kohya_state_dict(module, prefix: str, dtype: torch.dtype, adapter
...
@@ -89,7 +89,7 @@ def get_module_kohya_state_dict(module, prefix: str, dtype: torch.dtype, adapter
# Set alpha parameter
# Set alpha parameter
if
"lora_down"
in
kohya_key
:
if
"lora_down"
in
kohya_key
:
alpha_key
=
f
'
{
kohya_key
.
split
(
"."
)[
0
]
}
.alpha
'
alpha_key
=
f
"
{
kohya_key
.
split
(
'.'
)[
0
]
}
.alpha
"
kohya_ss_state_dict
[
alpha_key
]
=
torch
.
tensor
(
module
.
peft_config
[
adapter_name
].
lora_alpha
).
to
(
dtype
)
kohya_ss_state_dict
[
alpha_key
]
=
torch
.
tensor
(
module
.
peft_config
[
adapter_name
].
lora_alpha
).
to
(
dtype
)
return
kohya_ss_state_dict
return
kohya_ss_state_dict
...
...
examples/consistency_distillation/train_lcm_distill_lora_sdxl.py
View file @
edc154da
...
@@ -901,7 +901,7 @@ def main(args):
...
@@ -901,7 +901,7 @@ def main(args):
unet_
=
accelerator
.
unwrap_model
(
unet
)
unet_
=
accelerator
.
unwrap_model
(
unet
)
lora_state_dict
,
_
=
StableDiffusionXLPipeline
.
lora_state_dict
(
input_dir
)
lora_state_dict
,
_
=
StableDiffusionXLPipeline
.
lora_state_dict
(
input_dir
)
unet_state_dict
=
{
unet_state_dict
=
{
f
'
{
k
.
replace
(
"
unet.
"
,
""
)
}
'
:
v
for
k
,
v
in
lora_state_dict
.
items
()
if
k
.
startswith
(
"unet."
)
f
"
{
k
.
replace
(
'
unet.
'
,
''
)
}
"
:
v
for
k
,
v
in
lora_state_dict
.
items
()
if
k
.
startswith
(
"unet."
)
}
}
unet_state_dict
=
convert_unet_state_dict_to_peft
(
unet_state_dict
)
unet_state_dict
=
convert_unet_state_dict_to_peft
(
unet_state_dict
)
incompatible_keys
=
set_peft_model_state_dict
(
unet_
,
unet_state_dict
,
adapter_name
=
"default"
)
incompatible_keys
=
set_peft_model_state_dict
(
unet_
,
unet_state_dict
,
adapter_name
=
"default"
)
...
...
Prev
1
2
3
4
5
…
10
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