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
afa2399f
Commit
afa2399f
authored
Sep 22, 2023
by
comfyanonymous
Browse files
Add a way to set output block patches to modify the h and hsp.
parent
29ccf9f4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
0 deletions
+9
-0
comfy/ldm/modules/diffusionmodules/openaimodel.py
comfy/ldm/modules/diffusionmodules/openaimodel.py
+6
-0
comfy/model_patcher.py
comfy/model_patcher.py
+3
-0
No files found.
comfy/ldm/modules/diffusionmodules/openaimodel.py
View file @
afa2399f
...
...
@@ -608,6 +608,7 @@ class UNetModel(nn.Module):
"""
transformer_options
[
"original_shape"
]
=
list
(
x
.
shape
)
transformer_options
[
"current_index"
]
=
0
transformer_patches
=
transformer_options
.
get
(
"patches"
,
{})
assert
(
y
is
not
None
)
==
(
self
.
num_classes
is
not
None
...
...
@@ -644,6 +645,11 @@ class UNetModel(nn.Module):
if
ctrl
is
not
None
:
hsp
+=
ctrl
if
"output_block_patch"
in
transformer_patches
:
patch
=
transformer_patches
[
"output_block_patch"
]
for
p
in
patch
:
h
,
hsp
=
p
(
h
,
hsp
,
transformer_options
)
h
=
th
.
cat
([
h
,
hsp
],
dim
=
1
)
del
hsp
if
len
(
hs
)
>
0
:
...
...
comfy/model_patcher.py
View file @
afa2399f
...
...
@@ -88,6 +88,9 @@ class ModelPatcher:
def
set_model_attn2_output_patch
(
self
,
patch
):
self
.
set_model_patch
(
patch
,
"attn2_output_patch"
)
def
set_model_output_block_patch
(
self
,
patch
):
self
.
set_model_patch
(
patch
,
"output_block_patch"
)
def
model_patches_to
(
self
,
device
):
to
=
self
.
model_options
[
"transformer_options"
]
if
"patches"
in
to
:
...
...
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