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
5 changes: 4 additions & 1 deletion comfy/ldm/flux/controlnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ def forward_orig(
if img.ndim != 3 or txt.ndim != 3:
raise ValueError("Input img and txt tensors must have 3 dimensions.")

if y is None:
y = torch.zeros((img.shape[0], self.params.vec_in_dim), device=img.device, dtype=img.dtype)

# running on sequences img
img = self.img_in(img)

Expand Down Expand Up @@ -174,7 +177,7 @@ def forward_orig(
out["output"] = out_output[:self.main_model_single]
return out

def forward(self, x, timesteps, context, y, guidance=None, hint=None, **kwargs):
def forward(self, x, timesteps, context, y=None, guidance=None, hint=None, **kwargs):
patch_size = 2
if self.latent_input:
hint = comfy.ldm.common_dit.pad_to_patch_size(hint, (patch_size, patch_size))
Expand Down
6 changes: 5 additions & 1 deletion comfy/ldm/flux/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ def forward_orig(
transformer_options={},
attn_mask: Tensor = None,
) -> Tensor:

if y is None:
y = torch.zeros((img.shape[0], self.params.vec_in_dim), device=img.device, dtype=img.dtype)

patches_replace = transformer_options.get("patches_replace", {})
if img.ndim != 3 or txt.ndim != 3:
raise ValueError("Input img and txt tensors must have 3 dimensions.")
Expand Down Expand Up @@ -188,7 +192,7 @@ def block_wrap(args):
img = self.final_layer(img, vec) # (N, T, patch_size ** 2 * out_channels)
return img

def forward(self, x, timestep, context, y, guidance=None, control=None, transformer_options={}, **kwargs):
def forward(self, x, timestep, context, y=None, guidance=None, control=None, transformer_options={}, **kwargs):
bs, c, h, w = x.shape
patch_size = self.patch_size
x = comfy.ldm.common_dit.pad_to_patch_size(x, (patch_size, patch_size))
Expand Down
Loading