-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathutils.py
More file actions
22 lines (16 loc) · 723 Bytes
/
Copy pathutils.py
File metadata and controls
22 lines (16 loc) · 723 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import torch
# Copied from ComfyUI Wanvideo Wrapper
def add_noise_to_reference_video(image, ratio=None):
sigma = torch.ones((image.shape[0],)).to(image.device, image.dtype) * ratio
image_noise = torch.randn_like(image) * sigma[:, None, None, None]
image_noise = torch.where(image==-1, torch.zeros_like(image), image_noise)
image = image + image_noise
return image
# Copied from Kijai Wanvideo Wrapper
def add_noise_at_step(
original_samples: torch.FloatTensor,
noise: torch.FloatTensor,
sigma: torch.IntTensor,
) -> torch.FloatTensor:
sigma = sigma.view(sigma.shape + (1,) * (len(noise.shape)-1))
return (1 - sigma) * original_samples + sigma * noise