License MIT Static Badge

Fast-SRGAN

Overview

Fast-SRGAN is a lightweight generative super-resolution model. It upscales small images to 4x their size with minimal loss in detail while remaining fast enough for edge deployment. The model implemented here is the Fast-SRGAN x4 Bicubic variant, so it provides the best results for bicubically downscaled images. It takes a 128x128 RGB image as input and outputs a 512x512 RGB image. The int8 TFLite model used here is published in the PINTO model zoo.

This repository contains the already-quantized int8 TFLite model, plus variants compiled/converted for NXP i.MX 8M Plus, i.MX 93, i.MX 95, and i.MX 952, together with the scripts used to produce them.

Key Features

  • Lightweight generative super-resolution network (4x upscaling)
  • Trained with 6 inverted residual blocks and 32 filters per generator layer
  • ~168K parameters, ~460M FLOPS
  • int8 quantized for accelerated NPU inference on NXP i.MX platforms

Model Description

This repository contains the Fast-SRGAN x4 model quantized to int8 and compiled for NXP i.MX 8M Plus, i.MX 93, i.MX 95, and i.MX 952 processors.

  • Base Model: Fast-SRGAN
  • Original Model Authors: Hasnain Raz
  • Original License: MIT
  • Modified by: NXP

Modifications

This model is a derivative work with the following changes from the original:

  • Quantization: The int8 TFLite model is provided directly by the PINTO model zoo; no local re-quantization is performed. Weights and activations are int8, while the input and output tensors of the TFLite graph remain float32.
  • Compilation: Compiled for i.MX 93 (Arm Ethos-U65 NPU) using Vela, tagged lf-6.18.20_2.0.0 and lf-6.18.37_2.1.0.
  • Conversion: Converted for i.MX 95 and i.MX 952 (eIQ Neutron NPU) using eIQ Neutron SDK versions 3.1.3, 3.2.1, and 3.2.3.
  • Post-processing outside the graph: The input image is normalized to [0, 1] before inference. The raw model output is in the range [-1, 1] and is mapped back to [0, 255] by example.py after inference.

Original model available at: Fast-SRGAN.

Model Information

Information Value
Input shape RGB image (1, 128, 128, 3), float32, normalized to [0, 1]
Input example (Image source: Urban100 dataset [1])
Output shape RGB image (1, 512, 512, 3), float32, values in [-1, 1] (mapped to [0, 255] outside the graph)
Output example
FLOPS 460M
Number of parameters 168K
File size (int8) 240 KB

The model was trained on 128x128 images but can be used with images of different sizes via interpreter.resize_tensor_input() in example.py; it performs best at its trained input size.

Supported Hardware and Software Configurations

The same information is available in machine-readable form in release_manifest.json.

Asset Runtime Precision HW target BSP & SDK versions Link to asset
i.MX 8M Plus Quantized LiteRT INT8 i.MX 8M Plus - Download
i.MX 93 Precompiled LiteRT INT8 i.MX 93 BSP lf-6.18.20_2.0.0, VELA_TAG = lf-6.18.20_2.0.0 Download
i.MX 93 Precompiled LiteRT INT8 i.MX 93 BSP lf-6.18.37_2.1.0, VELA_TAG = lf-6.18.37_2.1.0 Download
i.MX 95 Precompiled LiteRT INT8 i.MX 95 BSP lf-6.18.20_2.0.0, Neutron SDK v3.1.3 Download
i.MX 95 Precompiled LiteRT INT8 i.MX 95 BSP lf-6.18.37_2.1.0, Neutron SDK v3.2.1 Download
i.MX 95 Precompiled LiteRT INT8 i.MX 95 BSP lf-6.18.37_2.1.0, Neutron SDK v3.2.3 Download
i.MX 952 Precompiled LiteRT INT8 i.MX 952 BSP lf-6.18.20_2.0.0, Neutron SDK v3.1.3 Download
i.MX 952 Precompiled LiteRT INT8 i.MX 952 BSP lf-6.18.37_2.1.0, Neutron SDK v3.2.1 Download
i.MX 952 Precompiled LiteRT INT8 i.MX 952 BSP lf-6.18.37_2.1.0, Neutron SDK v3.2.3 Download

Note: assets/imx8mplus/fsrgan.tflite is the same file as assets/quantized_tflite_model/fsrgan.tflite (identical sha256). The latter is also kept as a host (x86) reference copy for use with example.py on a PC and is not re-listed in the table above.

Limitations and Biases

  • Task scope: This model only performs 4x bicubic super-resolution; it is not designed for other degradation types (e.g. noisy or blurry inputs) or other upscaling factors.
  • Training data bias: The original model was trained on natural photographic image datasets and may not generalize well to synthetic images, text, or domains that are under-represented in the training data (see Training section).

Download and Run

The recipe installs the eIQ Neutron SDK from the NXP eIQ PyPI Distribution Portal. Configure pip once to use it:

python -m pip config --user set global.index https://eiq.nxp.com/repository
python -m pip config --user set global.index-url https://eiq.nxp.com/repository
python -m pip config --user set global.trusted-host eiq.nxp.com
python -m pip config --user set global.extra-index-url https://pypi.org/simple
python -m pip config --user set global.find-links https://eiq.nxp.com/repository/

To download the quantized int8 model and compile the platform-specific variants, run:

bash recipe.sh

The Vela tag and eIQ Neutron SDK version can be passed as positional arguments (defaulting to lf-6.18.20_2.0.0 and 3.2.3 respectively):

bash recipe.sh lf-6.18.37_2.1.0 3.2.3

This generates:

  • assets/quantized_tflite_model/fsrgan.tflite - int8 TFLite model for i.MX 8M Plus (and host/x86 reference).
  • assets/imx93/<VELA_TAG>/fsrgan_vela.tflite - Vela-compiled model for i.MX 93.
  • assets/imx95/<NEUTRON_SDK_VERSION>/fsrgan_converted.tflite - Neutron-converted model for i.MX 95.
  • assets/imx952/<NEUTRON_SDK_VERSION>/fsrgan_converted.tflite - Neutron-converted model for i.MX 952.

An example of how to use the model is in example.py (run on a PC):

python example.py -m assets/quantized_tflite_model/fsrgan.tflite -i example_input.png -o example_output.png

All three arguments are optional; the defaults shown above (-m assets/quantized_tflite_model/fsrgan.tflite, -i example_input.png, -o example_output.png) are used if omitted. The example loads an input image, runs super-resolution inference, and writes the upscaled image.

Please refer to the i.MX Machine Learning User Guide for details on how to run the models on each target platform.

License

This repository is released under the MIT License (see LICENSE), the same license as the original Fast-SRGAN model (see MODEL_LICENSE).

Citation

If you use this model, please cite both this work and the original model:

@misc{fast-srgan,
  title = {Fast-SRGAN},
  author = {Raz, Hasnain},
  howpublished = {\url{https://github.com/HasnainRaz/Fast-SRGAN}}
}

@inproceedings{huang2015single,
  title={Single image super-resolution from transformed self-exemplars},
  author={Huang, Jia-Bin and Singh, Abhishek and Ahuja, Narendra},
  booktitle={Proceedings of the IEEE conference on computer vision and pattern recognition},
  pages={5197--5206},
  year={2015}
}
Downloads last month
194
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Collections including nxp/fast-srgan-imx