Update readme
Browse files
README.md
CHANGED
|
@@ -1,110 +1,110 @@
|
|
| 1 |
-
---
|
| 2 |
-
license: apache-2.0
|
| 3 |
-
tags:
|
| 4 |
-
- RyzenAI
|
| 5 |
-
- Int8 quantization
|
| 6 |
-
- Face Restoration
|
| 7 |
-
- PSFRGAN
|
| 8 |
-
- ONNX
|
| 9 |
-
- Computer Vision
|
| 10 |
-
metrics:
|
| 11 |
-
- PSNR
|
| 12 |
-
- MS_SSIM
|
| 13 |
-
- FID
|
| 14 |
-
---
|
| 15 |
-
|
| 16 |
-
# PSFRGAN for face restoration
|
| 17 |
-
|
| 18 |
-
The model operates at 512x512 resolution and is particularly effective at restoring faces with various degradations including blur, noise,
|
| 19 |
-
|
| 20 |
-
It was introduced in the paper _Progressive Semantic-Aware Style Transformation for Blind Face Restoration_ by Chaofeng Chen et al. at CVPR 2021.
|
| 21 |
-
|
| 22 |
-
We have developed a modified version optimized for [AMD Ryzen AI](https://onnxruntime.ai/docs/execution-providers/Vitis-AI-ExecutionProvider.html).
|
| 23 |
-
|
| 24 |
-
## Model description
|
| 25 |
-
|
| 26 |
-
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.
|
| 27 |
-
|
| 28 |
-
## Intended uses & limitations
|
| 29 |
-
|
| 30 |
-
You can use this model for face restoration tasks. See the [model hub](https://huggingface.co/models?search=amd/ryzenai-psfrgan) for all available psfrgan models.
|
| 31 |
-
|
| 32 |
-
## How to use
|
| 33 |
-
|
| 34 |
-
### Installation
|
| 35 |
-
|
| 36 |
-
```bash
|
| 37 |
-
# inference only
|
| 38 |
-
pip install -r requirements-infer.txt
|
| 39 |
-
# inference & evaluation
|
| 40 |
-
pip install -r requirements-eval.txt
|
| 41 |
-
```
|
| 42 |
-
|
| 43 |
-
### Data Preparation (optional: for
|
| 44 |
-
|
| 45 |
-
1. Download `CelebA-Test (LQ)` and `CelebA-Test (HQ)` from [GFP-GAN homepage](https://xinntao.github.io/projects/gfpgan)
|
| 46 |
-
2. Organize the dataset directory as follows:
|
| 47 |
-
|
| 48 |
-
```Plain
|
| 49 |
-
βββ datasets
|
| 50 |
-
βββ celeba_512_validation
|
| 51 |
-
βββ 00000000.png
|
| 52 |
-
βββ ...
|
| 53 |
-
βββ celeba_512_validation_lq
|
| 54 |
-
βββ 00000000.png
|
| 55 |
-
βββ ...
|
| 56 |
-
|
| 57 |
-
```
|
| 58 |
-
|
| 59 |
-
### Test & Evaluation
|
| 60 |
-
|
| 61 |
-
- Run inference on images
|
| 62 |
-
|
| 63 |
-
```bash
|
| 64 |
-
python onnx_inference.py --onnx psfrgan_nchw_fp32.onnx --latent latent.npy --input /Path/To/Image --out-dir outputs
|
| 65 |
-
python onnx_inference.py --onnx psfrgan_nhwc_int8.onnx --latent latent.npy --input /Path/To/Image --out-dir outputs
|
| 66 |
-
```
|
| 67 |
-
|
| 68 |
-
**Arguments:**
|
| 69 |
-
|
| 70 |
-
- `--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.
|
| 71 |
-
- `--latent`: (Optional) Path to the latent code file (.npy). If not provided, random latent values will be generated with a fixed seed for reproducibility.
|
| 72 |
-
- `--out-dir`: Output directory where the restored images will be saved.
|
| 73 |
-
|
| 74 |
-
- Evaluate the quantized model
|
| 75 |
-
|
| 76 |
-
```bash
|
| 77 |
-
# eval fp32
|
| 78 |
-
python onnx_eval.py \
|
| 79 |
-
--onnx psfrgan_nchw_fp32.onnx \
|
| 80 |
-
--latent latent.npy \
|
| 81 |
-
--hq-dir datasets/celeba_512_validation \
|
| 82 |
-
--lq-dir datasets/celeba_512_validation_lq \
|
| 83 |
-
--out-dir outputs/fp32 -clean
|
| 84 |
-
|
| 85 |
-
# eval int8
|
| 86 |
-
python onnx_eval.py \
|
| 87 |
-
--onnx psfrgan_nhwc_int8.onnx \
|
| 88 |
-
--latent latent.npy \
|
| 89 |
-
--hq-dir datasets/celeba_512_validation \
|
| 90 |
-
--lq-dir datasets/celeba_512_validation_lq \
|
| 91 |
-
--out-dir outputs/int8 -clean
|
| 92 |
-
```
|
| 93 |
-
|
| 94 |
-
### Performance
|
| 95 |
-
|
| 96 |
-
| Model | PSNR(β) | MS_SSIM(β) | FID(β) |
|
| 97 |
-
| -------------- | ------- | ---------- | ------ |
|
| 98 |
-
| PSFRGAN (fp32) | 25.27 | 0.8500 | 21.99 |
|
| 99 |
-
| PSFRGAN (int8) | 25.27 | 0.8487 | 24.34 |
|
| 100 |
-
|
| 101 |
-
---
|
| 102 |
-
|
| 103 |
-
```bibtex
|
| 104 |
-
@inproceedings{ChenPSFRGAN,
|
| 105 |
-
author = {Chen, Chaofeng and Li, Xiaoming and Lingbo, Yang and Lin, Xianhui and Zhang, Lei and Wong, Kwan-Yee~K.},
|
| 106 |
-
title = {Progressive Semantic-Aware Style Transformation for Blind Face Restoration},
|
| 107 |
-
Journal = {IEEE Conference on Computer Vision and Pattern Recognition (CVPR)},
|
| 108 |
-
year = {2021}
|
| 109 |
-
}
|
| 110 |
-
```
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
tags:
|
| 4 |
+
- RyzenAI
|
| 5 |
+
- Int8 quantization
|
| 6 |
+
- Face Restoration
|
| 7 |
+
- PSFRGAN
|
| 8 |
+
- ONNX
|
| 9 |
+
- Computer Vision
|
| 10 |
+
metrics:
|
| 11 |
+
- PSNR
|
| 12 |
+
- MS_SSIM
|
| 13 |
+
- FID
|
| 14 |
+
---
|
| 15 |
+
|
| 16 |
+
# PSFRGAN for face restoration
|
| 17 |
+
|
| 18 |
+
The model operates at 512x512 resolution and is particularly effective at restoring faces with various degradations including blur, noise, and low resolution.
|
| 19 |
+
|
| 20 |
+
It was introduced in the paper _Progressive Semantic-Aware Style Transformation for Blind Face Restoration_ by Chaofeng Chen et al. at CVPR 2021.
|
| 21 |
+
|
| 22 |
+
We have developed a modified version optimized for [AMD Ryzen AI](https://onnxruntime.ai/docs/execution-providers/Vitis-AI-ExecutionProvider.html).
|
| 23 |
+
|
| 24 |
+
## Model description
|
| 25 |
+
|
| 26 |
+
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.
|
| 27 |
+
|
| 28 |
+
## Intended uses & limitations
|
| 29 |
+
|
| 30 |
+
You can use this model for face restoration tasks. See the [model hub](https://huggingface.co/models?search=amd/ryzenai-psfrgan) for all available psfrgan models.
|
| 31 |
+
|
| 32 |
+
## How to use
|
| 33 |
+
|
| 34 |
+
### Installation
|
| 35 |
+
|
| 36 |
+
```bash
|
| 37 |
+
# inference only
|
| 38 |
+
pip install -r requirements-infer.txt
|
| 39 |
+
# inference & evaluation
|
| 40 |
+
pip install -r requirements-eval.txt
|
| 41 |
+
```
|
| 42 |
+
|
| 43 |
+
### Data Preparation (optional: for evaluation)
|
| 44 |
+
|
| 45 |
+
1. Download `CelebA-Test (LQ)` and `CelebA-Test (HQ)` from [GFP-GAN homepage](https://xinntao.github.io/projects/gfpgan)
|
| 46 |
+
2. Organize the dataset directory as follows:
|
| 47 |
+
|
| 48 |
+
```Plain
|
| 49 |
+
βββ datasets
|
| 50 |
+
βββ celeba_512_validation
|
| 51 |
+
βββ 00000000.png
|
| 52 |
+
βββ ...
|
| 53 |
+
βββ celeba_512_validation_lq
|
| 54 |
+
βββ 00000000.png
|
| 55 |
+
βββ ...
|
| 56 |
+
|
| 57 |
+
```
|
| 58 |
+
|
| 59 |
+
### Test & Evaluation
|
| 60 |
+
|
| 61 |
+
- Run inference on images
|
| 62 |
+
|
| 63 |
+
```bash
|
| 64 |
+
python onnx_inference.py --onnx psfrgan_nchw_fp32.onnx --latent latent.npy --input /Path/To/Image --out-dir outputs
|
| 65 |
+
python onnx_inference.py --onnx psfrgan_nhwc_int8.onnx --latent latent.npy --input /Path/To/Image --out-dir outputs
|
| 66 |
+
```
|
| 67 |
+
|
| 68 |
+
**Arguments:**
|
| 69 |
+
|
| 70 |
+
- `--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.
|
| 71 |
+
- `--latent`: (Optional) Path to the latent code file (.npy). If not provided, random latent values will be generated with a fixed seed for reproducibility.
|
| 72 |
+
- `--out-dir`: Output directory where the restored images will be saved.
|
| 73 |
+
|
| 74 |
+
- Evaluate the quantized model
|
| 75 |
+
|
| 76 |
+
```bash
|
| 77 |
+
# eval fp32
|
| 78 |
+
python onnx_eval.py \
|
| 79 |
+
--onnx psfrgan_nchw_fp32.onnx \
|
| 80 |
+
--latent latent.npy \
|
| 81 |
+
--hq-dir datasets/celeba_512_validation \
|
| 82 |
+
--lq-dir datasets/celeba_512_validation_lq \
|
| 83 |
+
--out-dir outputs/fp32 -clean
|
| 84 |
+
|
| 85 |
+
# eval int8
|
| 86 |
+
python onnx_eval.py \
|
| 87 |
+
--onnx psfrgan_nhwc_int8.onnx \
|
| 88 |
+
--latent latent.npy \
|
| 89 |
+
--hq-dir datasets/celeba_512_validation \
|
| 90 |
+
--lq-dir datasets/celeba_512_validation_lq \
|
| 91 |
+
--out-dir outputs/int8 -clean
|
| 92 |
+
```
|
| 93 |
+
|
| 94 |
+
### Performance
|
| 95 |
+
|
| 96 |
+
| Model | PSNR(β) | MS_SSIM(β) | FID(β) |
|
| 97 |
+
| -------------- | ------- | ---------- | ------ |
|
| 98 |
+
| PSFRGAN (fp32) | 25.27 | 0.8500 | 21.99 |
|
| 99 |
+
| PSFRGAN (int8) | 25.27 | 0.8487 | 24.34 |
|
| 100 |
+
|
| 101 |
+
---
|
| 102 |
+
|
| 103 |
+
```bibtex
|
| 104 |
+
@inproceedings{ChenPSFRGAN,
|
| 105 |
+
author = {Chen, Chaofeng and Li, Xiaoming and Lingbo, Yang and Lin, Xianhui and Zhang, Lei and Wong, Kwan-Yee~K.},
|
| 106 |
+
title = {Progressive Semantic-Aware Style Transformation for Blind Face Restoration},
|
| 107 |
+
Journal = {IEEE Conference on Computer Vision and Pattern Recognition (CVPR)},
|
| 108 |
+
year = {2021}
|
| 109 |
+
}
|
| 110 |
+
```
|