Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions comfy/conds.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,45 @@ def concat(self, others):

def size(self):
return [1]


class CONDList(CONDRegular):
def __init__(self, cond):
self.cond = cond

def process_cond(self, batch_size, device, **kwargs):
out = []
for c in self.cond:
out.append(comfy.utils.repeat_to_batch_size(c, batch_size).to(device))

return self._copy_with(out)

def can_concat(self, other):
if len(self.cond) != len(other.cond):
return False
for i in range(len(self.cond)):
if self.cond[i].shape != other.cond[i].shape:
return False

return True

def concat(self, others):
out = []
for i in range(len(self.cond)):
o = [self.cond[i]]
for x in others:
o.append(x.cond[i])
out.append(torch.cat(o))

return out

def size(self): # hackish implementation to make the mem estimation work
o = 0
c = 1
for c in self.cond:
size = c.size()
o += math.prod(size)
if len(size) > 1:
c = size[1]

return [1, c, o // c]
5 changes: 5 additions & 0 deletions comfy/model_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,11 @@ def _apply_model(self, x, t, c_concat=None, c_crossattn=None, control=None, tran
if hasattr(extra, "dtype"):
if extra.dtype != torch.int and extra.dtype != torch.long:
extra = extra.to(dtype)
if isinstance(extra, list):
ex = []
for ext in extra:
ex.append(ext.to(dtype))
extra = ex
extra_conds[o] = extra

t = self.process_timestep(t, x=x, **extra_conds)
Expand Down
Loading