mirror of
https://git.datalinker.icu/comfyanonymous/ComfyUI
synced 2026-08-16 01:36:41 +08:00
Revert "Wan2.2 fun control ref image."
This reverts commit c2981b397b3a36e6ea16cffc7dbf828be8399120.
This commit is contained in:
parent
c2981b397b
commit
91b9a6fb34
@ -391,7 +391,6 @@ class WanModel(torch.nn.Module):
|
|||||||
cross_attn_norm=True,
|
cross_attn_norm=True,
|
||||||
eps=1e-6,
|
eps=1e-6,
|
||||||
flf_pos_embed_token_number=None,
|
flf_pos_embed_token_number=None,
|
||||||
in_dim_ref_conv=None,
|
|
||||||
image_model=None,
|
image_model=None,
|
||||||
device=None,
|
device=None,
|
||||||
dtype=None,
|
dtype=None,
|
||||||
@ -485,11 +484,6 @@ class WanModel(torch.nn.Module):
|
|||||||
else:
|
else:
|
||||||
self.img_emb = None
|
self.img_emb = None
|
||||||
|
|
||||||
if in_dim_ref_conv is not None:
|
|
||||||
self.ref_conv = operations.Conv2d(in_dim_ref_conv, dim, kernel_size=patch_size[1:], stride=patch_size[1:], device=operation_settings.get("device"), dtype=operation_settings.get("dtype"))
|
|
||||||
else:
|
|
||||||
self.ref_conv = None
|
|
||||||
|
|
||||||
def forward_orig(
|
def forward_orig(
|
||||||
self,
|
self,
|
||||||
x,
|
x,
|
||||||
@ -532,13 +526,6 @@ class WanModel(torch.nn.Module):
|
|||||||
e = e.reshape(t.shape[0], -1, e.shape[-1])
|
e = e.reshape(t.shape[0], -1, e.shape[-1])
|
||||||
e0 = self.time_projection(e).unflatten(2, (6, self.dim))
|
e0 = self.time_projection(e).unflatten(2, (6, self.dim))
|
||||||
|
|
||||||
full_ref = None
|
|
||||||
if self.ref_conv is not None:
|
|
||||||
full_ref = kwargs.get("reference_latent", None)
|
|
||||||
if full_ref is not None:
|
|
||||||
full_ref = self.ref_conv(full_ref).flatten(2).transpose(1, 2)
|
|
||||||
x = torch.concat((full_ref, x), dim=1)
|
|
||||||
|
|
||||||
# context
|
# context
|
||||||
context = self.text_embedding(context)
|
context = self.text_embedding(context)
|
||||||
|
|
||||||
@ -565,9 +552,6 @@ class WanModel(torch.nn.Module):
|
|||||||
# head
|
# head
|
||||||
x = self.head(x, e)
|
x = self.head(x, e)
|
||||||
|
|
||||||
if full_ref is not None:
|
|
||||||
x = x[:, full_ref.shape[1]:]
|
|
||||||
|
|
||||||
# unpatchify
|
# unpatchify
|
||||||
x = self.unpatchify(x, grid_sizes)
|
x = self.unpatchify(x, grid_sizes)
|
||||||
return x
|
return x
|
||||||
@ -586,9 +570,6 @@ class WanModel(torch.nn.Module):
|
|||||||
x = torch.cat([x, time_dim_concat], dim=2)
|
x = torch.cat([x, time_dim_concat], dim=2)
|
||||||
t_len = ((x.shape[2] + (patch_size[0] // 2)) // patch_size[0])
|
t_len = ((x.shape[2] + (patch_size[0] // 2)) // patch_size[0])
|
||||||
|
|
||||||
if self.ref_conv is not None and "reference_latent" in kwargs:
|
|
||||||
t_len += 1
|
|
||||||
|
|
||||||
img_ids = torch.zeros((t_len, h_len, w_len, 3), device=x.device, dtype=x.dtype)
|
img_ids = torch.zeros((t_len, h_len, w_len, 3), device=x.device, dtype=x.dtype)
|
||||||
img_ids[:, :, :, 0] = img_ids[:, :, :, 0] + torch.linspace(0, t_len - 1, steps=t_len, device=x.device, dtype=x.dtype).reshape(-1, 1, 1)
|
img_ids[:, :, :, 0] = img_ids[:, :, :, 0] + torch.linspace(0, t_len - 1, steps=t_len, device=x.device, dtype=x.dtype).reshape(-1, 1, 1)
|
||||||
img_ids[:, :, :, 1] = img_ids[:, :, :, 1] + torch.linspace(0, h_len - 1, steps=h_len, device=x.device, dtype=x.dtype).reshape(1, -1, 1)
|
img_ids[:, :, :, 1] = img_ids[:, :, :, 1] + torch.linspace(0, h_len - 1, steps=h_len, device=x.device, dtype=x.dtype).reshape(1, -1, 1)
|
||||||
|
|||||||
@ -1140,10 +1140,6 @@ class WAN21(BaseModel):
|
|||||||
if time_dim_concat is not None:
|
if time_dim_concat is not None:
|
||||||
out['time_dim_concat'] = comfy.conds.CONDRegular(self.process_latent_in(time_dim_concat))
|
out['time_dim_concat'] = comfy.conds.CONDRegular(self.process_latent_in(time_dim_concat))
|
||||||
|
|
||||||
reference_latents = kwargs.get("reference_latents", None)
|
|
||||||
if reference_latents is not None:
|
|
||||||
out['reference_latent'] = comfy.conds.CONDRegular(self.process_latent_in(reference_latents[-1])[:, :, 0])
|
|
||||||
|
|
||||||
return out
|
return out
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -373,11 +373,6 @@ def detect_unet_config(state_dict, key_prefix, metadata=None):
|
|||||||
flf_weight = state_dict.get('{}img_emb.emb_pos'.format(key_prefix))
|
flf_weight = state_dict.get('{}img_emb.emb_pos'.format(key_prefix))
|
||||||
if flf_weight is not None:
|
if flf_weight is not None:
|
||||||
dit_config["flf_pos_embed_token_number"] = flf_weight.shape[1]
|
dit_config["flf_pos_embed_token_number"] = flf_weight.shape[1]
|
||||||
|
|
||||||
ref_conv_weight = state_dict.get('{}ref_conv.weight'.format(key_prefix))
|
|
||||||
if ref_conv_weight is not None:
|
|
||||||
dit_config["in_dim_ref_conv"] = ref_conv_weight.shape[1]
|
|
||||||
|
|
||||||
return dit_config
|
return dit_config
|
||||||
|
|
||||||
if '{}latent_in.weight'.format(key_prefix) in state_dict_keys: # Hunyuan 3D
|
if '{}latent_in.weight'.format(key_prefix) in state_dict_keys: # Hunyuan 3D
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user