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
334ba48c
Commit
334ba48c
authored
Jul 23, 2024
by
comfyanonymous
Browse files
More generic unet prefix detection code.
parent
14764aa2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
6 deletions
+15
-6
comfy/model_detection.py
comfy/model_detection.py
+15
-6
No files found.
comfy/model_detection.py
View file @
334ba48c
...
...
@@ -261,13 +261,22 @@ def model_config_from_unet(state_dict, unet_key_prefix, use_base_if_no_match=Fal
return
model_config
def
unet_prefix_from_state_dict
(
state_dict
):
if
"model.model.postprocess_conv.weight"
in
state_dict
:
#audio models
unet_key_prefix
=
"model.model."
elif
"model.double_layers.0.attn.w1q.weight"
in
state_dict
:
#aura flow
unet_key_prefix
=
"model."
candidates
=
[
"model.diffusion_model."
,
#ldm/sgm models
"model.model."
,
#audio models
]
counts
=
{
k
:
0
for
k
in
candidates
}
for
k
in
state_dict
:
for
c
in
candidates
:
if
k
.
startswith
(
c
):
counts
[
c
]
+=
1
break
top
=
max
(
counts
,
key
=
counts
.
get
)
if
counts
[
top
]
>
5
:
return
top
else
:
unet_key_prefix
=
"model.diffusion_model."
return
unet_key_prefix
return
"model."
#aura flow and others
def
convert_config
(
unet_config
):
new_config
=
unet_config
.
copy
()
...
...
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