styler00dollar / VapourSynth-RIFE-ncnn-Vulkan

RIFE filter for VapourSynth
MIT License
97 stars 22 forks source link

Convert model process #26

Closed Siziff closed 7 months ago

Siziff commented 7 months ago

HI, can smb please explain how to convert the new Rife model from hzwer/Practical-RIFLE to ncnn format? I've tried to use:

  1. torch.jit.trace() and then convert .pt file through pnnx to ncnn
  2. torch.onnx._export() and then onnx2ncnn from ncnn git

BUT NONE OF THEM WORKS. The models I received do not run in the Vulkan app on my phone. but I run models from this project that @styler00dollar converted. Can someone explain how to convert models correctly?

TNTwise commented 7 months ago

https://github.com/TNTwise/REAL-Video-Enhancer/wiki/Convert-Rife-Models

styler00dollar commented 7 months ago

I wrote a guide here. It is more complicated than just using torch.onnx.

Siziff commented 7 months ago

@styler00dollar @TNTwise I follow all the instructions, but I get an error. How did you fix this error? I get this error in both solutions.

TypeError: upsample_bilinear2d() received an invalid combination of arguments - got (Tensor, NoneType, bool, list), but expected one of:
 * (Tensor input, tuple of ints output_size, bool align_corners, tuple of floats scale_factors)
      didn't match because some of the arguments have invalid types: (Tensor, NoneType, bool, list)
 * (Tensor input, tuple of ints output_size, bool align_corners, float scales_h, float scales_w, *, Tensor out)
TNTwise commented 7 months ago

Did you replace x with im0,img1

Siziff commented 7 months ago

Yes, everything is as in the instructions @TNTwise image

TNTwise commented 7 months ago

Are you using that specific torch version? It needs the one from the instructions to work with onnx export.

TNTwise commented 7 months ago

You can also use my script here on rife-v4.14 and compare to how you are exporting. You may need to download config.txt as well. https://github.com/TNTwise/ConvertRIFEtoNCNN-githubactions/blob/main/modify_train_log.py

Siziff commented 7 months ago

@TNTwise thanks a lot for the script, I get the once file, but when I try to convert it to ncnn I get an error Cast not supported yet! # to=1. If I use a sim, the model is converted to ncnn with no errors, BUT when I add these models to the rife-ncnn-vulkan project and try to launch it, I get a black picture. What could be the problem?
It's worth noting that when I run models from here, everything works correctly..

TNTwise commented 7 months ago

You need to run it through onnxsim to remove cast. You can also try pnnx conversion to see if that works. Make sure you compile rife ncnn vulkan with memorydata and convolutiondepthwise. Also check that the naming of your folder is right, it has to be rife-v4-something.