Skip to content

SRCNN and FSRCNN

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

Overview

SRCNN, by Dong and colleagues, was the first convolutional network for super-resolution. It ran three layers after a bicubic enlargement. FSRCNN, by the same authors, made it faster by working at the small size and enlarging only at the end with a transposed convolution. PixelNexus runs FSRCNN at two times, since SRCNN itself has no published weights with a clear license. The model is under 0.1 MB, small enough to study. OpenCV's dnn_superres module runs it.

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.

Three panels with four quarters each: stripes, fine noise, soft blobs and flat gray. Bicubic and FSRCNN both look slightly soft and close to the original at this scale. Three panels with four quarters each: stripes, fine noise, soft blobs and flat gray. Bicubic and FSRCNN both look slightly soft and close to the original at this scale.
The texture image of the edge pages. Shrunk two times with bicubic, then enlarged two times with bicubic and FSRCNN.

How it works

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

Mathematical foundation

\[ \hat{x} = D\big(m(s(e(y)))\big) \]

The formula shows the default parameter values.

where

  • \(e\): Feature extraction
  • \(s, m\): Shrinking and mapping layers
  • \(D\): The transposed convolution that enlarges

FSRCNN works at the small size. The layer e extracts features with a 5 x 5 convolution, and s shrinks them to fewer channels. The layers m map them with a few 3 x 3 convolutions. D, a transposed convolution, enlarges them to the output. SRCNN, its predecessor, first enlarged with bicubic and then ran three convolutions, which was slower.

FSRCNN extracts features with a 5 x 5 convolution and shrinks them to fewer channels. A few 3 x 3 layers map them, and a transposed convolution enlarges the result. Working at the small size makes it much faster than SRCNN.

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 2 2 to 2 x How many times larger the image becomes in each direction. The model was trained for 2 times only.

Implementation

srcnn in engine/src/pixelnexus_engine/filters/learned.py calls cv2.dnn_superres.DnnSuperResImpl with the FSRCNN x2 model of the FSRCNN_Tensorflow project. Colors are premultiplied by alpha first, and alpha is enlarged with bicubic.

Worked example

Method Whole (dB) Stripes (dB) Noise (dB) Blobs (dB) Flat (dB)
Bicubic 23.08 30.06 17.32 40.09 41.55
FSRCNN 22.99 28.45 17.33 39.23 41.27

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

FSRCNN does not beat bicubic on this image. It is 0.1 dB lower on the whole image and 1.6 dB lower on the stripes. The model was trained on a different shrinking than the one used here, and it is tiny. It is in PixelNexus to show how a small network enlarges, not to beat the classical methods.

Complexity

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

N is the number of input pixels. About 12 thousand weights.

Artifacts and limitations

Limitations

  • Only slightly sharper than bicubic.

Artifacts

  • Mild ringing at strong edges.

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 two times larger.

References

  • Dong, C., Loy, C. C., and Tang, X. Accelerating the super-resolution convolutional neural network. Computer Vision, ECCV 2016, Lecture Notes in Computer Science, 391 to 407, 2016. DOI 10.1007/978-3-319-46475-6_25.
  • Dong, C., Loy, C. C., He, K., and Tang, X. Image super-resolution using deep convolutional networks. IEEE Transactions on Pattern Analysis and Machine Intelligence 38(2), 295 to 307, 2016. DOI 10.1109/TPAMI.2015.2439281.
  • OpenCV documentation, dnn_superres module.