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

Use ESRGAN (old Architecture) weights #12

Open
Klanly opened this issue Sep 18, 2020 · 4 comments
Open

Use ESRGAN (old Architecture) weights #12

Klanly opened this issue Sep 18, 2020 · 4 comments

Comments

@Klanly
Copy link

Klanly commented Sep 18, 2020

I made a google colab script to convert ESRGAN (old Architecture) pth files to .param and .bin:

import shutil
import os
!7z x '/content/drive/My Drive/TFMLz/ESRGAN_oldarch/ncnnconv.7z' -o/content
!apt-get install -y libomp-dev
!pip install onnx-simplifier
!chmod u+x onnx2ncnn
!chmod u+x ncnnoptimize
adst='/content/esr.pth'

'''
asrc='/content/drive/My Drive/TFMLz/ESRGAN_oldarch/models/FatalimiX.pth'
shutil.copyfile(asrc,adst)
'''
'''
!7z e '/content/drive/My Drive/TFMLz/ESRGAN_oldarch/models/falcoon300.7z' -o/content
ren xxx.pth esr.pth
...


!python to_onnx.py
!python -m onnxsim '/content/esr.onnx' '/content/esr_simp.onnx'
!/content/onnx2ncnn /content/esr_simp.onnx /content/x4_o1.param /content/x4_o1.bin
!/content/ncnnoptimize /content/x4_o1.param /content/x4_o1.bin /content/x4_fp32.param /content/x4_fp32.bin 0
!/content/ncnnoptimize /content/x4_o1.param /content/x4_o1.bin /content/x4_fp16.param /content/x4_fp16.bin 1

ncnnconv.zip, rename it to .7z
(to_onnx.py .etc from github.com/achie27/super-resolution )

Replace 'models-DF2K/x4.bin' with the generated x4_fp32.bin or x4_fp16.bin then that's it.

There are about +-3 value bias per channel, comparing to it's original pytorch results.

@Felixkruemel
Copy link

Could you just share the bin files instead of pointing to the Colab script?
Also those file paths for the drive should be not working for other users I think

@Klanly
Copy link
Author

Klanly commented Nov 20, 2020

Could you just share the bin files instead of pointing to the Colab script?
Also those file paths for the drive should be not working for other users I think

This the converted weights& prog I currently use..
https://github.com/Klanly/lunusbuild/releases/download/gcgghq/SR.zip

1x ( cmd: realsr.exe -m c -s 1 ) is "Fatality DeBlur";
4x ( cmd: realsr.exe -m c ) is "FatalimiX".

Weights form:
https://upscale.wiki/wiki/Model_Database

default input = tibr_o.jpg
default output = output.png

@Felixkruemel
Copy link

Felixkruemel commented Nov 22, 2020

@Klanly
How can you specify a different model?
Something like realrsr.exe -m "DF2K_JPEG" (if the folder is named that way) doesn't seem to work
And what does -m c do?

@Klanly
Copy link
Author

Klanly commented Nov 23, 2020

@Klanly
How can you specify a different model?
Something like realrsr.exe -m "DF2K_JPEG" (if the folder is named that way) doesn't seem to work
And what does -m c do?

https://github.com/Klanly/realsr-ncnn-vulkan/blob/master/src/Readme/Readme.md
'a'=models-DF2K_JPEG, 'b'=models-DF2K, 'c'=models-ESRGAN

So,
-m a = -m "DF2K_JPEG"
-m b = -m "DF2K"

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