Skip to main content

Overview

SRVGGNetCompact is a compact VGG-style network architecture designed for efficient super-resolution. It performs upsampling in the last layer and conducts no convolution on the HR feature space, making it computationally efficient. This architecture is used in the lightweight Real-ESRGAN models like realesr-animevideov3 and realesr-general-x4v3.

Class Definition

Parameters

int
default:"3"
Number of input channels. Typically 3 for RGB images.
int
default:"3"
Number of output channels. Typically 3 for RGB images.
int
default:"64"
Number of feature channels in intermediate layers. Higher values increase model capacity but also computational cost.
int
default:"16"
Number of convolutional layers in the body network. More layers allow the model to learn more complex patterns.
int
default:"4"
Upsampling factor for super-resolution. Common values are 2, 4, or 8.
str
default:"prelu"
Activation function type. Options:
  • 'relu': ReLU activation
  • 'prelu': Parametric ReLU (default, learns activation parameters)
  • 'leakyrelu': Leaky ReLU with negative slope of 0.1

Architecture Details

The network consists of:
  1. Initial convolution: 3×3 conv layer that expands input channels to num_feat channels
  2. Body network: num_conv layers of 3×3 convolutions with activation functions
  3. Final convolution: Maps features to output space (channels = num_out_ch × upscale²)
  4. Pixel shuffle upsampler: Rearranges feature maps to produce high-resolution output
  5. Residual connection: Adds nearest-neighbor upsampled input to the network output
The network learns residual information rather than the full high-resolution image, which helps with training stability and performance.

Model Configurations

realesr-animevideov3 (XS size)

Optimized for anime video upscaling with minimal parameters.

realesr-general-x4v3 (S size)

General-purpose model with more layers for better quality on diverse images.

Usage Example

SRVGGNetCompact is significantly more efficient than RRDBNet, making it ideal for real-time applications and video processing.

Forward Method

The forward pass:
  1. Processes input through body network layers sequentially
  2. Applies pixel shuffle to upsample feature maps
  3. Adds nearest-neighbor upsampled input as residual

Source

Defined in realesrgan/archs/srvgg_arch.py