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
72188dff
"...git@developer.sourcefind.cn:modelzoo/solov2-pytorch.git" did not exist on "40ea9ca23a1cbe65dbe800dc065acfe44f5626f8"
Commit
72188dff
authored
Oct 06, 2023
by
comfyanonymous
Browse files
load_checkpoint_guess_config can now optionally output the model.
parent
5b828258
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
9 deletions
+12
-9
comfy/sd.py
comfy/sd.py
+12
-9
No files found.
comfy/sd.py
View file @
72188dff
...
@@ -394,13 +394,14 @@ def load_checkpoint(config_path=None, ckpt_path=None, output_vae=True, output_cl
...
@@ -394,13 +394,14 @@ def load_checkpoint(config_path=None, ckpt_path=None, output_vae=True, output_cl
return
(
comfy
.
model_patcher
.
ModelPatcher
(
model
,
load_device
=
model_management
.
get_torch_device
(),
offload_device
=
offload_device
),
clip
,
vae
)
return
(
comfy
.
model_patcher
.
ModelPatcher
(
model
,
load_device
=
model_management
.
get_torch_device
(),
offload_device
=
offload_device
),
clip
,
vae
)
def
load_checkpoint_guess_config
(
ckpt_path
,
output_vae
=
True
,
output_clip
=
True
,
output_clipvision
=
False
,
embedding_directory
=
None
):
def
load_checkpoint_guess_config
(
ckpt_path
,
output_vae
=
True
,
output_clip
=
True
,
output_clipvision
=
False
,
embedding_directory
=
None
,
output_model
=
True
):
sd
=
comfy
.
utils
.
load_torch_file
(
ckpt_path
)
sd
=
comfy
.
utils
.
load_torch_file
(
ckpt_path
)
sd_keys
=
sd
.
keys
()
sd_keys
=
sd
.
keys
()
clip
=
None
clip
=
None
clipvision
=
None
clipvision
=
None
vae
=
None
vae
=
None
model
=
None
model
=
None
model_patcher
=
None
clip_target
=
None
clip_target
=
None
parameters
=
comfy
.
utils
.
calculate_parameters
(
sd
,
"model.diffusion_model."
)
parameters
=
comfy
.
utils
.
calculate_parameters
(
sd
,
"model.diffusion_model."
)
...
@@ -421,6 +422,7 @@ def load_checkpoint_guess_config(ckpt_path, output_vae=True, output_clip=True, o
...
@@ -421,6 +422,7 @@ def load_checkpoint_guess_config(ckpt_path, output_vae=True, output_clip=True, o
if
fp16
:
if
fp16
:
dtype
=
torch
.
float16
dtype
=
torch
.
float16
if
output_model
:
inital_load_device
=
model_management
.
unet_inital_load_device
(
parameters
,
dtype
)
inital_load_device
=
model_management
.
unet_inital_load_device
(
parameters
,
dtype
)
offload_device
=
model_management
.
unet_offload_device
()
offload_device
=
model_management
.
unet_offload_device
()
model
=
model_config
.
get_model
(
sd
,
"model.diffusion_model."
,
device
=
inital_load_device
)
model
=
model_config
.
get_model
(
sd
,
"model.diffusion_model."
,
device
=
inital_load_device
)
...
@@ -444,6 +446,7 @@ def load_checkpoint_guess_config(ckpt_path, output_vae=True, output_clip=True, o
...
@@ -444,6 +446,7 @@ def load_checkpoint_guess_config(ckpt_path, output_vae=True, output_clip=True, o
if
len
(
left_over
)
>
0
:
if
len
(
left_over
)
>
0
:
print
(
"left over keys:"
,
left_over
)
print
(
"left over keys:"
,
left_over
)
if
output_model
:
model_patcher
=
comfy
.
model_patcher
.
ModelPatcher
(
model
,
load_device
=
model_management
.
get_torch_device
(),
offload_device
=
model_management
.
unet_offload_device
(),
current_device
=
inital_load_device
)
model_patcher
=
comfy
.
model_patcher
.
ModelPatcher
(
model
,
load_device
=
model_management
.
get_torch_device
(),
offload_device
=
model_management
.
unet_offload_device
(),
current_device
=
inital_load_device
)
if
inital_load_device
!=
torch
.
device
(
"cpu"
):
if
inital_load_device
!=
torch
.
device
(
"cpu"
):
print
(
"loaded straight to GPU"
)
print
(
"loaded straight to GPU"
)
...
...
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