RealESRGAN<T>

Models & Types · AiDotNet.Video

Real-ESRGAN (Real Enhanced Super-Resolution GAN) for image and video super-resolution.

Inheritance: NeuralNetworkBase<T> → VideoNeuralNetworkBase<T> → VideoSuperResolutionBase<T> → RealESRGAN<T>

For Beginners

Real-ESRGAN upscales images and video frames to higher resolution while adding realistic details. It’s one of the most practical super-resolution models.

The network works by:

  1. Extracting deep features from low-resolution input using RRDB blocks
  2. Upsampling using pixel shuffle (efficient sub-pixel convolution)
  3. Training with adversarial loss to add realistic textures
  4. Using perceptual loss to ensure visual quality

Example usage:

How It Works

Real-ESRGAN is a practical super-resolution model that uses:

  • RRDB (Residual in Residual Dense Block) generator for deep feature extraction
  • U-Net discriminator for adversarial training
  • Combined loss: L1 (pixel) + Perceptual (VGG) + GAN (adversarial)
  • Second-order degradation model for realistic training data

Reference: Wang et al., “Real-ESRGAN: Training Real-World Blind Super-Resolution with Pure Synthetic Data”, ICCV 2021. https://arxiv.org/abs/2107.10833

Constructors

Constructor Summary
RealESRGAN(NeuralNetworkArchitecture<T> architecture, string onnxModelPath, RealESRGANOptions options) Creates a Real-ESRGAN model using a pretrained ONNX model for inference.
RealESRGAN(NeuralNetworkArchitecture<T> generatorArchitecture, NeuralNetworkArchitecture<T> discriminatorArchitecture, InputType inputType, RealESRGANOptions options, IGradientBasedOptimizer<T, Tensor<T>, Tensor<T>> generatorOptimizer, IGradientBasedOptimizer<T, Tensor<T>, Tensor<T>> discriminatorOptimizer) Initializes a new instance of the Real-ESRGAN class.

Properties

Property Summary
RRDBNetGenerator<T> Generator { get; set; } Gets the RRDB-Net generator network that produces super-resolved images.
T LastDiscriminatorLoss { get; } Gets the last discriminator loss value.
T LastGeneratorLoss { get; } Gets the last generator loss value.
UNetDiscriminator<T> Discriminator { get; set; } Gets the U-Net discriminator network that judges image quality.
bool SupportsTraining { get; } Gets whether training is supported (only in native mode).
bool UseNativeMode { get; } Gets whether this model uses native mode (true) or ONNX mode (false).
int UpscaleFactor { get; } Gets the upscaling factor for this model.

Methods

Method Summary
ModelMetadata<T> GetModelMetadata()
Tensor<T> Upscale(Tensor<T> lowResImage) Upscales a low-resolution image to high resolution.
ValueTuple<T, T> TrainStep(Tensor<T> lowResImages, Tensor<T> highResTargets) Performs one training step for Real-ESRGAN.