What is GFPGAN? How to Use It (Explained)

by Chris Von Wilpert, BBusMan • Last updated November 30, 2023

Expert Verified by Leandro Langeani, BBA

What is GFPGAN?

GFPGAN is a powerful AI tool that helps enhance and restore old or low-quality photos. It's like having a magic wand that can turn old, blurry, grainy images into clear, high-resolution pictures. By using advanced technology called Generative Adversarial Networks (GANs), GFPGAN breathes new life into your cherished memories or historical photographs with just a few clicks.

GFPGAN fast facts

  • GFPGAN breathes new life into old, blurred, or damaged facial images in photographs.

  • It uses advanced AI to precisely restore and bring out facial features, maintaining the original likeness.

  • GFPGAN is open-source, making it free and customizable for users and developers.

  • GFPGAN is safe to use, but always double-check your source and keep privacy in mind.

  • GFPGAN’s community of tech enthusiasts and devs regularly updates GFPGAN's features and models.

A comparison of facial restoration techniques showing the original input and the enhanced outputs using different algorithms, including GFPGAN. Photograph: Suvojit Hore via Analytics Vidhya.

What is GFPGAN for?

GFPGAN, standing for Generative Facial Prior-Generative Adversarial Network, is a specialized tool for digital image processing. Its main job is to make faces and pictures in general look clearer. If you have an old, worn-out photo, GFPGAN can make the faces in that photo look fresh, sharp, and new again.

The way GFPGAN works is pretty smart. It uses AI, or artificial intelligence, to study the details of the faces in these pictures. Then, it carefully fixes them up, focusing on making sure that the facial features like eyes, nose, and mouth look right. It's not just about making the picture clearer — it's also about keeping the original look of the person's face.

The brains behind GFPGAN include some complex computer models that are really good at understanding faces. These models can pick up tiny details and features, which help them restore the face in the photo more accurately. This makes GFPGAN a really useful tool for things like fixing up old family photos, or improving the quality of images where faces don’t look good.

Is GFPGAN free to use?

Yes, GFPGAN is free to use. It's an open-source tool, which means that its code and resources are available for anyone to download and use without any cost. This is a big part of what makes GFPGAN popular in the tech community. People who are interested in image restoration, whether they're hobbyists, researchers, or professionals, can access GFPGAN's code and use it as they wish.

The concept of open-source also implies that users can modify or tweak the GFPGAN code to suit their specific needs. Anyone who knows a bit of coding and AI can customize the tool. This flexibility is great for those who want to experiment or need to adjust it for specific types of images or restoration tasks.

However, it's important to note that while GFPGAN itself is free, you might need some technical skills to use it effectively. Installing and running the tool requires some understanding of programming and possibly setting up certain software environments. But for those who are comfortable with these technical aspects, GFPGAN offers a powerful, cost-effective solution for enhancing facial images in photos.

Is GFPGAN safe to use?

GFPGAN, being an open-source tool, is generally considered safe to use, especially if you're obtaining it from a reliable source like its official repository. Open-source software often benefits from the scrutiny of a large community of developers who can spot and fix security issues. However, like any software, it's important to practice safe usage.

When downloading and installing GFPGAN, ensure you're using the official channels. Downloading from unofficial sources increases the risk of encountering malware or other security risks. Sticking to its official repository minimizes risks.

While using GFPGAN, it's also good to be aware of data privacy, especially if you're working with sensitive or personal images. Since GFPGAN processes images, particularly faces, you should consider where and how these images are stored and handled. If you're using GFPGAN on your own computer, you have more control over this aspect. But if you're using any online demo or cloud-based service associated with GFPGAN, it's wise to check their privacy policy and understand how your data is being used.

CCTV footage of a man before and after enhancement with GFPGAN, highlighting the software's potential use in improving image quality for identification and security purposes. Photograph: Mohammad Sulema via I Love Free Software.

How long should it take for GFPGAN to install?

The installation time for GFPGAN can vary based on several factors like your computer's capabilities, the speed of your internet connection, and the specific steps you're following for installation. Typically, the process involves a few key stages: setting up the right software environment, downloading the source code, and potentially downloading additional dependencies or models.

If you need to set up a software environment using Python or similar tools, this can take some time, especially if you're starting from scratch. Downloading and installing the necessary software packages, like Python, PyTorch, and others mentioned in GFPGAN’s installation guide, can take several minutes to an hour, depending on your internet speed and machine specs.

Next, downloading the GFPGAN code itself is usually quick, as the program isn't very large. However, the time-consuming part might be downloading the pre-trained models if your project requires them. These models can be sizable, and download times will depend on your internet connection.

Lastly, the actual installation and setup of GFPGAN, once all components are downloaded, should be relatively swift, especially if you're familiar with running such installations. If all goes smoothly and your setup is fairly standard, the whole process could take anywhere from 30 minutes to a couple of hours

How to restore damaged photos with GFPGAN?

Restoring damaged photos with GFPGAN involves a few key steps, assuming you've already installed the tool and its dependencies. Here’s a simplified guide:

  1. Prepare your environment: Before you start, make sure your environment is set up correctly. This means having GFPGAN and all its dependent packages installed on your system. If you’re working in a Python environment, ensure you have the correct version of Python and packages like PyTorch installed.
  2. Load your photos: You need to have the photos you want to restore saved on your computer. These should be accessible in a format that GFPGAN can process, like JPEG or PNG. If the photos are physical prints, you’ll need to scan them first.
  3. Run GFPGAN: The process of running GFPGAN varies slightly depending on whether you're using a command line interface or a graphical user interface, like a PyQt5-based image viewer, as mentioned in GFPGAN’s documentation. Typically, you'll run a command that specifies the path to the image you want to restore. This might look something like gfpgan/train.py -opt options/train_gfpgan_v1.yml, where you replace the file paths and options with those relevant to your specific image and restoration needs.
  4. Adjust settings as needed: GFPGAN offers various settings to tweak the restoration process, like the level of detail or how aggressively it tries to repair damage. Experimenting with these settings can help you achieve the best results for your specific photo.
  5. Save and review the output: Once GFPGAN processes your photo, it will output the restored version. Save this image and review it to check the restoration quality. If you're not satisfied, you might want to adjust the settings and try again.

A side-by-side view of a woman's portrait before and after the application of GFPGAN. Photograph: Suvojit Hore via Analytics Vidhya.

Is CodeFormer better than GFPGAN?

When deciding whether CodeFormer or GFPGAN is the better tool for restoring photos, it really boils down to what you need and prefer. GFPGAN is great at fixing up faces in photos, especially if they're blurry or damaged. It's great at making faces look clear and natural. So, if you have old family photos or images where the faces need some TLC, GFPGAN might be your go-to.

CodeFormer has a different angle. It could be better at certain things, like maybe tweaking colors or handling parts of the photo that aren't faces. So, if your photos need a different kind of fix-up, CodeFormer might do the trick. It’s generally more focused on striking a balance of detail, color correction, and handling of non-facial elements.

What is the best way to restore old photos?

For photos where the focus is on facial details, GFPGAN is the  standout choice. GFPGAN specializes in enhancing and repairing faces in images that are blurry, faded, or damaged. It's particularly efficient at maintaining the natural look and feel of the original photo while improving clarity and detail. You just need to scan your old photos into a digital format and let GFPGAN work its magic.

For more extensive or detailed restoration work, software like Adobe Photoshop offers a high degree of control. It's perfect for tackling a wide range of issues, from tears and scratches to color fading. Photoshop allows for precise manual edits, which can be incredibly effective for restoring non-facial details or handling complex damage. 

Sometimes, the best approach is to leave it to the experts, especially for severely damaged or historically significant photos. Professional restorers use a combination of advanced software and expert techniques to bring old photos back to life. They can handle a wide range of issues, including severe tears, water damage, or missing parts. While this option can be more expensive, it's often worth it for the level of skill and attention to detail that professionals provide.

How do you recover old scratched pictures?

Restoring old scratched pictures with GFPGAN as the main tool starts with digitizing your photo. If it’s a physical print, scan it at a high resolution. This step ensures you have a detailed digital version to work with. Once your input image is scanned, you're ready to use GFPGAN, which excels in handling digital images, especially for enhancing facial details.

GFPGAN shines in its ability to improve overall image quality, including reducing the visibility of scratches, particularly on faces. Its AI-driven approach automates much of the restoration process, which can be a big help if you're not experienced with manual photo editing. While GFPGAN is focused on restoring faces, it often enhances the entire photo, making it a useful first step in restoring old images.

After running your photo through GFPGAN, you might find that most of the scratches, especially the less severe ones, are less noticeable. However, for deeper or more prominent scratches, especially those away from facial areas, you might need additional touch-ups. For these, simple photo editing tools can be used for final tweaks. This combined approach of starting with GFPGAN for the heavy lifting and finishing with targeted manual edits  offers a balanced way to restore old, scratched pictures.

An iconic historical photograph of Mahatma Gandhi before and after processing with GFPGAN, illustrating the tool's proficiency in enhancing detail and clarity in aged or degraded images. Photograph: Amal via Medium.

How can I scan a photo for restoration?

If you have a scanner at home, this is a convenient choice. Most modern scanners offer high-resolution settings, which are crucial for detailed restorations. Set your scanner to at least 300 DPI for regular-sized photos — for smaller photos or if you need more detail, go for 600 DPI or higher. Clean both the photo and scanner glass to avoid dust spots. Choose a lossless file format like TIFF to save your scanned image, as this yields better quality than lossy formats like JPEG.

If you don't have a scanner, smartphone scanning apps are a good alternative. Apps like Adobe Scan, CamScanner, or Microsoft Lens use your phone's camera to create high-quality scans. While they might not match the quality of a dedicated scanner, they're surprisingly effective, especially for less damaged photos. Ensure you have good lighting and hold your phone steady to avoid blurs. 

For the best results, especially with very old or damaged photos, consider using a professional scanning service. These services use high-end equipment to produce the best possible digital version of your photo.

Which FPGA aims at developing practical algorithms for real-world face restoration?

An FPGA (Field-Programmable Gate Array) is a type of electronic chip that can be programmed to perform specific tasks. Unlike regular computer chips that have fixed functions, FPGAs are unique because they can be configured by the user after manufacturing. This means they can be tailored to perform specialized tasks very efficiently, making them versatile for various applications.

In the context of image restoration, particularly for restoring faces in real-world scenarios, FPGAs can play a significant role. Their ability to be programmed for specific tasks allows them to efficiently handle the complex computations required for image processing. This includes tasks like enhancing image details, correcting distortions, and improving resolution, all of which are crucial in restoring the quality of damaged or low-resolution images.

While FPGAs have great potential in tasks like image restoration, their actual use depends on the specific requirements of the project and the availability of programming expertise. Due to their customizable nature, FPGAs can offer superior performance for specialized image processing tasks. However, their application in this field is more common in professional or research settings where custom solutions are needed, and alternative solutions like GFPGAN are much more popular when it comes to face restoration.


Make a 7-figure content strategy for less than $7


The 7-figure content strategy we use to grow business's content marketing channel to over $100k per month. Updated for 2024 with the latest AI strategies + apps working now.

"I offered him $100,000... for six months... to execute his content strategy for AppSumo."

- Noah Kagan, CEO of AppSumo