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
d1d0b8af
Unverified
Commit
d1d0b8af
authored
Jul 07, 2023
by
Amiha
Committed by
GitHub
Jul 07, 2023
Browse files
Don't use bare prints in a library (#3991)
parent
04ddad48
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
4 deletions
+4
-4
src/diffusers/pipelines/stable_diffusion/convert_from_ckpt.py
...diffusers/pipelines/stable_diffusion/convert_from_ckpt.py
+4
-4
No files found.
src/diffusers/pipelines/stable_diffusion/convert_from_ckpt.py
View file @
d1d0b8af
...
@@ -391,8 +391,8 @@ def convert_ldm_unet_checkpoint(
...
@@ -391,8 +391,8 @@ def convert_ldm_unet_checkpoint(
# at least a 100 parameters have to start with `model_ema` in order for the checkpoint to be EMA
# at least a 100 parameters have to start with `model_ema` in order for the checkpoint to be EMA
if
sum
(
k
.
startswith
(
"model_ema"
)
for
k
in
keys
)
>
100
and
extract_ema
:
if
sum
(
k
.
startswith
(
"model_ema"
)
for
k
in
keys
)
>
100
and
extract_ema
:
pr
in
t
(
f
"Checkpoint
{
path
}
has both EMA and non-EMA weights."
)
logger
.
warn
in
g
(
f
"Checkpoint
{
path
}
has both EMA and non-EMA weights."
)
pr
in
t
(
logger
.
warn
in
g
(
"In this conversion only the EMA weights are extracted. If you want to instead extract the non-EMA"
"In this conversion only the EMA weights are extracted. If you want to instead extract the non-EMA"
" weights (useful to continue fine-tuning), please make sure to remove the `--extract_ema` flag."
" weights (useful to continue fine-tuning), please make sure to remove the `--extract_ema` flag."
)
)
...
@@ -402,7 +402,7 @@ def convert_ldm_unet_checkpoint(
...
@@ -402,7 +402,7 @@ def convert_ldm_unet_checkpoint(
unet_state_dict
[
key
.
replace
(
unet_key
,
""
)]
=
checkpoint
.
pop
(
flat_ema_key
)
unet_state_dict
[
key
.
replace
(
unet_key
,
""
)]
=
checkpoint
.
pop
(
flat_ema_key
)
else
:
else
:
if
sum
(
k
.
startswith
(
"model_ema"
)
for
k
in
keys
)
>
100
:
if
sum
(
k
.
startswith
(
"model_ema"
)
for
k
in
keys
)
>
100
:
pr
in
t
(
logger
.
warn
in
g
(
"In this conversion only the non-EMA weights are extracted. If you want to instead extract the EMA"
"In this conversion only the non-EMA weights are extracted. If you want to instead extract the EMA"
" weights (usually better for inference), please make sure to add the `--extract_ema` flag."
" weights (usually better for inference), please make sure to add the `--extract_ema` flag."
)
)
...
@@ -1183,7 +1183,7 @@ def download_from_original_stable_diffusion_ckpt(
...
@@ -1183,7 +1183,7 @@ def download_from_original_stable_diffusion_ckpt(
if
"global_step"
in
checkpoint
:
if
"global_step"
in
checkpoint
:
global_step
=
checkpoint
[
"global_step"
]
global_step
=
checkpoint
[
"global_step"
]
else
:
else
:
pr
in
t
(
"global_step key not found in model"
)
logger
.
warn
in
g
(
"global_step key not found in model"
)
global_step
=
None
global_step
=
None
# NOTE: this while loop isn't great but this controlnet checkpoint has one additional
# NOTE: this while loop isn't great but this controlnet checkpoint has one additional
...
...
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