Home

Awesome

neosr

neosr is a framework for training real-world single-image super-resolution networks.

installation

Requires Python 3.11 and CUDA =>11.8

git clone https://github.com/muslll/neosr
cd neosr

Install latest Pytorch (=>2.1) and TorchVision (required).

Then install other dependencies via pip:

pip install -e .

Alternatively, use poetry (recommended on linux):

poetry install && poetry add torch@latest torchvision@latest

Note: You must use poetry shell to enter the env after installation.

(optional) If you want to convert your models (convert.py), you need to following dependencies:

pip install onnx onnxruntime-gpu onnxconverter-common onnxsim

You can also install using poetry (recommended on linux):

poetry add onnx onnxruntime-gpu onnxconverter-common onnxsim

Please read the wiki tutorial for converting your models.

quick start

Start training by running:

python train.py -opt options.yml

Where options.yml is a configuration file. Templates can be found in options. Please read the wiki Configuration Walkthrough for an explanation of each option.

features

Currently included archs:

archoption
ESRGANold_esrgan
Real-ESRGANesrgan
SRVGGNetCompactcompact
SwinIRswinir_small, swinir_medium
HAThat_s, hat_m, hat_l
OmniSRomnisr
SRFormersrformer_light, srformer_medium
DATdat_light, dat_small, dat_medium, dat_2
DITNditn
DCTLSAdctlsa
SPANspan
NLSANnlsan_medium, nlsan_light
DWTdwt
EDATedat, edat_light
CRAFTcraft
Bicubic++bpp, bpp_l
Real-CUGANcugan

Arch Inference times with provided testscript, rtx 3060

typefps
bicubic ++1.76
compact1.37
span0.92
ditn0.76
omnisr0.54
swinir_small0.49
craft0.49
srformer_light0.43
nlsan_light0.38
dctlsa0.35
dat_light0.35
esrgan0.18
swinir_medium0.13
dwt_light0.12
dat_small0.08
dat_20.08
dat_medium0.07

Supported Discriminators:

netoption
U-Net SNunet
A2-FPNa2fpn

Supported Optimizers:

optimizeroption
AdamAdam or adam
AdamWAdamW or adamw
LionLion or lion
LAMBLamb or lamb
AdanAdan or adan

Supported models:

modeldescriptionoption
DefaultBase model, supports both Generator and Discriminatordefault
OTFBuilds on top of default, adding Real-ESRGAN on-the-fly degradationsotf

Supported dataset loaders:

loaderoption
Paired datasetspaired
Single datasets (for inference, no GT required)single
Real-ESRGAN on-the-fly degradationotf

Supported losses:

lossoption
L1 LossL1Loss, l1
L2 LossMSELoss, l2
Huber LossHuberLoss, huber
Perceptual Lossperceptual_opt, PerceptualLoss
GANgan_opt, GANLoss, MultiScaleGANLoss
YUV Color Losscolor_opt, colorloss
LDL Lossldl_opt
Focal Frequencyff_opt, focalfrequencyloss

datasets

If you don't have a dataset, you can either download research datasets like DIV2K or use one of the following.

These datasets have been tiled and manually curated across multiple sources, including DIV8K, Adobe-MIT 5k, RAISE, FFHQ, etc.

datasetnum imagesmeta_infodownloadsha256
nomos_uni2989 (512x512px)nomos_uni_metainfo.txtGDrive (1.3GB)6403764c3062aa8aa6b842319502004aab931fcab228f85eb94f14f3a4c224b2
nomos_uni (lmdb)2989 (512x512px)-GDrive (1.3GB)596e64ec7a4d5b5a6d44e098b12c2eaf6951c68239ade3e0a1fcb914c4412788
nomos_uni (LQ 4x)2989 (512x512px)nomos_uni_metainfo.txtGDrive (92MB)c467e078d711f818a0148cfb097b3f60763363de5981bf7ea650dad246946920
nomos_uni (LQ 4x - lmdb)2989 (512x512px)-GDrive (91MB)1d770b2c6721c97bd2679db68f43a9f12d59a580e9cfeefd368db5a4fab0f0bb
nomos8k8492 (512x512px)nomos8k_metainfo.txtGDrive (3.4GB)89724f4adb651e1c17ebee9e4b2526f2513c9b060bc3fe16b317bbe9cd8dd138
hfa2k2568 (512x512px)hfa2k_metainfo.txtGDrive (3.2GB)3a3d2293a92fb60507ecd6dfacd636a21fd84b96f8f19f8c8a55ad63ca69037a

Note: these are not intended for use in academic research.

community datasets

These are datasets made by the upscaling community. More info can be found in the Enhance Everything discord

datasetnum imagesmeta_infodownloadsha256
@Kim2091's 8k Dataset V2672 (7680x4320px)-GDrive (33.5GB)-
@Phhofm FaceUp10000 (512x512)-GDrive (4GB)-
@Phhofm SSDIR10000 (512x512)-Gdrive (4.5GB)-

resources

support me

☕ Consider supporting me on KoFi. ☕

license and acknowledgements

Released under the Apache license. This code was originally based on BasicSR. See other licenses in license/readme.

Thanks to victorca25/traiNNer, styler00dollar/Colab-traiNNer and timm for providing helpful insights into some problems.

Thanks to contributors @Phhofm, @Sirosky, @Kim2091 and @terrainer for helping with tests and bug reporting.