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
c70f0ac6
"web/git@developer.sourcefind.cn:chenpangpang/ComfyUI.git" did not exist on "f12ec55983fb13b3bcad33b05ff8043b22b36181"
Commit
c70f0ac6
authored
Mar 08, 2023
by
comfyanonymous
Browse files
SD2.x controlnets now work.
parent
5ea59771
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
15 deletions
+33
-15
comfy/sd.py
comfy/sd.py
+33
-15
No files found.
comfy/sd.py
View file @
c70f0ac6
...
...
@@ -489,21 +489,39 @@ def load_controlnet(ckpt_path, model=None):
if
model_management
.
should_use_fp16
()
and
controlnet_data
[
key
].
dtype
==
torch
.
float16
:
use_fp16
=
True
control_model
=
cldm
.
ControlNet
(
image_size
=
32
,
in_channels
=
4
,
hint_channels
=
3
,
model_channels
=
320
,
attention_resolutions
=
[
4
,
2
,
1
],
num_res_blocks
=
2
,
channel_mult
=
[
1
,
2
,
4
,
4
],
num_heads
=
8
,
use_spatial_transformer
=
True
,
transformer_depth
=
1
,
context_dim
=
context_dim
,
use_checkpoint
=
True
,
legacy
=
False
,
use_fp16
=
use_fp16
)
if
context_dim
==
768
:
#SD1.x
control_model
=
cldm
.
ControlNet
(
image_size
=
32
,
in_channels
=
4
,
hint_channels
=
3
,
model_channels
=
320
,
attention_resolutions
=
[
4
,
2
,
1
],
num_res_blocks
=
2
,
channel_mult
=
[
1
,
2
,
4
,
4
],
num_heads
=
8
,
use_spatial_transformer
=
True
,
transformer_depth
=
1
,
context_dim
=
context_dim
,
use_checkpoint
=
True
,
legacy
=
False
,
use_fp16
=
use_fp16
)
else
:
#SD2.x
control_model
=
cldm
.
ControlNet
(
image_size
=
32
,
in_channels
=
4
,
hint_channels
=
3
,
model_channels
=
320
,
attention_resolutions
=
[
4
,
2
,
1
],
num_res_blocks
=
2
,
channel_mult
=
[
1
,
2
,
4
,
4
],
num_head_channels
=
64
,
use_spatial_transformer
=
True
,
use_linear_in_transformer
=
True
,
transformer_depth
=
1
,
context_dim
=
context_dim
,
use_checkpoint
=
True
,
legacy
=
False
,
use_fp16
=
use_fp16
)
if
pth
:
if
'difference'
in
controlnet_data
:
if
model
is
not
None
:
...
...
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