GFPGAN
GFPGAN v1.4 (Wang et al., Tencent ARC, CVPR 2021): restores a degraded face (an aligned 512 x 512 crop) with a pretrained StyleGAN2 face generator as prior; the classic face restorer of upscaling tools. Apache-2.0 code and weights.
experimental Fork of TencentARC/GFPGAN@7552a77 · backends: portable, kernels
- Paper Towards Real-World Blind Face Restoration with Generative Facial Prior CVPR 2021 · first released 11 Jan 2021
Checkpoint gfpgan-v1.4
Paper 2021 Added in 0.2.0
Use it
pip install fastforks Lean install with only what this model needs: pip install fastforks-core
from fastforks import restoration
model = restoration.load("gfpgan-v1.4") # kernels on a supported GPU, else portable PyTorch
result = model(image)
result.image
result.backend # what ran: mode, device, dtype, kernels fastforks bench gfpgan-v1.4 Times the model on this machine. load(…, mode="portable") or mode="kernels" picks a backend; usage guide.
Speed and memory
Every backend on one GPU (RTX 5060 Ti 16 GB) and the same input, the authors’ code included. Kernels runs fp16. Portable runs fp16 on CUDA.
Input: synthetic, 512x512 (the task’s standard size)
| Backend | dtype | Time per call (ms) | vs original fp16 | Peak memory allocated / reserved | Load (s) | First call (s) |
|---|---|---|---|---|---|---|
| Original fp32 | fp32 | not measured | – | – | – | – |
| Original fp16.half() on 1 modules, fp16 inputs; upstream GFPGANer.enhance on the aligned face, float32, random noise per call | fp16 | 21.9 | – | 563 MiB/670 MiB | 0.8 | 0.03 |
| Portable fp32 | fp32 | not measured | – | – | – | – |
| Portable | fp16 | 21.2 | 1.0× | 505 MiB/528 MiB | 1.0 | 0.25 |
| Kernels | fp16 | 18.0 | 1.2× | 473 MiB/530 MiB | 0.8 | 0.07 |
| Portable + torch.compile | 12.5 | 1.8× | 360 MiB/428 MiB | 27 (build) | – | |
| TensorRT fp16 | fp16 | 15.8 | 1.4× | 400 MiBenginenot comparable | 115 (build) | – |
Measured on RTX 5060 Ti 16 GB, torch 2.14.1+cu130, 2026-11-14. First call, 3 warm-up, peak reset, median of 3 rounds x median of 5. Ratios divide two
times of this table (same GPU, same input). Original fp16 is the authors’ own precision option, else torch.autocast. torch.compile and TensorRT: build time instead of load time. TensorRT memory (engine, not comparable) is the GPU memory the engine took, read from the driver because TensorRT allocates outside PyTorch, so it can't be compared with the PyTorch peaks of the other rows.
Other devices
| Device | Backend | dtype | ms / call | Peak memory | Output vs reference | Input |
|---|---|---|---|---|---|---|
| Apple M1 Pro 16 GB MPS, torch 2.14.1, 2026-11-14 | Original | fp32 | 172 | 2,871 MiB process | – | 512x512 |
| Portable | fp16 | 138 | 1,982 MiB process | matches | 512x512 | |
| Portable | fp32 | 153 | 1,954 MiB process | matches | 512x512 | |
| Kernels | fp16 | not implemented | – | 512x512 | ||
CUDA memory is torch’s peak allocated / reserved; Apple has no such counter, so the Mac rows show the process footprint (weights, Python and torch included). “Output vs reference” compares the device’s output with the stored golden output under the card’s tolerance; – = not checked on that device. Kernels “not implemented” = no kernels for this model on that backend yet: it runs portable there.
Licence and weights
Commercial use allowed
- Code
- Apache-2.0 LICENSE
- Weights
- Apache-2.0 source
- Training data
-
- Flickr-Faces-HQ (FFHQ, 70k face images) CC-BY-NC-SA-4.0, non-commercial
Our reading of the licences, not legal advice.
Weights
GFPGANv1.4.pth 349 MB· hosted on GitHubfastforks downloads and checks these files on first use (fastforks download gfpgan-v1.4).
Accuracy
The test set through the authors’ code and through ours: same checkpoint, same protocol. The distance between the original’s fp32 and fp16 runs is what half precision alone costs; our runs should stay within it.
Accuracy not measured for gfpgan-v1.4.
Closeness to the original
Beyond the test-set scores: the raw output of ours against the original’s fp32 output on the same input, pixel by pixel. CPU, float32: max |diff| <= 6.3e-06 vs the original. GPU, float16 (the default), portable and kernels: mean |diff| <= 0.00051 and p99 <= 0.0022 (absolute error of the output image).
| Check | Tolerance | Measured |
|---|---|---|
| CPU fp32, max |diff| | ≤ 0.0000063 | not recorded |
| GPU default dtypes, mean |diff| | ≤ 0.00051 | 0.00034 |
| GPU default dtypes, p99 |diff| | ≤ 0.0022 | 0.00144 |
Recorded for gfpgan-v1.4 on RTX 5060 Ti, torch 2.14.1+cu130, 2026-11-14, with these kernels: cudnn_hacc
Details
GFPGAN v1.4 (Wang et al., CVPR 2021): blind face restoration with a generative facial prior: a U-Net encoder whose features modulate (spatial feature transform) a pretrained StyleGAN2 face generator. Input: an aligned 512 x 512 face crop (FFHQ alignment); detecting, aligning and pasting the face back are not part of the model.
- Input / output
- Input: one RGB image. Output: the restored (upscaled) image,
model.scalex the input size, RGB in [0, 1].What the numbers mean, and which models need the camera focal length
tile=runs large images in overlapping tiles (as ComfyUI). - Input size
- any H x W >= 512, padded to a multiple of 32; tested up to 512x512 (508 MiB allocated)
- Outputs
image- CUDA kernels
cudnn_haccconvolutions with fp16 accumulation (cuDNN)
- Apple (MPS)
- fp32, fp16
Limitations
- No accuracy measurement: blind face restoration is scored on CelebA-Test / LFW / WebPhoto (FID, NIQE, identity distance), which are not part of the evaluation data here; tiers are compared by output parity and speed only.
Full reference, generated from the repository
GFPGAN v1.4 (Wang et al., Tencent ARC, CVPR 2021): restores a degraded face (an aligned 512 x 512 crop) with a pretrained StyleGAN2 face generator as prior; the classic face restorer of upscaling tools. Apache-2.0 code and weights.
Commercial use: yes.
| variant | input | backend | time (ms) | peak memory (MiB, allocated / reserved) |
|---|---|---|---|---|
gfpgan-v1.4 | synthetic (512x512) | original portable kernels portable + torch.compile TensorRT fp16 | 21.9 21.2 18.0 12.5 15.8 | 563 / 670 505 / 528 473 / 530 360 / 428 609 / 644 |
Details
- Original code: https://github.com/TencentARC/GFPGAN at
7552a7791caa - Code licence: Apache-2.0 (permissive); files:
LICENSE - Weights licence: Apache-2.0
- Licence evidence: https://github.com/TencentARC/GFPGAN/blob/7552a7791caad982045a7bbe5634bbf1cd5c8679/LICENSE ; https://github.com/TencentARC/GFPGAN/blob/7552a7791caad982045a7bbe5634bbf1cd5c8679/README.md (weights: https://github.com/TencentARC/GFPGAN/releases/tag/v1.3.0)
- Training data: Flickr-Faces-HQ (FFHQ, 70k face images) (Paper Sec. 4.1: FFHQ (70 000 faces, resized to 512 x 512) with synthetic degradations (blur, downsampling, noise, JPEG); the StyleGAN2 prior is also trained on FFHQ.)
- Kernel libraries:
cudnn_hacc - Variants:
gfpgan-v1.4 - Outputs: image
- Input size: any H x W >= 512, padded to a multiple of 32
- Tested up to (portable, fp16, RTX 5060 Ti 16 GB):
gfpgan-v1.4512x512 (0.5 GiB peak allocated, 0.6 reserved) gfpgan-v1.4512x512, first call: portable + torch.compile 27 s (cold Inductor cache), TensorRT fp16 115 s (ONNX + engine).gfpgan-v1.4original 512x512: .half() on 1 modules, fp16 inputs; upstream GFPGANer.enhance on the aligned face, float32, random noise per callgfpgan-v1.4load / first call: original 0.86 s / 0.333 s, portable 1.04 s / 0.254 s, kernels 0.78 s / 0.073 s- Protocol, first call, 3 warm-up, peak reset, median of 3 rounds x median of 5
Parity
CPU, float32: max |diff| <= 6.3e-06 vs the original. GPU, float16 (the default), portable and kernels: mean |diff| <= 0.00051 and p99 <= 0.0022 (absolute error of the output image).
| variant | kernels error vs original, mean / p99 | GPU, torch | kernels used |
|---|---|---|---|
gfpgan-v1.4 | 0.00034 / 0.00144 | RTX 5060 Ti, torch 2.14.1+cu130 | cudnn_hacc@cudnn92400 |
Limitations
- No accuracy measurement: blind face restoration is scored on CelebA-Test / LFW / WebPhoto (FID, NIQE, identity distance), which are not part of the evaluation data here; tiers are compared by output parity and speed only.
Example output
No example rendered for this checkpoint yet.