Skip to content

Latest commit

 

History

History
92 lines (83 loc) · 3.52 KB

File metadata and controls

92 lines (83 loc) · 3.52 KB

Pytorch SRGAN (Super Resolution)

Setup AI Model Efficiency Toolkit (AIMET)

Please install and setup AIMET before proceeding further. This model was tested with the torch_gpu variant of AIMET 1.22.2.

Experiment setup

  • Clone the mmsr repo and apply patch
  git clone https://github.com/andreas128/mmsr.git
  cd mmsr
  git checkout a73b318f0f07feb6505ef5cb1abf0db33e33807a
  git apply aimet_zoo_torch/srgan/evaluators/srgan_eval.patch
  • Install dependencies
   python -m pip install lmdb
  • Append the repo location to your PYTHONPATH with the following:
    export PYTHONPATH=<path to mmsr repo>:<path to mmsr repo>/codes:$PYTHONPATH

    Note that here we add both mmsr and the subdirectory mmsr/codes to our path.

  • Loading AIMET model zoo libraries
    export PYTHONPATH=$PYTHONPATH:<aimet_model_zoo_path>

Model checkpoints and configuration

  • Downloading checkpoints is handled through evaluation script. Configuration is set to default by evaluation script.
  • The SRGAN model checkpoints can be downloaded from mmediting.
  • The Quantization Simulation (Quantsim) Configuration file can be downloaded from default_config_per_channel.json. (Please see this page for more information on this file).

Dataset

  • Three benchmark datasets can be downloaded from here:

    Our benchmark results use images under image_SRF_4 directory which tests 4x super-resolution as the suffix number indicates. You can also use other scales. See instructions for usage below.

  • Downloaded datasets should be arranged in one directory <dataset_path>

    • The <dataset_path> should be arranged in the following way
  <dataset_path>/
  ├── Set5
  │   ├── image_SRF_2
  │   ├── image_SRF_3
  │   ├── image_SRF_4
  ├── Set14
  │   ├── image_SRF_2
  │   ├── image_SRF_3
  │   ├── image_SRF_4
  ├── BSD100
  │   ├── image_SRF_2
  │   ├── image_SRF_3
  │   ├── image_SRF_4

Usage

  • To run evaluation with QuantSim in AIMET, use the following
python srgan_quanteval.py \
	--mmsr-path <path to patched mmsr git repo> \
	--dataset-path <path to dataset folder> \
	--use-cuda <Run evaluation on GPU> \
	--output-dir <path to output images>

Quantization configuration

  • Weight quantization: 8 bits per tensor asymmetric quantization
  • Bias parameters are quantized
  • Activation quantization: 8 bits asymmetric quantization
  • Model inputs are not quantized

Results

Model Dataset PSNR SSIM
FP32 Set5 / Set14 / BSD100 29.93 / 26.58 / 25.51 0.851 / 0.709 / 0.653
INT8 Set5 / Set14 / BSD100 29.86 / 26.59 / 25.55 0.845 / 0.705 / 0.648