Skip to content

Losses & Perceptual Metrics ​

Super-resolution exhibits a fundamental perception-distortion trade-off: minimizing pixel-wise error alone produces overly smooth textures, while aggressive adversarial training can hallucinate unrealistic high-frequency patterns. SoraSR exposes a composable loss framework to navigate this trade-off explicitly.

Composite Training Objective ​

The total generator loss combines spatial reconstruction, deep perceptual similarity, and frequency-domain fidelity:

Ltotal=λpixLchar+λpercLvgg+λfreqLfft+λadvLgan

1. Charbonnier Pixel Loss ​

A differentiable approximation to L1 loss that avoids zero-gradient instability near exact pixel matches:

Lchar(y^,y)=1N∑i=1N(y^i−yi)2+ϵ2,ϵ=10−3

Charbonnier loss is used exclusively during Stage 1 pretraining (λpix=1.0, all other weights 0) to establish a distortion-optimal anchor checkpoint.

2. Multi-Scale Perceptual Loss ​

Extracts intermediate activations from a frozen VGG-19 network (conv2_2, conv3_4, conv4_4, conv5_4 before activation) and computes weighted L1 distance:

Lvgg(y^,y)=∑l∈Swl∥ϕl(y^)−ϕl(y)∥1

Using pre-activation features preserves texture contrast and reduces brightness drift compared to post-ReLU feature maps.

3. 2D Frequency (FFT) Loss ​

Supervises the log-amplitude spectrum of the 2D Fast Fourier Transform to discourage over-smoothing of fine diagonal structures:

Lfft(y^,y)=‖log(1+|F(y^)|)−log(1+|F(y)|)‖1

In practice, a modest weight (λfreq∈[0.02,0.08]) sharpens edges without introducing ringing artifacts.

StageStepsActive WeightsPrimary Goal
Stage 1 (PSNR Pretrain)300kchar=1.0, fft=0.02Converge low-frequency geometry and color
Stage 2 (Perceptual Fine-Tune)150kchar=0.5, vgg=1.0, fft=0.05, gan=0.05Restore crisp micro-textures and natural grain

Evaluation Metrics ​

SoraSR reports three complementary metrics during validation:

  • PSNR (Y-Channel, dB) — Measures pixel-level distortion on the BT.601 luminance channel after shaving scale boundary pixels. Higher is better.
  • SSIM (Y-Channel) — Captures local luminance, contrast, and structural correlation over 11×11 Gaussian windows. Higher is better (range [0,1]).
  • LPIPS (AlexNet / VGG) — Learned perceptual patch similarity aligned with human visual preference. Lower is better.
yaml
# Example loss block in a SoraSR training config
losses:
  charbonnier:
    weight: 0.5
    eps: 1.0e-3
  perceptual:
    weight: 1.0
    backbone: vgg19
    layers: { conv2_2: 0.1, conv3_4: 0.2, conv4_4: 0.4, conv5_4: 0.3 }
  fft:
    weight: 0.05

Released under the Apache-2.0 License.