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
5e3ac192
Commit
5e3ac192
authored
Jul 25, 2023
by
comfyanonymous
Browse files
Implement modelspec metadata in CheckpointSave for SDXL and refiner.
parent
727588d0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
0 deletions
+27
-0
comfy_extras/nodes_model_merging.py
comfy_extras/nodes_model_merging.py
+27
-0
No files found.
comfy_extras/nodes_model_merging.py
View file @
5e3ac192
import
comfy.sd
import
comfy.sd
import
comfy.utils
import
comfy.utils
import
comfy.model_base
import
folder_paths
import
folder_paths
import
json
import
json
import
os
import
os
...
@@ -100,6 +102,31 @@ class CheckpointSave:
...
@@ -100,6 +102,31 @@ class CheckpointSave:
prompt_info
=
json
.
dumps
(
prompt
)
prompt_info
=
json
.
dumps
(
prompt
)
metadata
=
{
"prompt"
:
prompt_info
}
metadata
=
{
"prompt"
:
prompt_info
}
enable_modelspec
=
True
if
isinstance
(
model
.
model
,
comfy
.
model_base
.
SDXL
):
metadata
[
"modelspec.architecture"
]
=
"stable-diffusion-xl-v1-base"
elif
isinstance
(
model
.
model
,
comfy
.
model_base
.
SDXLRefiner
):
metadata
[
"modelspec.architecture"
]
=
"stable-diffusion-xl-v1-refiner"
else
:
enable_modelspec
=
False
if
enable_modelspec
:
metadata
[
"modelspec.sai_model_spec"
]
=
"1.0.0"
metadata
[
"modelspec.implementation"
]
=
"sgm"
metadata
[
"modelspec.title"
]
=
"{} {}"
.
format
(
filename
,
counter
)
#TODO:
# "stable-diffusion-v1", "stable-diffusion-v1-inpainting", "stable-diffusion-v2-512",
# "stable-diffusion-v2-768-v", "stable-diffusion-v2-unclip-l", "stable-diffusion-v2-unclip-h",
# "v2-inpainting"
if
model
.
model
.
model_type
==
comfy
.
model_base
.
ModelType
.
EPS
:
metadata
[
"modelspec.predict_key"
]
=
"epsilon"
elif
model
.
model
.
model_type
==
comfy
.
model_base
.
ModelType
.
V_PREDICTION
:
metadata
[
"modelspec.predict_key"
]
=
"v"
if
extra_pnginfo
is
not
None
:
if
extra_pnginfo
is
not
None
:
for
x
in
extra_pnginfo
:
for
x
in
extra_pnginfo
:
metadata
[
x
]
=
json
.
dumps
(
extra_pnginfo
[
x
])
metadata
[
x
]
=
json
.
dumps
(
extra_pnginfo
[
x
])
...
...
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