You've already forked ComfyUI-WanVideoWrapper
mirror of
https://github.com/kijai/ComfyUI-WanVideoWrapper.git
synced 2026-01-26 23:41:35 +03:00
commit 73dd1a06d33953912f5dd684f168028b14e42a36 Author: kijai <40791699+kijai@users.noreply.github.com> Date: Mon Oct 13 19:47:38 2025 +0300 cleanup commit 39bc2cecf493e2eb176b55e8841d933f0da1ec39 Author: kijai <40791699+kijai@users.noreply.github.com> Date: Mon Oct 13 19:24:20 2025 +0300 Allow scheduling ovi cfg commit 2c153c5f324dbd59670ad9c51a7995459504a3cd Merge: dba766732eb6b4Author: kijai <40791699+kijai@users.noreply.github.com> Date: Mon Oct 13 17:48:20 2025 +0300 Merge branch 'main' into ovi commit dba76674c71af7bf94c82834a0b0e40d94043c99 Merge: 0f11a435a0456eAuthor: kijai <40791699+kijai@users.noreply.github.com> Date: Sun Oct 12 22:45:43 2025 +0300 Merge branch 'main' into ovi commit 0f11a439622799ad8070f8a2b8cc8e6a041b761d Merge: 0999f50e2d8c9bAuthor: kijai <40791699+kijai@users.noreply.github.com> Date: Sat Oct 11 07:48:06 2025 +0300 Merge branch 'main' into ovi commit 0999f50cfe025290cd7ce88a8dd1acff0b38d9bd Merge: d45df1ff1d1c83Author: kijai <40791699+kijai@users.noreply.github.com> Date: Fri Oct 10 22:16:09 2025 +0300 Merge branch 'main' into ovi commit d45df1fb5b7c629b15eabc197357d62bdc232aaf Author: kijai <40791699+kijai@users.noreply.github.com> Date: Thu Oct 9 20:21:37 2025 +0300 Remove dependency for librosa commit d8e7533fdf7eab1d2489c3e025a908c02d997444 Author: kijai <40791699+kijai@users.noreply.github.com> Date: Thu Oct 9 19:57:28 2025 +0300 Remove omegaconf dependency commit f4e27ff018e98cb5b09655dceda399baea36b240 Author: kijai <40791699+kijai@users.noreply.github.com> Date: Thu Oct 9 19:31:06 2025 +0300 Fix VACE commit 35d3df39294831e5e7568b6f7e16d2ecf2d790a0 Author: kijai <40791699+kijai@users.noreply.github.com> Date: Thu Oct 9 00:26:40 2025 +0300 small update commit 96f8ea1d26869ab7e49e12a07f19d5d5a2023253 Author: kijai <40791699+kijai@users.noreply.github.com> Date: Wed Oct 8 22:32:57 2025 +0300 Create wanvideo_2_2_5B_ovi_testing.json commit a2511be73b9da7019fd21aeb0b521af941c09150 Author: kijai <40791699+kijai@users.noreply.github.com> Date: Wed Oct 8 22:32:54 2025 +0300 Update nodes_sampler.py commit d3688b8db71452ea1f7c9a2bc0216441d524e56c Author: kijai <40791699+kijai@users.noreply.github.com> Date: Wed Oct 8 21:43:02 2025 +0300 Allow EasyCache to work with ovi commit 586d9148a0306ef5d30e9a971a9c3be4cd3ecc97 Author: kijai <40791699+kijai@users.noreply.github.com> Date: Wed Oct 8 19:09:06 2025 +0300 Update model.py commit 61eedd2839decdb7d4c2ddd5f1310fdaf49d36ad Author: kijai <40791699+kijai@users.noreply.github.com> Date: Wed Oct 8 19:09:02 2025 +0300 I2V fix commit a97fcb1b9ae9fb7bbfdf668c24816e014a1b58d1 Author: kijai <40791699+kijai@users.noreply.github.com> Date: Wed Oct 8 17:57:28 2025 +0300 Add nodes to set audio latent size commit d41e42a697f3d561dabbc22566f633b5f1bbd952 Author: kijai <40791699+kijai@users.noreply.github.com> Date: Wed Oct 8 16:42:04 2025 +0300 Support loading mmaudio vae from .safetensors commit 1b0e28ec41e3c97fe1f2f057fef9b9bbcb87bca7 Author: kijai <40791699+kijai@users.noreply.github.com> Date: Wed Oct 8 16:19:53 2025 +0300 Update nodes_sampler.py commit fbd18f45fe85ede8edcb5aebaea7ceb5b6eab5a2 Author: kijai <40791699+kijai@users.noreply.github.com> Date: Wed Oct 8 10:16:44 2025 +0300 Fixes for other workflows commit b06993b637198f7fad92208f3b3dc9a7d7f57c7f Author: kijai <40791699+kijai@users.noreply.github.com> Date: Wed Oct 8 09:46:27 2025 +0300 initial commit T2V works
118 lines
3.3 KiB
Python
118 lines
3.3 KiB
Python
import torch
|
|
import torch.nn as nn
|
|
import torch.nn.functional as F
|
|
from einops import rearrange
|
|
|
|
from .edm2_utils import (MPConv1D, mp_silu, mp_sum, normalize)
|
|
|
|
|
|
def nonlinearity(x):
|
|
# swish
|
|
return mp_silu(x)
|
|
|
|
|
|
class ResnetBlock1D(nn.Module):
|
|
|
|
def __init__(self, *, in_dim, out_dim=None, conv_shortcut=False, kernel_size=3, use_norm=True):
|
|
super().__init__()
|
|
self.in_dim = in_dim
|
|
out_dim = in_dim if out_dim is None else out_dim
|
|
self.out_dim = out_dim
|
|
self.use_conv_shortcut = conv_shortcut
|
|
self.use_norm = use_norm
|
|
|
|
self.conv1 = MPConv1D(in_dim, out_dim, kernel_size=kernel_size)
|
|
self.conv2 = MPConv1D(out_dim, out_dim, kernel_size=kernel_size)
|
|
if self.in_dim != self.out_dim:
|
|
if self.use_conv_shortcut:
|
|
self.conv_shortcut = MPConv1D(in_dim, out_dim, kernel_size=kernel_size)
|
|
else:
|
|
self.nin_shortcut = MPConv1D(in_dim, out_dim, kernel_size=1)
|
|
|
|
def forward(self, x: torch.Tensor) -> torch.Tensor:
|
|
|
|
# pixel norm
|
|
if self.use_norm:
|
|
x = normalize(x, dim=1)
|
|
|
|
h = x
|
|
h = nonlinearity(h)
|
|
h = self.conv1(h)
|
|
|
|
h = nonlinearity(h)
|
|
h = self.conv2(h)
|
|
|
|
if self.in_dim != self.out_dim:
|
|
if self.use_conv_shortcut:
|
|
x = self.conv_shortcut(x)
|
|
else:
|
|
x = self.nin_shortcut(x)
|
|
|
|
return mp_sum(x, h, t=0.3)
|
|
|
|
|
|
class AttnBlock1D(nn.Module):
|
|
|
|
def __init__(self, in_channels, num_heads=1):
|
|
super().__init__()
|
|
self.in_channels = in_channels
|
|
|
|
self.num_heads = num_heads
|
|
self.qkv = MPConv1D(in_channels, in_channels * 3, kernel_size=1)
|
|
self.proj_out = MPConv1D(in_channels, in_channels, kernel_size=1)
|
|
|
|
def forward(self, x):
|
|
h = x
|
|
y = self.qkv(h)
|
|
y = y.reshape(y.shape[0], self.num_heads, -1, 3, y.shape[-1])
|
|
q, k, v = normalize(y, dim=2).unbind(3)
|
|
|
|
q = rearrange(q, 'b h c l -> b h l c')
|
|
k = rearrange(k, 'b h c l -> b h l c')
|
|
v = rearrange(v, 'b h c l -> b h l c')
|
|
|
|
h = F.scaled_dot_product_attention(q, k, v)
|
|
h = rearrange(h, 'b h l c -> b (h c) l')
|
|
|
|
h = self.proj_out(h)
|
|
|
|
return mp_sum(x, h, t=0.3)
|
|
|
|
|
|
class Upsample1D(nn.Module):
|
|
|
|
def __init__(self, in_channels, with_conv):
|
|
super().__init__()
|
|
self.with_conv = with_conv
|
|
if self.with_conv:
|
|
self.conv = MPConv1D(in_channels, in_channels, kernel_size=3)
|
|
|
|
def forward(self, x):
|
|
x = F.interpolate(x, scale_factor=2.0, mode='nearest-exact') # support 3D tensor(B,C,T)
|
|
if self.with_conv:
|
|
x = self.conv(x)
|
|
return x
|
|
|
|
|
|
class Downsample1D(nn.Module):
|
|
|
|
def __init__(self, in_channels, with_conv):
|
|
super().__init__()
|
|
self.with_conv = with_conv
|
|
if self.with_conv:
|
|
# no asymmetric padding in torch conv, must do it ourselves
|
|
self.conv1 = MPConv1D(in_channels, in_channels, kernel_size=1)
|
|
self.conv2 = MPConv1D(in_channels, in_channels, kernel_size=1)
|
|
|
|
def forward(self, x):
|
|
|
|
if self.with_conv:
|
|
x = self.conv1(x)
|
|
|
|
x = F.avg_pool1d(x, kernel_size=2, stride=2)
|
|
|
|
if self.with_conv:
|
|
x = self.conv2(x)
|
|
|
|
return x
|