AI Personal Learning
and practical guidance

CodeFormer: image and video facial restoration, old photo restoration, offers one-click deployment version

CodeFormer General Introduction

CodeFormer is a codebase for robust blind face repair, developed by a team of researchers at S-Lab, Nanyang Technological University and presented at NeurIPS 2022. The project leverages the Codebook Lookup Transformer technology and aims to enhance the restoration of faces in images, especially when dealing with low-quality or corrupted images.CodeFormer provides a wide range of features, including face restoration, colorization, and patching, for a variety of image processing needs. In addition, the program supports video input and offers easy-to-use online demos, pre-trained models, and detailed instructions for use.

Instructions for use must be read strictly, otherwise it will not work properly. Formally sold as old photo restoration business, you need a simple PS base, otherwise you can not achieve the same effect online.

 

CodeFormer: Image & Video Facial Recovery | Facial Recovery | Old Photo Restoration, Provides One-Click Deployment-1


 

CodeFormer: Image & Video Facial Recovery | Facial Recovery | Old Photo Restoration, Provides One-Click Deployment-1

CodeFormer Tries to Enhance Old Photos / Fix AI Portraits

 

CodeFormer: Image & Video Face Recovery | Face Recovery | Old Photo Restoration, provides one-click deployment-2

CodeFormer Face Repair

 

CodeFormer: Image & Video Facial Recovery|Facial Recovery|Old Photo Restoration, Provides One-Click Deployment-3

CodeFormer Facial Color Enhancement and Restoration

 

CodeFormer: Image & Video Face Recovery | Face Recovery | Old Photo Restoration, Provides One-Click Deployment-4

CodeFormer Face Repair

 

 

CodeFormer Feature List

  • face restoration: Enhance the clarity and detail of low-quality or corrupted face images with codebook lookup converter technology.
  • Image coloring: Add natural color to black and white or faded images.
  • image repair: Repair missing parts of an image to make it complete.
  • Video Processing: Supports repair and enhancement of faces in videos.
  • Online Demo: An online demo function is provided so that users can experience the restoration directly in their browsers.

 

 

CodeFormer Help

Installation process

  1. Cloning Codebase::
    git clone https://github.com/sczhou/CodeFormer
    cd CodeFormer
    

     

  2. Create and activate a virtual environment::
    conda create -n codeformer python=3.8 -y
    conda activate codeformer
    

     

  3. Installation of dependencies::
    pip install -r requirements.txt
    python basicsr/setup.py develop
    conda install -c conda-forge dlib
    

     

  4. Download pre-trained model::
    python scripts/download_pretrained_models.py facelib
    python scripts/download_pretrained_models.py dlib
    python scripts/download_pretrained_models.py CodeFormer
    

     

Usage Process

  1. Preparing test data: Place the test image into the inputs/TestWhole folder. If you need to test cropped and aligned face images, you can place them in the inputs/cropped_faces folder.
  2. Run the inference code::
    python inference_codeformer.py --input_path inputs/TestWhole --output_path results
    

    This command will process the inputs/TestWhole folder with all the images in it and save the results in the results folder.

Functional operation flow

  1. face restoration::
    • Place the image to be restored into the inputs/TestWhole Folder.
    • Run the inference code to generate the repaired image.
  2. Image coloring::
    • Place a black and white image into the inputs/TestWhole Folder.
    • utilization inference_colorization.py Script for coloring.
  3. image repair::
    • Place the image to be patched into the inputs/TestWhole Folder.
    • utilization inference_inpainting.py Scripts for patching.
  4. Video Processing::
    • Place the video file into the specified folder.
    • Run the inference code to process the faces in the video.

 

Facial restoration (cropping and alignment of the face)

# For cropped and aligned faces
python inference_codeformer.py -w 0.5 --has_aligned --input_path [input folder]

Overall Image Enhancement

# For whole image
# Add '---bg_upsampler realesrgan' to enhance the background regions with Real-ESRGAN
# Add '--face_upsample' to further upsample restored face with Real-ESRGAN
python inference_codeformer.py -w 0.7 --input_path [image folder/image path]

video enhancement

# For video clips
python inference_codeformer.py --bg_upsampler realesrgan --face_upsample -w 1.0 --input_path

 

The fidelity weight w is located in [0, 1]. In general, smaller w tends to produce higher quality results, while larger w produces higher fidelity results.

The results will be saved in the results folder.

 

CodeFormer One-Click Deployment Kit

Chief AI Sharing CircleThis content has been hidden by the author, please enter the verification code to view the content
Captcha:
Please pay attention to this site WeChat public number, reply "CAPTCHA, a type of challenge-response test (computing)", get the verification code. Search in WeChat for "Chief AI Sharing Circle"or"Looks-AI"or WeChat scanning the right side of the QR code can be concerned about this site WeChat public number.

AI Easy Learning

The layman's guide to getting started with AI

Help you learn how to utilize AI tools at a low cost and from a zero base.AI, like office software, is an essential skill for everyone. Mastering AI will give you an edge in your job search and half the effort in your future work and studies.

View Details>
May not be reproduced without permission:Chief AI Sharing Circle " CodeFormer: image and video facial restoration, old photo restoration, offers one-click deployment version

Chief AI Sharing Circle

Chief AI Sharing Circle specializes in AI learning, providing comprehensive AI learning content, AI tools and hands-on guidance. Our goal is to help users master AI technology and explore the unlimited potential of AI together through high-quality content and practical experience sharing. Whether you are an AI beginner or a senior expert, this is the ideal place for you to gain knowledge, improve your skills and realize innovation.

Contact Us
en_USEnglish