Skip to main content

Overview

Real-ESRGAN integrates with GFPGAN (Generative Facial Prior GAN) to provide enhanced face restoration. This combination uses Real-ESRGAN for overall image super-resolution and GFPGAN to specifically enhance facial details.

How It Works

When face enhancement is enabled:
  1. Detection: GFPGAN detects faces in the image
  2. Enhancement: Each detected face is enhanced using GFPGANv1.3
  3. Background: Real-ESRGAN upscales the background
  4. Composition: Enhanced faces are pasted back into the upscaled background
This approach ensures both high-quality face restoration and overall image super-resolution.

Quick Start

1

Install Dependencies

Install GFPGAN and facexlib:
2

Run with Face Enhancement

3

Check Results

The output image will have enhanced faces with upscaled background.

Usage Examples

Basic Face Enhancement

Advanced Usage

Compatible Models

GFPGAN Integration Details

Model Information

GFPGANv1.3
GFPGAN version 1.3 is automatically downloaded and used for face enhancement.Download URL:
clean
Uses the ‘clean’ architecture variant of GFPGAN.
2
Set to 2 for optimal quality.
RealESRGAN
Real-ESRGAN is used as the background upsampler, ensuring consistent quality across the entire image.

Face Detection Parameters

  • has_aligned: Set to False as input faces are not pre-aligned
  • only_center_face: Set to False to enhance all detected faces
  • paste_back: Set to True to composite faces back into the upscaled image

Use Cases

Portrait Photography

Enhance professional or casual portraits with improved facial details.

Old Family Photos

Restore and upscale vintage family photographs. Use tiling for large scans.

Group Photos

Enhance all faces in group photos - GFPGAN detects and enhances each face individually.

Low-Resolution Photos

Upscale and enhance low-resolution images from older cameras or compressed sources.

Video Frames with Faces

Face enhancement significantly increases processing time for videos. Consider processing only key frames or using face enhancement selectively.

Performance Considerations

Processing Time

Face enhancement adds overhead:
  • Without face enhancement: ~0.1-0.5s per image (depends on size and GPU)
  • With face enhancement: ~0.5-2s per image (depends on number of faces)
Batch ProcessingProcess multiple images in batch mode for better efficiency:

Memory Usage

CUDA Out of MemoryFace enhancement increases memory usage. If you encounter memory errors:
  1. Use tiling:
  2. Use a smaller model:
  3. Process smaller batches or individual images

GPU Selection

For multi-GPU systems:

Comparison Examples

Results:
  • Without: Good overall upscaling, but faces may lack fine details
  • With: Sharper facial features, better skin texture, enhanced eye details

Tips for Best Results

Input Image QualityBetter source images = better results:
  • Use the highest resolution source available
  • Avoid heavily compressed images when possible
  • Ensure faces are reasonably visible in the input
Face SizeFace enhancement works best when:
  • Faces are at least 64x64 pixels in the input
  • Faces are clearly visible (not too dark or blurry)
  • Faces are front-facing or at slight angles
For very small faces, upscale without face enhancement first, then apply face enhancement to the upscaled result.
Multiple FacesGFPGAN automatically detects and enhances all faces in the image:
No special configuration needed for multiple faces.
Output FormatUse PNG for best quality preservation:

Troubleshooting

Install the required dependencies:
If you still encounter issues:
Check if you’re using a compatible model:Compatible:
  • RealESRGAN_x4plus
  • RealESRNet_x4plus
  • RealESRGAN_x2plus
  • realesr-general-x4v3
Not Compatible:
  • RealESRGAN_x4plus_anime_6B ✗ (automatically disabled)
  • realesr-animevideov3 ✗ (automatically disabled)
This can happen with heavily compressed or very low-quality inputs. Try:
  1. Use a higher quality source image
  2. Try without face enhancement if the result is too aggressive
  3. Use RealESRNet_x4plus for smoother results:
GFPGAN may miss faces that are:
  • Too small (< 64x64 pixels)
  • At extreme angles
  • Partially occluded
  • Very dark or blurry
Solutions:
  1. Pre-crop and process faces individually
  2. Manually adjust brightness/contrast before processing
  3. Try upscaling first without face enhancement, then apply face enhancement
Face enhancement requires additional memory. Solutions:
  1. Use tiling:
  2. Use smaller model:
  3. Process images individually instead of batch processing

Standalone GFPGAN

For more control over face enhancement, you can use GFPGAN directly:
See the GFPGAN repository for more options.

GFPGAN Project

Official GFPGAN repository

General Images

Learn about models for real-world photos

Basic Inference

Complete reference for inference options