Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

请问如果用于多个视频的拼接,需要怎么改造? #291

Closed
qijiaojiao opened this issue Nov 23, 2022 · 4 comments
Closed

请问如果用于多个视频的拼接,需要怎么改造? #291

qijiaojiao opened this issue Nov 23, 2022 · 4 comments

Comments

@qijiaojiao
Copy link

论文的扩展里有提到这个应用,请问代码上怎么改造呢

@hzwer
Copy link
Owner

hzwer commented Nov 23, 2022

在 model/IFNet_m.py 里面把 timestep 改写一下

timestep = (x[:, :1].clone() * 0 + 1) 
n, c, h, w = x.shape
_, XXs = np.mgrid[:h, :w]
XXs = torch.from_numpy(XXs[:,:,np.newaxis]).permute(2, 0, 1).float()[None].to(device)
timestep = XXs * timestep / XXs.max()

这样应该就创建了一个渐变的 temporal encoding

@qijiaojiao
Copy link
Author

在 model/IFNet_m.py 里面把 timestep 改写一下

timestep = (x[:, :1].clone() * 0 + 1) 
n, c, h, w = x.shape
_, XXs = np.mgrid[:h, :w]
XXs = torch.from_numpy(XXs[:,:,np.newaxis]).permute(2, 0, 1).float()[None].to(device)
timestep = XXs * timestep / XXs.max()

这样应该就创建了一个渐变的 temporal encoding

您好,我用rife_m,修改了ifnet_m中如上您给的代码,然后参照论文Fig8做的图片I0 I1(基于demo里的两张图片进行了左右侧裁剪),出来的中间帧图片是一片混乱的像素,可以帮忙看下什么问题吗?
rife_m推理如下:
img_list = [img0]
p = 2 ** args.exp
for i in range(p-1):
t = (i+1)*(1./p)
print(t)
img_list.append(model.inference(img0, img1, timestep=t))
img_list.append(img1)

@hzwer
Copy link
Owner

hzwer commented Nov 28, 2022

我试了一下,用目前的 RIFEm 模型,对这两张图片做插帧会出一片蓝色,具体原因可能是模型无法适应镜头移动,我猜测训练的时候如果加一些镜头移动的增广能修复,很抱歉我之前没有注意到

改用 practical RIFE 里的模型,用 v4.6 模型 https://github.com/hzwer/Practical-RIFE#usage ,可以得到正常的结果

输入(左右各裁剪 32 pixel):
img0
img2

输出:
img1

我的 timestep 生成方式:

n, c, h, w = x.shape
XXs, YYs = np.mgrid[:h, :w]
XXs = torch.from_numpy(XXs[np.newaxis, np.newaxis, :,:]).float().to(device)
YYs = torch.from_numpy(YYs[np.newaxis, np.newaxis, :,:]).float().to(device)
timestep = YYs / YYs.max()

@qijiaojiao
Copy link
Author

谢谢了!

@hzwer hzwer closed this as completed Dec 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants