AdvancedLivePortrait-WebUI

repository·master·Indexed 19 days ago

https://github.com/jhj0517/advancedliveportrait-webui

A Gradio-based interface for the LivePortrait project that allows users to edit facial expressions from images. Built upon LivePortrait and ComfyUI-AdvancedLivePortrait, it features an Expression Editor for fine-grained control of facial features and a Video Driven mode to animate reference images using driving videos. Supports local installation via Python, PowerShell scripts, Docker, or hosted environments like Google Colab and Hugging Face Spaces.

Tokens
2.4K
Snippets
8
Records
14
Agent score
67%

What's inside AdvancedLivePortrait-WebUI

  1. Try AdvancedLivePortrait-WebUI in Colab or Hugging Face Spaces

    master

    If you do not want to install the project locally, you can use the following hosted environments:

    • Google Colab: Use the provided notebook for a cloud-based execution environment.
    • Hugging Face Spaces: Access the hosted WebUI directly on Hugging Face.
  2. Run AdvancedLivePortrait-WebUI with Docker

    master

    You can containerize the application using Docker Compose.

    1. Clone the repository:
      git clone https://github.com/jhj0517/AdvancedLivePortrait-WebUI.git
    2. Build the image:
      docker compose -f docker/docker-compose.yaml build
    3. Start the container:
      docker compose -f docker/docker-compose.yaml up
    4. Access the WebUI at http://localhost:7860/.

    Note: If you are not using an Nvidia GPU, you must update the docker/docker-compose.yaml file to match your environment.

    git clone https://github.com/jhj0517/AdvancedLivePortrait-WebUI.git
    docker compose -f docker/docker-compose.yaml build
    docker compose -f docker/docker-compose.yaml up
  3. Install and run AdvancedLivePortrait-WebUI locally

    master

    To run the WebUI on your local machine, follow these steps:

    1. Clone the repository:
      git clone https://github.com/jhj0517/AdvancedLivePortrait-WebUI.git
    2. Install dependencies. If you have an Nvidia GPU, use requirements.txt. If you are running on a CPU, use requirements-cpu.txt:
      pip install -r requirements.txt
    3. Launch the application:
      python app.py
    git clone https://github.com/jhj0517/AdvancedLivePortrait-WebUI.git
    pip install -r requirements.txt
    python app.py
  4. Run AdvancedLivePortrait-WebUI with PowerShell (Windows)

    master

    For Windows users, the project provides PowerShell scripts that automate the creation and activation of a virtual environment (venv), dependency installation, and app execution.

    Available scripts:

    • Install.ps1
    • Start-WebUI.ps1
    • Update.ps1

    To use them, right-click the script file and select Run with PowerShell.

  5. Prerequisites for AdvancedLivePortrait-WebUI

    master

    Before installing, ensure your environment meets the following requirements:

    • Python: Version 3.9 to 3.12.
    • CUDA (Optional): If using an Nvidia GPU, CUDA 12.4 is recommended.
    • FFmpeg (Optional): Required if you are using the Video Driven feature. You must add the FFmpeg/bin folder to your system PATH after installation.
  6. Run AdvancedLivePortrait-WebUI without an NVIDIA GPU

    master

    If you do not have an NVIDIA GPU, you must perform two steps to ensure the Docker container runs correctly:

    1. Update Docker Compose: Modify the deploy section in docker-compose.yaml to match your specific device driver (refer to Docker Compose deploy documentation).
    2. Update Dependencies: You must edit the Dockerfile to change the requirement installation from requirements.txt to requirements-cpu.txt to avoid attempting to install CUDA-dependent packages.
  7. Install AdvancedLivePortrait-WebUI dependencies

    master

    To set up the environment, clone the repository and install the required Python packages including lmdb, ultralytics, tyro, dill, and gradio-i18n.

    !git clone https://github.com/jhj0517/AdvancedLivePortrait-WebUI.git
    %cd AdvancedLivePortrait-WebUI
    !pip install lmdb
    !pip install ultralytics
    !pip install tyro
    !pip install dill
    !pip install gradio-i18n
  8. Configure Docker Compose for AdvancedLivePortrait-WebUI

    master

    Use the docker-compose.yaml file to orchestrate the application container. The service app builds from docker/Dockerfile and exposes the WebUI on port 7860.

    Volume Mounting

    To persist models and outputs on your host machine, you must map local directories to the container paths. Update the volumes section with your local absolute paths:

    • Map local models to: /AdvancedLivePortrait-WebUI/models
    • Map local outputs to: /AdvancedLivePortrait-WebUI/outputs

    GPU Configuration

    By default, the configuration is set up for NVIDIA GPUs using the nvidia driver. If you are running on a different hardware setup, you must update the deploy.resources.reservations.devices.driver field.

    services:
      app:
        build:
          dockerfile: docker/Dockerfile
          context: ..
        image: jhj0517/advancedliveportrait-webui:latest
        volumes:
          - C:/your-local-path/AdvancedLivePortrait-WebUI/models:/AdvancedLivePortrait-WebUI/models
          - C:/your-local-path/AdvancedLivePortrait-WebUI/outputs:/AdvancedLivePortrait-WebUI/outputs
        ports:
          - "7860:7860"
        stdin_open: true
        tty: true
        entrypoint: ["python", "app.py", "--server_port", "7860", "--server_name", "0.0.0.0"]
        deploy:
          resources:
            reservations:
              devices:
                - driver: nvidia
                  count: all
                  capabilities: [ gpu ]
  9. Initialize and launch the AdvancedLivePortrait App

    master

    The App class is the main entrypoint for the Gradio-based WebUI. It manages the LivePortraitInferencer, internationalization (i18n), and the Gradio interface layout.

    To use the App class, you should pass an object containing configuration arguments (similar to argparse results) to the constructor. The launch() method starts the Gradio server with settings derived from these arguments.

    import argparse
    from app import App
    
    parser = argparse.ArgumentParser()
    parser.add_argument('--model_dir', type=str, default='path/to/models')
    parser.add_argument('--output_dir', type=str, default='path/to/outputs')
    parser.add_argument('--server_port', type=int, default=7860)
    # ... add other args as needed
    args = parser.parse_args()
    
    app = App(args=args)
    app.launch()
  10. Video Driven parameters

    master

    The Video Driven mode uses a driving video to animate a reference image. The following parameters control the alignment and quality:

    • First frame eyes alignment factor: Alignment strength for eyes (0 to 1).
    • First frame mouth alignment factor: Alignment strength for mouth (0 to 1).
    • Face Crop Factor: Controls the face cropping area (1.5 to 2.5).
    • Enable Image Restoration: Checkbox to enable RealESRGAN.