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
c59fe9f2
Commit
c59fe9f2
authored
Apr 18, 2024
by
comfyanonymous
Browse files
Support VAE without quant_conv.
parent
a88b0ebc
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
2 deletions
+8
-2
comfy/sd.py
comfy/sd.py
+8
-2
No files found.
comfy/sd.py
View file @
c59fe9f2
...
@@ -214,12 +214,18 @@ class VAE:
...
@@ -214,12 +214,18 @@ class VAE:
#default SD1.x/SD2.x VAE parameters
#default SD1.x/SD2.x VAE parameters
ddconfig
=
{
'double_z'
:
True
,
'z_channels'
:
4
,
'resolution'
:
256
,
'in_channels'
:
3
,
'out_ch'
:
3
,
'ch'
:
128
,
'ch_mult'
:
[
1
,
2
,
4
,
4
],
'num_res_blocks'
:
2
,
'attn_resolutions'
:
[],
'dropout'
:
0.0
}
ddconfig
=
{
'double_z'
:
True
,
'z_channels'
:
4
,
'resolution'
:
256
,
'in_channels'
:
3
,
'out_ch'
:
3
,
'ch'
:
128
,
'ch_mult'
:
[
1
,
2
,
4
,
4
],
'num_res_blocks'
:
2
,
'attn_resolutions'
:
[],
'dropout'
:
0.0
}
if
'encoder.down.2.downsample.conv.weight'
not
in
sd
:
#Stable diffusion x4 upscaler VAE
if
'encoder.down.2.downsample.conv.weight'
not
in
sd
and
'decoder.up.3.upsample.conv.weight'
not
in
sd
:
#Stable diffusion x4 upscaler VAE
ddconfig
[
'ch_mult'
]
=
[
1
,
2
,
4
]
ddconfig
[
'ch_mult'
]
=
[
1
,
2
,
4
]
self
.
downscale_ratio
=
4
self
.
downscale_ratio
=
4
self
.
upscale_ratio
=
4
self
.
upscale_ratio
=
4
self
.
first_stage_model
=
AutoencoderKL
(
ddconfig
=
ddconfig
,
embed_dim
=
4
)
self
.
latent_channels
=
ddconfig
[
'z_channels'
]
=
sd
[
"decoder.conv_in.weight"
].
shape
[
1
]
if
'quant_conv.weight'
in
sd
:
self
.
first_stage_model
=
AutoencoderKL
(
ddconfig
=
ddconfig
,
embed_dim
=
4
)
else
:
self
.
first_stage_model
=
AutoencodingEngine
(
regularizer_config
=
{
'target'
:
"comfy.ldm.models.autoencoder.DiagonalGaussianRegularizer"
},
encoder_config
=
{
'target'
:
"comfy.ldm.modules.diffusionmodules.model.Encoder"
,
'params'
:
ddconfig
},
decoder_config
=
{
'target'
:
"comfy.ldm.modules.diffusionmodules.model.Decoder"
,
'params'
:
ddconfig
})
else
:
else
:
self
.
first_stage_model
=
AutoencoderKL
(
**
(
config
[
'params'
]))
self
.
first_stage_model
=
AutoencoderKL
(
**
(
config
[
'params'
]))
self
.
first_stage_model
=
self
.
first_stage_model
.
eval
()
self
.
first_stage_model
=
self
.
first_stage_model
.
eval
()
...
...
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