Skip to main content
Real-ESRGAN uses two primary generator architectures optimized for different use cases, along with a specialized discriminator network for adversarial training.

Generator Architectures

Real-ESRGAN offers two generator networks with different trade-offs between quality and efficiency.

RRDBNet Architecture

The RRDBNet (Residual-in-Residual Dense Block Network) is the primary architecture for high-quality super-resolution tasks, inherited from ESRGAN.

Architecture Parameters

Based on the source code in inference_realesrgan.py, Real-ESRGAN uses the following RRDBNet configurations: RealESRGAN_x4plus / RealESRNet_x4plus (Standard Model)
RealESRGAN_x4plus_anime_6B (Lightweight Anime Model)
RealESRGAN_x2plus (2x Upsampling)

Network Structure

RRDBNet is built on a “Residual-in-Residual” design where dense blocks are nested within residual connections, enabling very deep networks with stable gradient flow.
The network follows this structure:
  1. Initial Convolution: Extracts base features from the input image
  2. RRDB Trunk: Stack of Residual-in-Residual Dense Blocks
  3. Trunk Convolution: Processes accumulated features
  4. Global Residual Connection: Adds input features to output of trunk
  5. Upsampling Layers: Pixel shuffle layers for resolution increase
  6. Final Convolution: Produces output RGB image

Residual-in-Residual Dense Block (RRDB)

Each RRDB contains multiple dense blocks with residual scaling:
  • Dense Block: Each layer connects to all subsequent layers
  • Local Residual: Within each dense block
  • Global Residual: Across the entire RRDB
  • Residual Scaling: Uses β scaling factor (typically 0.2) for stable training

Model Sizes and Complexity

The anime model with only 6 RRDB blocks achieves excellent results for anime content while being significantly smaller, demonstrating that model capacity requirements vary by domain.

SRVGGNetCompact Architecture

SRVGGNetCompact is a lightweight VGG-style architecture designed for fast inference with minimal memory footprint.

Architecture Parameters

From realesrgan/archs/srvgg_arch.py and inference_realesrgan.py: realesr-animevideov3 (Extra Small Model)
realesr-general-x4v3 (Small General Model)

Network Structure

The SRVGGNetCompact architecture is intentionally simple:
Compact Design
  • No dense connections or complex residual structures
  • All convolutions operate on the low-resolution feature space
  • Upsampling performed only at the final layer
Residual Learning
  • Adds nearest-neighbor upsampled input to output
  • Network learns the residual/difference rather than the full output
  • Simplifies learning and improves convergence
Efficiency Focus
  • Minimal memory footprint during inference
  • Fast processing suitable for video applications
  • Significantly fewer parameters than RRDBNet

Activation Functions

SRVGGNetCompact supports three activation types:
  • PReLU (default): Learnable negative slope, most common choice
  • ReLU: Simple and fast, zero for negative values
  • LeakyReLU: Fixed small negative slope (0.1)

Model Comparison

SRVGGNetCompact is approximately 28x smaller and several times faster than RRDBNet while still producing high-quality results for appropriate content types.

Discriminator Architecture

Real-ESRGAN uses a U-Net discriminator with spectral normalization for stable adversarial training.

UNetDiscriminatorSN

From realesrgan/archs/discriminator_arch.py:

Architecture Details

The discriminator follows a U-Net structure with downsampling and upsampling paths:

Downsampling Path

Upsampling Path

Output Head

Key Features

Spectral Normalization: Applied to all convolutional layers (except first and last) to stabilize GAN training by constraining the Lipschitz constant of the discriminator.
U-Net Skip Connections: When enabled (default), features from the downsampling path are added to corresponding upsampling layers:
Multi-scale Discrimination: The U-Net structure enables the discriminator to:
  • Capture both local and global information
  • Provide feedback at multiple resolutions
  • Preserve fine details through skip connections
Activation Function: Uses LeakyReLU with negative_slope=0.2 throughout

Architecture Selection Guide

RRDBNet (23 blocks)
  • Professional photo enhancement
  • Maximum quality is required
  • Batch processing with GPU available
  • File size and speed are not critical
RRDBNet (6 blocks)
  • Anime and illustration upscaling
  • Balance between quality and efficiency
  • Moderate computational resources
SRVGGNetCompact (32 conv)
  • General-purpose fast upscaling
  • Real-time or near-real-time requirements
  • CPU inference or limited GPU memory
SRVGGNetCompact (16 conv)
  • Video super-resolution
  • Anime/cartoon video processing
  • Maximum speed and minimal memory
  • Mobile or edge deployment

Model Files

Pre-trained model weights are available for all architectures:
  • RealESRGAN_x4plus.pth: 4x RRDBNet for general images
  • RealESRNet_x4plus.pth: 4x RRDBNet before GAN training
  • RealESRGAN_x4plus_anime_6B.pth: 4x RRDBNet (6 blocks) for anime
  • RealESRGAN_x2plus.pth: 2x RRDBNet for moderate upscaling
  • realesr-animevideov3.pth: 4x SRVGGNetCompact for anime videos
  • realesr-general-x4v3.pth: 4x SRVGGNetCompact for general use
All models are trained with the same two-stage training strategy but optimized for their respective domains.