Live Portrait

KwaiVGI

Introduction

LivePortrait is a PyTorch implementation for efficient portrait animation, focusing on stitching and retargeting control. The project is actively updated, and users are encouraged to contribute by reporting bugs or submitting pull requests.

Architecture

The model leverages several key components:

  • Appearance Feature Extractor
  • Motion Extractor
  • SPADE Generator
  • Warping Module
  • Stitching and Retargeting Modules

These components work together to animate portraits by extracting motion and appearance features and generating animated results with precise control over retargeting.

Training

The documentation primarily focuses on implementation and usage rather than training. It provides pretrained weights, which are crucial for running the model effectively.

Guide: Running Locally

Basic Steps

  1. Clone the Repository and Set Up Environment

    git clone https://github.com/KwaiVGI/LivePortrait
    cd LivePortrait
    conda create -n LivePortrait python==3.9
    conda activate LivePortrait
    

    For Linux and Windows:

    pip install -r requirements.txt
    

    For macOS with Apple Silicon:

    pip install -r requirements_macOS.txt
    

    Ensure FFmpeg is installed on your system.

  2. Download Pretrained Weights

    • Use Git Large File Storage (LFS) to clone weights from Hugging Face, or download from Google Drive/Baidu Yun.
    git lfs install
    git clone https://huggingface.co/KwaiVGI/LivePortrait temp_pretrained_weights
    mv temp_pretrained_weights/* pretrained_weights/
    rm -rf temp_pretrained_weights
    
  3. Run Inference

    • For Linux and Windows:
      python inference.py
      
    • For macOS with Apple Silicon:
      PYTORCH_ENABLE_MPS_FALLBACK=1 python inference.py
      
  4. Use Gradio Interface

    • For an interactive interface:
      python app.py
      

Cloud GPUs

For enhanced performance, especially for large-scale inference, consider using cloud GPUs, such as those provided by AWS, Google Cloud, or Azure.

License

LivePortrait is licensed under the MIT License, allowing for broad usage and modification, provided that proper attribution is given.

More Related APIs