tumuyan / RealSR-NCNN-Android

An Android application for super-resolution & interpolation. Contains RealSR-NCNN, SRMD-NCNN, RealCUGAN-NCNN, Real-ESRGAN-NCNN, Waifu2x-NCNN, Anime4kcpp, nearest, bilinear, bicubic, AVIR...
Other
1.13k stars 90 forks source link

KeyError: 'model.0.weight' #35

Closed Eliya-Shalom closed 1 year ago

Eliya-Shalom commented 1 year ago

I'm trying to convert RealESRNet_x4plus.pth to 'ncnn' using the 'pth2ncnn' tool, but It fails will KeyError: 'model.0.weight'.

Windows machine, Powershell

Here is the full log:

PS E:\Downloads\Cupscale.1.39.0f1\Cupscale 1.39.0f1\CupscaleData\bin\pth2ncnn> .\pth2ncnn.exe .\RealESRGAN_x4plus.pth Loading model Traceback (most recent call last): File "D:\obj\windows-release\37amd64_Release\msi_python\zip_amd64\runpy.py", line 193, in _run_module_as_main File "D:\obj\windows-release\37amd64_Release\msi_python\zip_amd64\runpy.py", line 85, in _run_code File "E:\Downloads\Cupscale.1.39.0f1\Cupscale 1.39.0f1\CupscaleData\bin\pth2ncnn\pth2ncnn.exe\__main__.py", line 440, in <module> File "E:\Downloads\Cupscale.1.39.0f1\Cupscale 1.39.0f1\CupscaleData\bin\pth2ncnn\pth2ncnn.exe\__main__.py", line 361, in main KeyError: 'model.0.weight' PS E:\Downloads\Cupscale.1.39.0f1\Cupscale 1.39.0f1\CupscaleData\bin\pth2ncnn>

Thanks :)

tumuyan commented 1 year ago

The pth2ncnn' tool could only convert esrgan model, but RealESRNet_x4plus.pth is a RealESRGAN model. You should use realesrgan project (python) to convert the model to onnx, then use ncnn tool to convert onnx model to ncnn (bin file) But the App has contains the RealESRGAN official model.