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
064d7583
"test/config/vscode:/vscode.git/clone" did not exist on "4dc9eb9385f1cb3df07f01b35c19a02963ddcfa8"
Commit
064d7583
authored
Nov 08, 2023
by
comfyanonymous
Browse files
Add a CONDConstant for passing non tensor conds to unet.
parent
794dd206
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
1 deletion
+19
-1
comfy/conds.py
comfy/conds.py
+15
-0
comfy/model_base.py
comfy/model_base.py
+4
-1
No files found.
comfy/conds.py
View file @
064d7583
...
...
@@ -62,3 +62,18 @@ class CONDCrossAttn(CONDRegular):
c
=
c
.
repeat
(
1
,
crossattn_max_len
//
c
.
shape
[
1
],
1
)
#padding with repeat doesn't change result
out
.
append
(
c
)
return
torch
.
cat
(
out
)
class
CONDConstant
(
CONDRegular
):
def
__init__
(
self
,
cond
):
self
.
cond
=
cond
def
process_cond
(
self
,
batch_size
,
device
,
**
kwargs
):
return
self
.
_copy_with
(
self
.
cond
)
def
can_concat
(
self
,
other
):
if
self
.
cond
!=
other
.
cond
:
return
False
return
True
def
concat
(
self
,
others
):
return
self
.
cond
comfy/model_base.py
View file @
064d7583
...
...
@@ -61,7 +61,10 @@ class BaseModel(torch.nn.Module):
context
=
context
.
to
(
dtype
)
extra_conds
=
{}
for
o
in
kwargs
:
extra_conds
[
o
]
=
kwargs
[
o
].
to
(
dtype
)
extra
=
kwargs
[
o
]
if
hasattr
(
extra
,
"to"
):
extra
=
extra
.
to
(
dtype
)
extra_conds
[
o
]
=
extra
model_output
=
self
.
diffusion_model
(
xc
,
t
,
context
=
context
,
control
=
control
,
transformer_options
=
transformer_options
,
**
extra_conds
).
float
()
return
self
.
model_sampling
.
calculate_denoised
(
sigma
,
model_output
,
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