readme.md

April 12, 2025 ยท View on GitHub


Join our Discord

neosr is an open-source framework for training super-resolution models. It provides a comprehensive and reproducible environment for achieving state-of-the-art image restoration results, making it suitable for both the enthusiastic community, professionals and machine learning academic researchers. It serves as a versatile platform and aims to bridge the gap between practical application and academic research in the field.

  • Accessible: implements a wide range of the latest advancements in single-image super-resolution networks, losses, optimizers and augmentations. Users can easily explore, adapt and experiment with various configurations for their specific needs, even without coding skills.

  • Efficient: optimized for faster training iterations, quicker convergence and low GPU requirements, making it the most efficient choice for both research and practical use cases.

  • Practical: focuses on the real-world use of super-resolution to realistically restore degraded images in various domains, including photos, anime/cartoons, illustrations and more. It's also suitable for critical applications like medical imaging, forensics, geospatial and others (although caution should be taken in those cases).

  • Reproducible: this framework emphasizes the importance of reproducible research. It provides deterministic training environments that can create bit-exact reproducible models (on the same platform), ensuring predictable and reliable results, which are essential for maintaining consistency in academic validation.

  • Simple: features are easy to implement or modify. Code is written in readable Python, no fancy styling. All code is managed, validated and formatted by uv, ruff, mypy and torchfix.

For more information see our wiki.

๐Ÿค support the project

Tip

Consider supporting the project on KoFi โ˜• or Patreon

๐Ÿ’ป installation

Requires CUDA >=12.4

Windows:

powershell -ExecutionPolicy ByPass -c "irm https://raw.githubusercontent.com/neosr-project/neosr/refs/heads/master/install_windows.ps1 | iex"

Linux:

curl -LsSf https://raw.githubusercontent.com/neosr-project/neosr/refs/heads/master/install_linux.sh | sh

Note: neosr will be installed on your terminal current path.

To update neosr, run:

neosr-update

For manual installation details, see our Installation Instructions wiki.

โฉ quick start

Start training by running:

neosr-train config.toml

Where config.toml is a configuration file. Templates can be found in options.

Tip

Please read the wiki Configuration Walkthrough for an explanation of each option.

โœจ features

supported archs:

archoption
Real-ESRGANesrgan
SRVGGNetCompactcompact
SwinIRswinir_small, swinir_medium
HAThat_s, hat_m, hat_l
OmniSRomnisr
SRFormersrformer_light, srformer_medium
DATdat_small, dat_medium, dat_2
DITNditn
DCTLSAdctlsa
SPANspan
Real-CUGANcugan
CRAFTcraft
SAFMNsafmn, safmn_l
RGTrgt, rgt_s
ATDatd, atd_light
PLKSRplksr, plksr_tiny
RealPLKSRrealplksr, realplksr_s, realplksr_l
DRCTdrct, drct_l, drct_s
MSDANmsdan
SPANPlusspanplus, spanplus_sts, spanplus_s, spanplus_st
HiT-SRFhit_srf, hit_srf_medium, hit_srf_large
HMAhma, hma_medium, hma_large
MANman, man_tiny, man_light
light-SAFMN++light_safmnpp
GRFormergrformer, grformer_medium, grformer_large
EIMNeimn, eimn_a, eimn_l
LMLTlmlt, lmlt_tiny, lmlt_large
DCTdct
KRGNkrgn
PlainUSRplainusr, plainusr_ultra, plainusr_large
HASNhasn
FlexNetflexnet, metaflexnet
CFSRcfsr
Sebicasebica, sebica_mini
NinaSRninasr, ninasr_b0, ninasr_b2
RCANrcan
MoESRmoesr
ASIDasid, asid_d8
MoSRV2mosrv2
ESCesc, esc_fp, esc_large

Note

For all arch-specific parameters, read the wiki.

under testing

archoption
CATANetcatanet

supported discriminators:

netoption
U-Net w/ SNunet
PatchGAN w/ SNpatchgan
EA2FPN (bespoke, based on A2-FPN)ea2fpn
DUnetdunet
MetaGanmetagan

supported optimizers:

optimizeroption
AdamAdam or adam
AdamWAdamW or adamw
NAdamNAdam or nadam
AdanAdan or adan
AdamW Win2AdamW_Win or adamw_win
ECO strategyeco, eco_iters
AdamW Schedule-Freeadamw_sf
Adan Schedule-Freeadan_sf
F-SAMfsam, FSAM
SOAP-SFsoap_sf

supported losses:

lossoption
L1 LossL1Loss, l1_loss
L2 LossMSELoss, mse_loss
Huber LossHuberLoss, huber_loss
CHC (Clipped Huber with Cosine Similarity Loss)chc_loss
NCC (Normalized Cross-Correlation)ncc_opt, ncc_loss
Perceptual Lossperceptual_opt, vgg_perceptual_loss
GANgan_opt, gan_loss
MS-SSIMmssim_opt mssim_loss
LDL Lossldl_opt, ldl_loss
Focal Frequencyff_opt, ff_loss
DISTSdists_opt, dists_loss
Wavelet Guidedwavelet_guided
Perceptual Patch Lossperceptual_opt, patchloss, ipk
Consistency Loss (Oklab and CIE L*)consistency_opt, consistency_loss
KL Divergencekl_opt, kl_loss
MS-SWDmsswd_opt, msswd_loss
FDL + DINOv2 backendfdl_opt, fdl_loss

supported metrics

metricoption
PSNRcalculate_psnr
SSIMcalculate_ssim
DISTScalculate_dists
TOPIQcalculate_topiq

supported augmentations:

augmentationoption
Rotationuse_rot
Flipuse_hflip
MixUpmixup
CutMixcutmix
ResizeMixresizemix
CutBlurcutblur

supported models:

modeldescriptionoption
ImageBase model for SISR, supports both Generator and Discriminatorimage
OTFBuilds on top of image, adding Real-ESRGAN on-the-fly degradationsotf

supported dataloaders:

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

๐Ÿ“ธ datasets

As part of neosr, we have released a series of datasets. The purpose of these datasets is to distill only the best images from the academic and community datasets. A total of 14+ datasets were manually reviewed and processed, including: Adobe-MIT-5k, RAISE, LSDIR, LIU4k-v2, KONIQ-10k, Nikon LL RAW, DIV8k, FFHQ, Flickr2k, ModernAnimation1080_v2, Rawsamples, SignatureEdits, Hasselblad raw samples and Unsplash.

  • BHI series from @Phhofm. Read more about the selection process here. Full version is recommended for large networks, while small version is recommended for lightweight SISR:
datasetdownload
BHI fullRelease page
BHI smallRelease page
BHI miniRelease page
BHI100 (val)Release page
  • Nomos-v2: contains 6000 images, multipurpose.
  • nomos_uni: contains 2989 images, multipurpose. Meant to be used on lightweight networks (<800k parameters).
dataset downloadsha256
nomosv2 (3GB)sha256
nomosv2.lmdb (3GB)sha256
nomosv2_lq_4x (187MB)sha256
nomosv2_lq_4x.lmdb (187MB)sha256
nomos_uni (1.3GB)sha256
nomos_uni_lq_4xsha256

community datasets

Datasets made by the upscaling community. More info can be found in author's repository.

  • digital_art_v3: Digital art dataset from @umzi2.
  • ModernAnimation_v3: High-quality modern anime dataset from Zarxrax.
  • ClassicAnimation: High-quality analog (cel) anime dataset from Zarxrax.
  • DF2k-BHI: a curated version of the classic DF2k dataset, made by @Phhofm.
  • 4xNomosRealWeb Dataset: realistically degraded LQ's for Nomos-v2 dataset (from @Phhofm).
  • FaceUp: Curated version of FFHQ.
  • SSDIR: Curated version of LSDIR.
  • ArtFaces: Curated version of MetFaces.
  • Nature Dataset: Curated version of iNaturalist.
datasetdownload
@Phhofm DF2k-BHIHuggingFace
@Phhofm 4xNomosRealWebRelease page
@Phhofm FaceUpGDrive (4GB)
@Phhofm SSDIRGdrive (4.5GB)
@Phhofm ArtFacesRelease page
@Phhofm Nature DatasetRelease page
@umzi2 Digital Art (v3)Release page
@Zarxrax ClassicAnimationRelease page
@Zarxrax ModernAnimation_v3Release page

๐Ÿ“– resources

๐Ÿ“„ license and acknowledgements

Released under the Apache license. All licenses listed on license/readme. This code was originally based on BasicSR.

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

Thanks to active contributors @Phhofm, @Sirosky, and @umzi2 for helping with tests and bug reporting.