### Download LivePortrait Installer from HuggingFace Source: https://github.com/klingairesearch/liveportrait/blob/main/assets/docs/changelog/2024-08-05.md Use the huggingface-cli to download the Windows installer. Ensure huggingface_hub is installed. ```bash # !pip install -U "huggingface_hub[cli]" huggingface-cli download cleardusk/LivePortrait-Windows LivePortrait-Windows-v20240806.zip --local-dir ./ ``` -------------------------------- ### Download LivePortrait Installer via HF-Mirror Source: https://github.com/klingairesearch/liveportrait/blob/main/assets/docs/changelog/2024-08-05.md Download the Windows installer using huggingface-cli with HF_ENDPOINT set to hf-mirror.com. This is an alternative if direct Hugging Face access is restricted. Ensure huggingface_hub is installed. ```bash # !pip install -U "huggingface_hub[cli]" export HF_ENDPOINT=https://hf-mirror.com huggingface-cli download cleardusk/LivePortrait-Windows LivePortrait-Windows-v20240806.zip --local-dir ./ ``` -------------------------------- ### Install FFmpeg on Ubuntu/Debian Source: https://github.com/klingairesearch/liveportrait/blob/main/assets/docs/how-to-install-ffmpeg.md Commands for installing FFmpeg and its development libraries on Ubuntu or Debian-based systems. ```bash sudo apt install ffmpeg ``` ```bash sudo apt install libsox-dev ``` ```bash conda install -c conda-forge 'ffmpeg<7' ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/klingairesearch/liveportrait/blob/main/readme.md Install all remaining Python dependencies required for the LivePortrait project from the requirements.txt file. ```bash pip install -r requirements.txt ``` -------------------------------- ### Launch Gradio Interface (Linux/Windows) Source: https://github.com/klingairesearch/liveportrait/blob/main/readme.md Start the Gradio web interface for human mode inference on Linux and Windows systems. ```bash python app.py ``` -------------------------------- ### Install FFmpeg on MacOS Source: https://github.com/klingairesearch/liveportrait/blob/main/assets/docs/how-to-install-ffmpeg.md Use Homebrew to install FFmpeg on MacOS. ```bash brew install ffmpeg ``` -------------------------------- ### Launch Gradio Interface for Animals Source: https://github.com/klingairesearch/liveportrait/blob/main/readme.md Start the Gradio web interface specifically for animal inference. This is tested on Linux with NVIDIA GPU. ```bash python app_animals.py ``` -------------------------------- ### Install PyTorch for CUDA 11.1 Source: https://github.com/klingairesearch/liveportrait/blob/main/readme.md Install PyTorch, torchvision, and torchaudio compatible with CUDA 11.1. This command uses a specific index URL for CUDA 11.1 wheels. ```bash pip install torch==1.10.1+cu111 torchvision==0.11.2 torchaudio==0.10.1 -f https://download.pytorch.org/whl/cu111/torch_stable.html ``` -------------------------------- ### Install FFmpeg with Conda Source: https://github.com/klingairesearch/liveportrait/blob/main/assets/docs/how-to-install-ffmpeg.md Use this command if you are a Conda user to install FFmpeg. ```bash conda install ffmpeg ``` -------------------------------- ### Install PyTorch for CUDA 11.8 Source: https://github.com/klingairesearch/liveportrait/blob/main/readme.md Install PyTorch, torchvision, and torchaudio compatible with CUDA 11.8. This command uses the default PyTorch index URL for CUDA 11.8 wheels. ```bash pip install torch==2.3.0 torchvision==0.18.0 torchaudio==2.3.0 --index-url https://download.pytorch.org/whl/cu118 ``` -------------------------------- ### Install PyTorch for CUDA 12.1 Source: https://github.com/klingairesearch/liveportrait/blob/main/readme.md Install PyTorch, torchvision, and torchaudio compatible with CUDA 12.1. This command uses the default PyTorch index URL for CUDA 12.1 wheels. ```bash pip install torch==2.3.0 torchvision==0.18.0 torchaudio==2.3.0 --index-url https://download.pytorch.org/whl/cu121 ``` -------------------------------- ### Install Dependencies for macOS Source: https://github.com/klingairesearch/liveportrait/blob/main/readme.md Install Python dependencies specifically for macOS with Apple Silicon, using a separate requirements file as X-Pose is not supported. ```bash pip install -r requirements_macOS.txt ``` -------------------------------- ### Launch Animals Mode Gradio App Source: https://github.com/klingairesearch/liveportrait/blob/main/assets/docs/changelog/2024-08-02.md Start the Gradio interface for the animals mode. Optional arguments can be used to specify server port, name, and sharing. ```bash python app_animals.py # --server_port 8889 --server_name "0.0.0.0" --share ``` -------------------------------- ### Clone Repository and Create Conda Environment Source: https://github.com/klingairesearch/liveportrait/blob/main/readme.md Clone the LivePortrait repository and set up a dedicated Conda environment for the project. Ensure you have git, conda, and FFmpeg installed. ```bash git clone https://github.com/KlingTeam/LivePortrait cd LivePortrait # create env using conda conda create -n LivePortrait python=3.10 conda activate LivePortrait ``` -------------------------------- ### Check CUDA Version Source: https://github.com/klingairesearch/liveportrait/blob/main/readme.md Verify your system's CUDA version. This is important for selecting the correct PyTorch installation. ```bash nvcc -V # example versions: 11.1, 11.8, 12.1, etc. ``` -------------------------------- ### Display Inference Help Source: https://github.com/klingairesearch/liveportrait/blob/main/readme.md View all available command-line options for the inference script. ```bash python inference.py -h ``` -------------------------------- ### Run Inference with Video Source Source: https://github.com/klingairesearch/liveportrait/blob/main/readme.md Perform inference using a video as the source input and another video as the driving input. ```bash python inference.py -s assets/examples/source/s13.mp4 -d assets/examples/driving/d0.mp4 ``` -------------------------------- ### Download Pretrained Weights from HuggingFace Source: https://github.com/klingairesearch/liveportrait/blob/main/readme.md Download pretrained weights from the HuggingFace model hub using the huggingface-cli. This command excludes Git-related files and documentation. ```bash # !pip install -U "huggingface_hub[cli]" huggingface-cli download KlingTeam/LivePortrait --local-dir pretrained_weights --exclude "*.git*" "README.md" "docs" ``` -------------------------------- ### Launch Gradio with Torch Compile Source: https://github.com/klingairesearch/liveportrait/blob/main/readme.md Enable torch.compile for faster inference via the Gradio interface. This optimization process takes about a minute on the first run and is not supported on Windows or macOS. ```bash python app.py --flag_do_torch_compile ``` -------------------------------- ### Launch Gradio Interface (macOS Apple Silicon) Source: https://github.com/klingairesearch/liveportrait/blob/main/readme.md Run the Gradio web interface for human mode on macOS with Apple Silicon. Note potential performance limitations. ```bash PYTORCH_ENABLE_MPS_FALLBACK=1 python app.py ``` -------------------------------- ### Run Inference with Motion Template (Video Source) Source: https://github.com/klingairesearch/liveportrait/blob/main/readme.md Edit a portrait video using a pre-generated motion template (.pkl file). This method can accelerate inference and enhance privacy. ```bash python inference.py -s assets/examples/source/s13.mp4 -d assets/examples/driving/d5.pkl ``` -------------------------------- ### Download Pretrained Weights via HF-Mirror Source: https://github.com/klingairesearch/liveportrait/blob/main/readme.md Download pretrained weights using hf-mirror as an alternative endpoint for HuggingFace. Set the HF_ENDPOINT environment variable before downloading. ```bash # !pip install -U "huggingface_hub[cli]" export HF_ENDPOINT=https://hf-mirror.com huggingface-cli download KlingTeam/LivePortrait --local-dir pretrained_weights --exclude "*.git*" "README.md" "docs" ``` -------------------------------- ### Run Inference with Image Source Source: https://github.com/klingairesearch/liveportrait/blob/main/readme.md Perform inference using a static image as the source input and a video as the driving input. ```bash python inference.py -s assets/examples/source/s9.jpg -d assets/examples/driving/d0.mp4 ``` -------------------------------- ### Run Inference with Motion Template (Image Source) Source: https://github.com/klingairesearch/liveportrait/blob/main/readme.md Generate a portrait animation using a static image source and a pre-generated motion template (.pkl file). This can speed up inference and protect privacy. ```bash python inference.py -s assets/examples/source/s9.jpg -d assets/examples/driving/d5.pkl ``` -------------------------------- ### Build X-Pose Attention Module Source: https://github.com/klingairesearch/liveportrait/blob/main/readme.md Compile the MultiScaleDeformableAttention module required for animal inference. Ensure your CUDA versions are compatible. ```bash cd src/utils/dependencies/XPose/models/UniPose/ops python setup.py build install cd - # equal to cd ../../../../../../../ ``` -------------------------------- ### Build X-Pose OP MultiScaleDeformableAttention Source: https://github.com/klingairesearch/liveportrait/blob/main/assets/docs/changelog/2024-08-02.md Build the MultiScaleDeformableAttention OP required for X-Pose keypoint detection. Ensure you are in the correct directory before running. ```bash cd src/utils/dependencies/XPose/models/UniPose/ops python setup.py build install cd - # this returns to the previous directory ``` -------------------------------- ### Run Human Inference (macOS Apple Silicon) Source: https://github.com/klingairesearch/liveportrait/blob/main/readme.md Run the inference script on macOS with Apple Silicon, noting potential performance differences compared to NVIDIA GPUs. ```bash PYTORCH_ENABLE_MPS_FALLBACK=1 python inference.py ``` -------------------------------- ### Evaluate Inference Speed Source: https://github.com/klingairesearch/liveportrait/blob/main/readme.md Run the script to benchmark the inference speed of each module on NVIDIA GPUs. ```bash python speed.py ``` -------------------------------- ### Use Image as Driving Reference (CLI) Source: https://github.com/klingairesearch/liveportrait/blob/main/assets/docs/changelog/2024-08-19.md Use this command to specify a driving image for animation. Ensure the source and driving files are correctly path-ed. ```bash python inference.py -s assets/examples/source/s5.jpg -d assets/examples/driving/d30.jpg ``` -------------------------------- ### Run Inference with Auto-Cropping Source: https://github.com/klingairesearch/liveportrait/blob/main/readme.md Perform inference while enabling the auto-cropping feature for the driving video. This is recommended for custom driving videos. ```bash python inference.py -s assets/examples/source/s9.jpg -d assets/examples/driving/d13.mp4 --flag_crop_driving_video ``` -------------------------------- ### Run Animal Inference Source: https://github.com/klingairesearch/liveportrait/blob/main/readme.md Execute inference for animal portraits using a specified source, driving input (PKL file), and custom multipliers. This mode is tested on Linux/Windows with NVIDIA GPU. ```bash python inference_animals.py -s assets/examples/source/s39.jpg -d assets/examples/driving/wink.pkl --driving_multiplier 1.75 --no_flag_stitching ``` -------------------------------- ### Run Human Inference (Linux/Windows) Source: https://github.com/klingairesearch/liveportrait/blob/main/readme.md Execute the main inference script for human portraits on Linux and Windows systems. ```bash python inference.py ``` -------------------------------- ### Configure Animals Model Version Source: https://github.com/klingairesearch/liveportrait/blob/main/assets/docs/changelog/2025-01-01.md Modify this configuration to switch between the new (v1.1) and original Animals model versions. Ensure your weights are updated to use the new version. ```python version_animals = "" # old version # version_animals = "_v1.1" # new (v1.1) version ``` -------------------------------- ### Run Animals Mode Inference Source: https://github.com/klingairesearch/liveportrait/blob/main/assets/docs/changelog/2024-08-02.md Execute the animals mode inference script. Disable stitching and adjust the driving multiplier as recommended for animal models. ```bash python inference_animals.py -s assets/examples/source/s39.jpg -d assets/examples/driving/wink.pkl --no_flag_stitching --driving_multiplier 1.75 ``` -------------------------------- ### Regional Control for Animation (CLI) Source: https://github.com/klingairesearch/liveportrait/blob/main/assets/docs/changelog/2024-08-19.md Specify the animation region to control specific facial features. Use 'lip' to animate only the lip movements. ```bash # only driving the lip region python inference.py -s assets/examples/source/s5.jpg -d assets/examples/driving/d0.mp4 --animation_region lip ``` -------------------------------- ### LivePortrait Citation BibTeX Source: https://github.com/klingairesearch/liveportrait/blob/main/readme.md Use this BibTeX entry to cite the LivePortrait project in your research or publications. It includes title, authors, journal, and year. ```bibtex @article{guo2024liveportrait, title = {LivePortrait: Efficient Portrait Animation with Stitching and Retargeting Control}, author = {Guo, Jianzhu and Zhang, Dingyun and Liu, Xiaoqiang and Zhong, Zhizhou and Zhang, Yuan and Wan, Pengfei and Zhang, Di}, journal = {arXiv preprint arXiv:2407.03168}, year = {2024} } ``` -------------------------------- ### Absolute Motion Driving (CLI) Source: https://github.com/klingairesearch/liveportrait/blob/main/assets/docs/changelog/2024-08-19.md Use this command to apply the driving video's motion directly to the output, disabling relative motion. This may cause jitter or identity leakage. ```bash python inference.py --no_flag_relative_motion ``` -------------------------------- ### Adjusting Detection Threshold in LivePortrait Source: https://github.com/klingairesearch/liveportrait/blob/main/assets/docs/changelog/2024-07-24.md Use the `--det_thresh` argument to modify the face detection threshold. A lower value increases recall, detecting more varied faces. The default is 0.15. ```python python app.py --det_thresh 0.5 ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.