The most powerful and modular diffusion model GUI, api and backend with a graph/nodes interface. The fastest local inference engine in the world.
Fix issues with new hunyuan img2vid model and bumb version to v0.3.26
comfyanonymous9aac21f894a1
diff --git a/comfy/ldm/flux/layers.py b/comfy/ldm/flux/layers.pyindex 1b3e9f313..76af967e6 100644--- a/comfy/ldm/flux/layers.py+++ b/comfy/ldm/flux/layers.py@@ -159,20 +159,20 @@ class DoubleStreamBlock(nn.Module):)self.flipped_img_txt = flipped_img_txt- def forward(self, img: Tensor, txt: Tensor, vec: Tensor, pe: Tensor, attn_mask=None, modulation_dims=None):+ def forward(self, img: Tensor, txt: Tensor, vec: Tensor, pe: Tensor, attn_mask=None, modulation_dims_img=None, modulation_dims_txt=None):img_mod1, img_mod2 = self.img_mod(vec)txt_mod1, txt_mod2 = self.txt_mod(vec)# prepare image for attentionimg_modulated = self.img_norm1(img)- img_modulated = apply_mod(img_modulated, (1 + img_mod1.scale), img_mod1.shift, modulation_dims)+ img_modulated = apply_mod(img_modulated, (1 + img_mod1.scale), img_mod1.shift, modulation_dims_img)img_qkv = self.img_attn.qkv(img_modulated)img_q, img_k, img_v = img_qkv.view(img_qkv.shape[0], img_qkv.shape[1], 3, self.num_heads, -1).permute(2, 0, 3, 1, 4)img_q, img_k = self.img_attn.norm(img_q, img_k, img_v)# prepare txt for attentiontxt_modulated = self.txt_norm1(txt)- txt_modulated = apply_mod(txt_modulated, (1 + txt_mod1.scale), txt_mod1.shift, modulation_dims)+ txt_modulated = apply_mod(txt_modulated, (1 + txt_mod1.scale), txt_mod1.shift, modulation_dims_txt)txt_qkv = self.txt_attn.qkv(txt_modulated)txt_q, txt_k, txt_v = txt_qkv.view(txt_qkv.shape[0], txt_qkv.shape[1], 3, self.num_heads, -1).permute(2, 0, 3, 1, 4)txt_q, txt_k = self.txt_attn.norm(txt_q, txt_k, txt_v)@@ -195,12 +195,12 @@ class DoubleStreamBlock(nn.Module):txt_attn, img_attn = attn[:, : txt.shape[1]], attn[:, txt.shape[1]:]# calculate the img bloks- img = img + apply_mod(self.img_attn.proj(img_attn), img_mod1.gate, None, modulation_dims)- img = img + apply_mod(self.img_mlp(apply_mod(self.img_norm2(img), (1 + img_mod2.scale), img_mod2.shift, modulation_dims)), img_mod2.gate, None, modulation_dims)+ img = img + apply_mod(self.img_attn.proj(img_attn), img_mod1.gate, None, modulation_dims_img)+ img = img + apply_mod(self.img_mlp(apply_mod(self.img_norm2(img), (1 + img_mod2.scale), img_mod2.shift, modulation_dims_img)), img_mod2.gate, None, modulation_dims_img)# calculate the txt bloks- txt += apply_mod(self.txt_attn.proj(txt_attn), txt_mod1.gate, None, modulation_dims)- txt += apply_mod(self.txt_mlp(apply_mod(self.txt_norm2(txt), (1 + txt_mod2.scale), txt_mod2.shift, modulation_dims)), txt_mod2.gate, None, modulation_dims)+ txt += apply_mod(self.txt_attn.proj(txt_attn), txt_mod1.gate, None, modulation_dims_txt)+ txt += apply_mod(self.txt_mlp(apply_mod(self.txt_norm2(txt), (1 + txt_mod2.scale), txt_mod2.shift, modulation_dims_txt)), txt_mod2.gate, None, modulation_dims_txt)if txt.dtype == torch.float16:txt = torch.nan_to_num(txt, nan=0.0, posinf=65504, neginf=-65504)diff --git a/comfy/ldm/hunyuan_video/model.py b/comfy/ldm/hunyuan_video/model.pyindex 001e302b5..72af3d5bb 100644--- a/comfy/ldm/hunyuan_video/model.py+++ b/comfy/ldm/hunyuan_video/model.py@@ -244,9 +244,11 @@ class HunyuanVideo(nn.Module):vec = torch.cat([(vec_ + token_replace_vec).unsqueeze(1), (vec_ + vec).unsqueeze(1)], dim=1)frame_tokens = (initial_shape[-1] // self.patch_size[-1]) * (initial_shape[-2] // self.patch_size[-2])modulation_dims = [(0, frame_tokens, 0), (frame_tokens, None, 1)]+ modulation_dims_txt = [(0, None, 1)]else:vec = vec + self.vector_in(y[:, :self.params.vec_in_dim])modulation_dims = None+ modulation_dims_txt = Noneif self.params.guidance_embed:if guidance is not None:@@ -273,14 +275,14 @@ class HunyuanVideo(nn.Module):if ("double_block", i) in blocks_replace:def block_wrap(args):out = {}- out["img"], out["txt"] = block(img=args["img"], txt=args["txt"], vec=args["vec"], pe=args["pe"], attn_mask=args["attention_mask"])+ out["img"], out["txt"] = block(img=args["img"], txt=args["txt"], vec=args["vec"], pe=args["pe"], attn_mask=args["attention_mask"], modulation_dims_img=args["modulation_dims_img"], modulation_dims_txt=args["modulation_dims_txt"])return out- out = blocks_replace[("double_block", i)]({"img": img, "txt": txt, "vec": vec, "pe": pe, "attention_mask": attn_mask}, {"original_block": block_wrap})+ out = blocks_replace[("double_block", i)]({"img": img, "txt": txt, "vec": vec, "pe": pe, "attention_mask": attn_mask, 'modulation_dims_img': modulation_dims, 'modulation_dims_txt': modulation_dims_txt}, {"original_block": block_wrap})txt = out["txt"]img = out["img"]else:- img, txt = block(img=img, txt=txt, vec=vec, pe=pe, attn_mask=attn_mask, modulation_dims=modulation_dims)+ img, txt = block(img=img, txt=txt, vec=vec, pe=pe, attn_mask=attn_mask, modulation_dims_img=modulation_dims, modulation_dims_txt=modulation_dims_txt)if control is not None: # Controlnetcontrol_i = control.get("input")@@ -295,10 +297,10 @@ class HunyuanVideo(nn.Module):if ("single_block", i) in blocks_replace:def block_wrap(args):out = {}- out["img"] = block(args["img"], vec=args["vec"], pe=args["pe"], attn_mask=args["attention_mask"])+ out["img"] = block(args["img"], vec=args["vec"], pe=args["pe"], attn_mask=args["attention_mask"], modulation_dims=args["modulation_dims"])return out- out = blocks_replace[("single_block", i)]({"img": img, "vec": vec, "pe": pe, "attention_mask": attn_mask}, {"original_block": block_wrap})+ out = blocks_replace[("single_block", i)]({"img": img, "vec": vec, "pe": pe, "attention_mask": attn_mask, 'modulation_dims': modulation_dims}, {"original_block": block_wrap})img = out["img"]else:img = block(img, vec=vec, pe=pe, attn_mask=attn_mask, modulation_dims=modulation_dims)diff --git a/comfyui_version.py b/comfyui_version.pyindex 9cf4c13fa..b5e6fbead 100644--- a/comfyui_version.py+++ b/comfyui_version.py@@ -1,3 +1,3 @@# This file is automatically generated by the build process when version is# updated in pyproject.toml.-__version__ = "0.3.25"+__version__ = "0.3.26"diff --git a/pyproject.toml b/pyproject.tomlindex 3b53d1492..f13fed8dc 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -1,6 +1,6 @@[project]name = "ComfyUI"-version = "0.3.25"+version = "0.3.26"readme = "README.md"license = { file = "LICENSE" }requires-python = ">=3.9"