mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-05-09 00:32:31 +08:00
wan: encode frames 2x2.
Reduce VRAM usage greatly by encoding frames 2 at a time rather than 4.
This commit is contained in:
parent
0ebd807eb9
commit
6c4843567d
@ -458,11 +458,12 @@ class WanVAE(nn.Module):
|
|||||||
conv_idx = [0]
|
conv_idx = [0]
|
||||||
## cache
|
## cache
|
||||||
t = x.shape[2]
|
t = x.shape[2]
|
||||||
iter_ = 1 + (t - 1) // 4
|
t = 1 + ((t - 1) // 4) * 4
|
||||||
|
iter_ = 1 + (t - 1) // 2
|
||||||
feat_map = None
|
feat_map = None
|
||||||
if iter_ > 1:
|
if iter_ > 1:
|
||||||
feat_map = [None] * count_cache_layers(self.encoder)
|
feat_map = [None] * count_cache_layers(self.encoder)
|
||||||
## 对encode输入的x,按时间拆分为1、4、4、4....
|
## 对encode输入的x,按时间拆分为1、2、2、2....(总帧数先按4N+1向下取整)
|
||||||
for i in range(iter_):
|
for i in range(iter_):
|
||||||
conv_idx = [0]
|
conv_idx = [0]
|
||||||
if i == 0:
|
if i == 0:
|
||||||
@ -472,7 +473,7 @@ class WanVAE(nn.Module):
|
|||||||
feat_idx=conv_idx)
|
feat_idx=conv_idx)
|
||||||
else:
|
else:
|
||||||
out_ = self.encoder(
|
out_ = self.encoder(
|
||||||
x[:, :, 1 + 4 * (i - 1):1 + 4 * i, :, :],
|
x[:, :, 1 + 2 * (i - 1):1 + 2 * i, :, :],
|
||||||
feat_cache=feat_map,
|
feat_cache=feat_map,
|
||||||
feat_idx=conv_idx,
|
feat_idx=conv_idx,
|
||||||
final=(i == (iter_ - 1)))
|
final=(i == (iter_ - 1)))
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user