hzwer/ECCV2022-RIFE

Convert model to .pt file

Siziff opened this issue · 1 comments

Siziff commented

How do I convert a model to a .pt file?? I to add the code block in Practical-RIFE/train_log/RIFE_HDv3.py in Model.inference block the next code:

test_input = torch.rand(1, 3, 128, 128).cuda()
mod = torch.jit.trace(self.flownet, torch.cat((test_input,test_input),1))
mod.save("rife417.pt")

But get the next error:

RuntimeError: Tracer cannot infer type of ([tensor([[[[-0.0011, -0.0011, -0.0011,  ...,  0.0004,  0.0004,  0.0004],
..............................................................................................................................................................................................................................
          [0.6896, 0.9605, 0.6331,  ..., 0.8422, 0.3023, 0.3185]]]],
       device='cuda:0')])
:List inputs to traced functions must have consistent element type. Found Tuple[Tensor, Tensor] and Tensor

It wont trace because you havent modified the rife arch. I have submitted a guide here to convert to ncnn through onnx, and the same principles apply. If you need more help, don't be afraid to ask me. If the guide is not clear enough, tell me and I will edit it. The answer is to just replace x in the ifnet file, with img0,img1, and you are also going to want to export the timestep variable with torch.Tensor([0.5]).
If you just want the models:
https://github.com/TNTwise/Rife-Vulkan-Models/releases/tag/models
Guide:
https://github.com/TNTwise/REAL-Video-Enhancer/wiki/Convert-Rife-Models