mirror of
https://git.datalinker.icu/comfyanonymous/ComfyUI
synced 2026-08-24 05:11:19 +08:00
Make get_resized_cond more robust for various dim sizes
This commit is contained in:
parent
30b1b75ced
commit
e7ead85cdb
@ -132,7 +132,7 @@ class IndexListContextHandler(ContextHandlerABC):
|
|||||||
cond_item = actual_cond[key]
|
cond_item = actual_cond[key]
|
||||||
if isinstance(cond_item, torch.Tensor):
|
if isinstance(cond_item, torch.Tensor):
|
||||||
# check that tensor is the expected length - x.size(0)
|
# check that tensor is the expected length - x.size(0)
|
||||||
if cond_item.size(self.dim) == x_in.size(self.dim):
|
if cond_item.ndim < self.dim and cond_item.size(self.dim) == x_in.size(self.dim):
|
||||||
# if so, it's subsetting time - tell controls the expected indeces so they can handle them
|
# if so, it's subsetting time - tell controls the expected indeces so they can handle them
|
||||||
actual_cond_item = window.get_tensor(cond_item)
|
actual_cond_item = window.get_tensor(cond_item)
|
||||||
resized_actual_cond[key] = actual_cond_item.to(device)
|
resized_actual_cond[key] = actual_cond_item.to(device)
|
||||||
@ -146,11 +146,11 @@ class IndexListContextHandler(ContextHandlerABC):
|
|||||||
# when in dictionary, look for tensors and CONDCrossAttn [comfy/conds.py] (has cond attr that is a tensor)
|
# when in dictionary, look for tensors and CONDCrossAttn [comfy/conds.py] (has cond attr that is a tensor)
|
||||||
for cond_key, cond_value in new_cond_item.items():
|
for cond_key, cond_value in new_cond_item.items():
|
||||||
if isinstance(cond_value, torch.Tensor):
|
if isinstance(cond_value, torch.Tensor):
|
||||||
if cond_value.size(self.dim) == x_in.size(self.dim):
|
if cond_value.ndim < self.dim and cond_value.size(0) == x_in.size(self.dim):
|
||||||
new_cond_item[cond_key] = window.get_tensor(cond_value, device)
|
new_cond_item[cond_key] = window.get_tensor(cond_value, device)
|
||||||
# if has cond that is a Tensor, check if needs to be subset
|
# if has cond that is a Tensor, check if needs to be subset
|
||||||
elif hasattr(cond_value, "cond") and isinstance(cond_value.cond, torch.Tensor):
|
elif hasattr(cond_value, "cond") and isinstance(cond_value.cond, torch.Tensor):
|
||||||
if cond_value.cond.size(self.dim) == x_in.size(self.dim):
|
if cond_value.cond < self.dim and cond_value.cond.size(0) == x_in.size(self.dim):
|
||||||
new_cond_item[cond_key] = cond_value._copy_with(window.get_tensor(cond_value.cond, device))
|
new_cond_item[cond_key] = cond_value._copy_with(window.get_tensor(cond_value.cond, device))
|
||||||
elif cond_key == "num_video_frames": # for SVD
|
elif cond_key == "num_video_frames": # for SVD
|
||||||
new_cond_item[cond_key] = cond_value._copy_with(cond_value.cond)
|
new_cond_item[cond_key] = cond_value._copy_with(cond_value.cond)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user