GFPGAN: Face restoration using generative priors
PyTorch framework for blind face restoration using StyleGAN2 priors.
Learn more about GFPGAN
GFPGAN is a PyTorch-based face restoration framework that applies generative priors from pretrained StyleGAN2 models to restore degraded facial images. The approach uses a two-stage pipeline incorporating face detection, alignment, and GAN-based restoration with local and global feature extraction. It handles blind restoration scenarios where the degradation type and severity are unknown, working with images ranging from very low to high quality. The tool is deployed as a Python package with optional CUDA support and integrates with complementary restoration models for background enhancement.
Blind Degradation Restoration
Leverages pretrained StyleGAN2 facial priors to restore images without knowing degradation type or parameters. Handles mixed artifacts including compression, noise, blur, and low resolution in a single pass.
Modular Two-Stage Pipeline
Separates face restoration from background enhancement through Real-ESRGAN integration. Multiple model versions (V1.3, V1.4) provide configurable trade-offs between photorealism and detail preservation.
Optional CUDA Dependencies
Pure PyTorch implementation runs on CPU without mandatory CUDA extensions for cross-platform deployment. Accessible through multiple interfaces including Python package, Colab notebooks, and hosted APIs.
from gfpgan import GFPGANer
restorer = GFPGANer(
model_path='experiments/pretrained_models/GFPGANv1.3.pth',
upscale=2,
arch='clean',
channel_multiplier=2
)
input_img = cv2.imread('degraded_face.jpg', cv2.IMREAD_COLOR)
cropped_faces, restored_faces, restored_img = restorer.enhance(
input_img, has_aligned=False, only_center_face=False, paste_back=True
)
cv2.imwrite('restored_face.jpg', restored_img)CodeFormer dependency removed; projects relying on it must vendor or switch to alternative face restoration models.
- –Remove CodeFormer integration from the codebase to reduce dependencies.
- –Audit your pipeline if you depend on CodeFormer; GFPGAN now ships without it.
Adds inference support for RestoreFormer and CodeFormer models; updates Cog prediction interface.
- –Use new inference codes to run RestoreFormer or CodeFormer models for face restoration tasks.
- –Review updated Cog predict implementation if deploying via Replicate or similar container platforms.
Maintenance release fixing BasicSR import errors and adding multi-GPU device selection; no breaking changes reported.
- –Update to latest facelib for segmentation-based face pasting; verify face restoration quality in your pipeline.
- –Pass device parameter to GFPGANer constructor to control GPU placement in multi-GPU environments.
Related Repositories
Discover similar tools and frameworks used by developers
deepface
Python library wrapping multiple face recognition deep learning models.
tesseract
LSTM-based OCR engine supporting 100+ languages.
stable-diffusion
CLIP-conditioned latent diffusion model for text-to-image synthesis.
context7
MCP server delivering version-specific library documentation to LLMs.
presentation-ai
AI-powered slide generator with multi-model integration and themes.