xinntao / Real-ESRGAN-ncnn-vulkan

NCNN implementation of Real-ESRGAN. Real-ESRGAN aims at developing Practical Algorithms for General Image Restoration.
https://github.com/xinntao/Real-ESRGAN
Other
1.42k stars 170 forks source link

how to convert python model (pth) to ncnn (bin & param) model #59

Open EKI-INDRADI opened 7 months ago

EKI-INDRADI commented 7 months ago

example model: https://github.com/xinntao/Real-ESRGAN/blob/master/docs/model_zoo.md

zjx424 commented 6 months ago

https://github.com/upscayl/upscayl/wiki/%F0%9F%96%A5%EF%B8%8F-Model-Conversion%E2%80%89%E2%80%93%E2%80%89Get-more-models!

i use chainner to convert pytorch .pth model to ncnn model

Ohrwerk commented 2 months ago

Thanks for the HowTo with Chainer but no chainner version is running, i think my system is to old.

NeedsMoar commented 2 months ago

I tried the above a while ago and chainner was producing corrupted ncnn output that neither the newer version of torch the system python had installed, or the old ncnn executables, or anything else could open. Chainner ends up being a gigantic install that you don't need if you have torch installed literally anywhere else, I have scripts written for the rare upscaling I need already, and I have way too many python installs thanks to every open and closed source program on the planet installing its own full python copy.

I've always used this: https://drive.google.com/file/d/1ibGyGgUP1oCpJ73y_3z471m50Qa6A2GB/view You really just need the tools subdirectory and pth2ncnn.exe... extract those somewhere then run pth2ncnn on the .pth file. It can't convert some newer types of models but AFAICT it works on everything this version of realesrgan can use. If it work's you'll get a subdirectory named after the model with the bin and params

Ohrwerk commented 2 months ago

Hello NeedsMoar, thank you very much for sharing your tool and experiences. Yes, it is similar with ffmpeg, although I cleaned it out some time ago, so I already have 10 times ffmpeg.exe on my disc again. But unfortunately... yes I know, my system is completely outdated. "ONNX Runtime supports Windows 10 and above, only"

I just can't cope with Linux, my system doesn't support 11, 10 would work as a snail but that doesn't make sense any more and I just don't like it for reasons. A new computer is a big investment, especially if you also want to switch to CUDA, and it doesn't match my philosophy either. I could write novels here about why things are the way they are, but let's leave it at that. I also don't have anyone who would come round for dinner to help with problems.