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
chenpangpang
ComfyUI
Commits
d7484ef3
"...git@developer.sourcefind.cn:modelzoo/nanotron_pytorch.git" did not exist on "61e929042c8139432a834c53dbeec6eddf7e8c59"
Commit
d7484ef3
authored
Jul 03, 2024
by
comfyanonymous
Browse files
Support loading checkpoints with the UNETLoader node.
parent
537f35c7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
8 deletions
+16
-8
comfy/sd.py
comfy/sd.py
+16
-8
No files found.
comfy/sd.py
View file @
d7484ef3
...
@@ -563,24 +563,32 @@ def load_checkpoint_guess_config(ckpt_path, output_vae=True, output_clip=True, o
...
@@ -563,24 +563,32 @@ def load_checkpoint_guess_config(ckpt_path, output_vae=True, output_clip=True, o
return
(
model_patcher
,
clip
,
vae
,
clipvision
)
return
(
model_patcher
,
clip
,
vae
,
clipvision
)
def
load_unet_state_dict
(
sd
):
#load unet in diffusers format
def
load_unet_state_dict
(
sd
):
#load unet in diffusers or regular format
#Allow loading unets from checkpoint files
checkpoint
=
False
diffusion_model_prefix
=
model_detection
.
unet_prefix_from_state_dict
(
sd
)
temp_sd
=
comfy
.
utils
.
state_dict_prefix_replace
(
sd
,
{
diffusion_model_prefix
:
""
},
filter_keys
=
True
)
if
len
(
temp_sd
)
>
0
:
sd
=
temp_sd
checkpoint
=
True
parameters
=
comfy
.
utils
.
calculate_parameters
(
sd
)
parameters
=
comfy
.
utils
.
calculate_parameters
(
sd
)
unet_dtype
=
model_management
.
unet_dtype
(
model_params
=
parameters
)
unet_dtype
=
model_management
.
unet_dtype
(
model_params
=
parameters
)
load_device
=
model_management
.
get_torch_device
()
load_device
=
model_management
.
get_torch_device
()
if
'transformer_blocks.0.attn.add_q_proj.weight'
in
sd
:
#MMDIT SD3
if
checkpoint
or
"input_blocks.0.0.weight"
in
sd
or
'clf.1.weight'
in
sd
:
#ldm or stable cascade
model_config
=
model_detection
.
model_config_from_unet
(
sd
,
""
)
if
model_config
is
None
:
return
None
new_sd
=
sd
elif
'transformer_blocks.0.attn.add_q_proj.weight'
in
sd
:
#MMDIT SD3
new_sd
=
model_detection
.
convert_diffusers_mmdit
(
sd
,
""
)
new_sd
=
model_detection
.
convert_diffusers_mmdit
(
sd
,
""
)
if
new_sd
is
None
:
if
new_sd
is
None
:
return
None
return
None
model_config
=
model_detection
.
model_config_from_unet
(
new_sd
,
""
)
model_config
=
model_detection
.
model_config_from_unet
(
new_sd
,
""
)
if
model_config
is
None
:
if
model_config
is
None
:
return
None
return
None
elif
"input_blocks.0.0.weight"
in
sd
or
'clf.1.weight'
in
sd
:
#ldm or stable cascade
model_config
=
model_detection
.
model_config_from_unet
(
sd
,
""
)
if
model_config
is
None
:
return
None
new_sd
=
sd
else
:
#diffusers
else
:
#diffusers
model_config
=
model_detection
.
model_config_from_diffusers_unet
(
sd
)
model_config
=
model_detection
.
model_config_from_diffusers_unet
(
sd
)
if
model_config
is
None
:
if
model_config
is
None
:
...
...
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