PSFRGAN for face restoration

The model operates at 512x512 resolution and is particularly effective at restoring faces with various degradations including blur, noise, and low resolution.

It was introduced in the paper Progressive Semantic-Aware Style Transformation for Blind Face Restoration by Chaofeng Chen et al. at CVPR 2021.

We have developed a modified version optimized for AMD Ryzen AI.

Model description

PSFRGAN (Progressive Semantic-aware Face Restoration Generative Adversarial Network) is a deep learning model designed for blind face restoration, capable of recovering high-quality face images from severely degraded inputs.

Intended uses & limitations

You can use this model for face restoration tasks. See the model hub for all available psfrgan models.

How to use

Installation

# inference only
pip install -r requirements-infer.txt
# inference & evaluation
pip install -r requirements-eval.txt

Data Preparation (optional: for evaluation)

  1. Download CelebA-Test (LQ) and CelebA-Test (HQ) from GFP-GAN homepage
  2. Organize the dataset directory as follows:
└── datasets
     └── celeba_512_validation
           β”œβ”€β”€ 00000000.png
           β”œβ”€β”€ ...
     β”œβ”€β”€ celeba_512_validation_lq
           β”œβ”€β”€ 00000000.png
           β”œβ”€β”€ ...

Test & Evaluation

  • Run inference on images
python onnx_inference.py --onnx psfrgan_nchw_fp32.onnx --latent latent.npy --input /Path/To/Image --out-dir outputs
python onnx_inference.py --onnx psfrgan_nhwc_int8.onnx --latent latent.npy --input /Path/To/Image --out-dir outputs

Arguments:

--input: Accepts either a single image file path or a directory path. If it's a file, the script will process that image only. If it's a directory, the script will recursively scan for .png, .jpg, and .jpeg files and process all of them.

--latent: (Optional) Path to the latent code file (.npy). If not provided, random latent values will be generated with a fixed seed for reproducibility.

--out-dir: Output directory where the restored images will be saved.

  • Evaluate the quantized model
# eval fp32
python onnx_eval.py \
      --onnx psfrgan_nchw_fp32.onnx \
      --latent latent.npy \
      --hq-dir datasets/celeba_512_validation \
      --lq-dir datasets/celeba_512_validation_lq \
      --out-dir outputs/fp32 -clean

# eval int8
python onnx_eval.py \
      --onnx psfrgan_nhwc_int8.onnx \
      --latent latent.npy \
      --hq-dir datasets/celeba_512_validation \
      --lq-dir datasets/celeba_512_validation_lq \
      --out-dir outputs/int8 -clean

Performance

Model PSNR(↑) MS_SSIM(↑) FID(↓)
PSFRGAN (fp32) 25.27 0.8500 21.99
PSFRGAN (int8) 25.27 0.8487 24.34

@inproceedings{ChenPSFRGAN,
    author = {Chen, Chaofeng and Li, Xiaoming and Lingbo, Yang and Lin, Xianhui and Zhang, Lei and Wong, Kwan-Yee~K.},
    title = {Progressive Semantic-Aware Style Transformation for Blind Face Restoration},
    Journal = {IEEE Conference on Computer Vision and Pattern Recognition (CVPR)},
    year = {2021}
}
Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Collection including amd/ryzenai-psfrgan