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
9f4214e5
Commit
9f4214e5
authored
Feb 26, 2023
by
comfyanonymous
Browse files
Preparing to add another function to load checkpoints.
parent
3cd7d84b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
7 deletions
+4
-7
comfy/sd.py
comfy/sd.py
+4
-7
No files found.
comfy/sd.py
View file @
9f4214e5
...
@@ -26,12 +26,7 @@ def load_torch_file(ckpt):
...
@@ -26,12 +26,7 @@ def load_torch_file(ckpt):
sd
=
pl_sd
sd
=
pl_sd
return
sd
return
sd
def
load_model_from_config
(
config
,
ckpt
,
verbose
=
False
,
load_state_dict_to
=
[]):
def
load_model_weights
(
model
,
sd
,
verbose
=
False
,
load_state_dict_to
=
[]):
print
(
f
"Loading model from
{
ckpt
}
"
)
sd
=
load_torch_file
(
ckpt
)
model
=
instantiate_from_config
(
config
.
model
)
m
,
u
=
model
.
load_state_dict
(
sd
,
strict
=
False
)
m
,
u
=
model
.
load_state_dict
(
sd
,
strict
=
False
)
k
=
list
(
sd
.
keys
())
k
=
list
(
sd
.
keys
())
...
@@ -654,5 +649,7 @@ def load_checkpoint(config_path, ckpt_path, output_vae=True, output_clip=True, e
...
@@ -654,5 +649,7 @@ def load_checkpoint(config_path, ckpt_path, output_vae=True, output_clip=True, e
w
.
cond_stage_model
=
clip
.
cond_stage_model
w
.
cond_stage_model
=
clip
.
cond_stage_model
load_state_dict_to
=
[
w
]
load_state_dict_to
=
[
w
]
model
=
load_model_from_config
(
config
,
ckpt_path
,
verbose
=
False
,
load_state_dict_to
=
load_state_dict_to
)
model
=
instantiate_from_config
(
config
.
model
)
sd
=
load_torch_file
(
ckpt_path
)
model
=
load_model_weights
(
model
,
sd
,
verbose
=
False
,
load_state_dict_to
=
load_state_dict_to
)
return
(
ModelPatcher
(
model
),
clip
,
vae
)
return
(
ModelPatcher
(
model
),
clip
,
vae
)
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