This project utilizes the GFPGAN (Generative Facial Prior-Generative Adversarial Network) and Real-ESRGAN models to upscale and restore images, improving the quality of low-resolution images with a focus on human faces.
The application enhances low-resolution images using advanced machine learning models, primarily focusing on enhancing facial features in images but also capable of general image upscaling. It integrates models like SRVGGNetCompact for image super-resolution and GFPGANer for facial enhancements.
To set up this project, you will need Python installed on your system. You can then install the required dependencies.
-
Clone the repository:
git clone <repository-url> cd <repository-folder>
-
Install the required Python libraries:
pip install -r requirements.txt
. -
Download the necessary model files by running the script or manually downloading them into your project directory:
realesr-general-x4v3.pth
GFPGANv1.2.pth
GFPGANv1.3.pth
GFPGANv1.4.pth
RestoreFormer.pth
To run the application: python app.py
.
This will launch a Gradio interface where you can upload an image, select the enhancement version, and specify the rescaling factor to enhance the image.
- Image Upscaling: Upscales images using Real-ESRGAN.
- Facial Enhancement: Enhances facial features in images using GFPGAN models.
- Flexible Scaling: Allows specifying the scaling factor for upscaling the image.
- Interactive UI: Provides an easy-to-use Gradio interface to interact with the models.
- Python 3.8+
- torch
- torchvision
- opencv-python
- gradio
- realesrgan
- gfpgan
- basicsr
Configuration involves setting up the models and their paths correctly, as well as ensuring all dependencies are installed. The script auto-downloads models if they're not present in the directory.
Common issues:
- Memory errors due to GPU limits: Try running the script with a smaller tile size or on a system with more GPU resources.
- Model files not found: Ensure all model files are downloaded as per the installation instructions.