Skip to content

EDSR

Fact Value
Also called Enhanced deep super-resolution
Status Available through an optional pretrained model
Family Deep learning and learned processing
Engine Science engine
Type Nonlinear, learned, residual CNN super-resolution
Output Image
Operator shown as algorithm (exact)
Support radius global
Code engine/src/pixelnexus_engine/filters/learned.py, edsr
Operator code engine/src/pixelnexus_engine/filters/learned.py, edsr
Packages OpenCV

Overview

EDSR, by Lim and colleagues, enlarges an image four times with a deep residual network. It was trained on clean images shrunk with bicubic and an L1 loss, so it aims at the true image and does not invent texture the way GAN models do. OpenCV's dnn_superres module runs it. The filter runs in the PixelNexus engine.

It needs an optional model. The model downloads only when you click Download model in the Properties panel, which first shows its size and license, and the engine checks its SHA-256 before it keeps it. Models published as PyTorch weights are converted to ONNX once on your computer with tools/export_models.py. The engine itself never uses PyTorch. Results carry the label: AI result. Detail may not exist in the original scene.

Four panels in four quarters each: stripes, fine noise, soft blobs and flat gray. The original is sharp. Bicubic is soft, with the stripes blurred and the noise smoothed away. Real-ESRGAN gives crisp stripes but turns the soft blobs into a busy, painted texture that was not there. EDSR is close to bicubic, a little sharper. Four panels in four quarters each: stripes, fine noise, soft blobs and flat gray. The original is sharp. Bicubic is soft, with the stripes blurred and the noise smoothed away. Real-ESRGAN gives crisp stripes but turns the soft blobs into a busy, painted texture that was not there. EDSR is close to bicubic, a little sharper.
The texture image of the edge pages: stripes, fine noise, soft blobs and a flat gray. Shrunk four times with bicubic, then enlarged four times with bicubic, Real-ESRGAN and EDSR.

How it works

  1. Premultiply the colors by alpha.
  2. Run EDSR through OpenCV.
  3. Enlarge alpha with bicubic.

Mathematical foundation

\[ \hat{x} = U_4\big(h_0 + \textstyle\sum_{k} r_k(h)\big),\quad h_0 = c(y) \]

The formula shows the default parameter values.

where

  • \(y\): The small image
  • \(r_k\): A residual block
  • \(U_4\): The upsampling part

A first convolution c turns the image into features h_0. Residual blocks r_k, without batch normalization, refine them, and their sum is added to h_0. An upsampling part U with pixel shuffles enlarges the result four times. The model was trained with an L1 loss, so it aims at the true image.

EDSR removed batch normalization from the residual blocks of earlier networks, which saved memory and improved results, and used that saving for more blocks and channels. An upsampling part with pixel shuffles enlarges the features at the end.

Kernel or operator

A trained network has many learned kernels, not one. The Inspector shows the stages and the model with its license.

Parameters

Parameter Default Values Meaning
Scale scale 4 4 to 4 x How many times larger the image becomes in each direction. The model was trained for 4 times only.

Implementation

edsr in engine/src/pixelnexus_engine/filters/learned.py calls cv2.dnn_superres.DnnSuperResImpl with the EDSR x4 model of the EDSR_Tensorflow project. Colors are premultiplied by alpha first, and alpha is enlarged with bicubic. OpenCV 5 still reads these TensorFlow files.

Worked example

Method Whole (dB) Stripes (dB) Noise (dB) Blobs (dB) Flat (dB)
Bicubic 20.34 18.54 16.54 31.41 40.20
Real-ESRGAN 18.34 15.52 16.36 21.28 40.99
EDSR 20.34 18.68 16.44 31.89 40.44

PSNR against the original, 160 x 160, gray. The small copy was made with Pillow's bicubic resize, which filters before it samples.

EDSR matches bicubic on the whole image and is a little better on the stripes and the blobs. It adds no false texture. The fine noise quarter cannot be recovered by any method, since the shrinking removed it.

Complexity

  • Time: \(O(N)\)
  • Memory: \(O(16 N)\)

N is the number of input pixels. EDSR is large, so it is slow on the CPU.

Artifacts and limitations

Limitations

  • Trained on bicubic shrinking only, so real blur and noise stay or grow.
  • Slow on large images.

Artifacts

  • Soft results on real photos.

Tests

Tiny ONNX models made inside the tests check the plumbing in every test run. Tiles with enough margin must equal a run on the whole image. Color, alpha and padding must be handled as described. Where the real model is downloaded, as on the development machine, the real network is checked too. With the real model, the result must be four times larger.

References

  • Lim, B., Son, S., Kim, H., Nah, S., and Lee, K. M. Enhanced deep residual networks for single image super-resolution. IEEE Conference on Computer Vision and Pattern Recognition Workshops, 1132 to 1140, 2017. DOI 10.1109/CVPRW.2017.151.
  • OpenCV documentation, dnn_superres module.