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)Removed CodeFormer dependency to streamline the codebase.
- –Removed CodeFormer integration from the project
Added inference code support for RestoreFormer and CodeFormer models.
- –Added RestoreFormer inference code implementation
- –Added CodeFormer inference code implementation
- –Updated Cog predict functionality
Fixed import issues and added multi-GPU support with improved face segmentation.
- –Fixed BasicSR losses import error
- –Updated facelib library and improved face pasting using segmentation
- –Added device parameter to GFPGANer class for multi-GPU support
See how people are using GFPGAN
Related Repositories
Discover similar tools and frameworks used by developers
Stanford Alpaca
Research project that fine-tunes LLaMA models to follow instructions using self-generated training data.
Model Context Protocol Servers
Reference implementations for LLM tool and data integration.
MediaPipe
Graph-based framework for streaming media ML pipelines.
ONNX Runtime
Cross-platform engine for optimized ONNX model execution.
LightRAG
Graph-based retrieval framework for structured RAG reasoning.