Bring portraits to life in Real Time!onnx/tensorrt support!实时肖像驱动!
Python
1,194
110 commits
updated Jun 29, 2025
Original repository: LivePortrait, thanks to the authors for sharing
New features:
If you find this project useful, please give it a star ✨✨
Your browser does not support this video!
Your browser does not support this video!
Your browser does not support this video!
Your browser does not support this video!
Your browser does not support this video!
update.bat to update the code.scripts/all_onnx2trt.bat to convert onnx files to tensorrt files.webui.bat to open the webpage, or double-click camera.bat to open the camera for real-time operation.docker pull shaoguo/faster_liveportrait:v3$FasterLivePortrait_ROOT with the local directory where you downloaded FasterLivePortrait:docker run -it --gpus=all \
--name faster_liveportrait \
-v $FasterLivePortrait_ROOT:/root/FasterLivePortrait \
--restart=always \
-p 9870:9870 \
shaoguo/faster_liveportrait:v3 \
/bin/bash
pip install -r requirements.txtgit clone https://github.com/SeanWangJS/grid-sample3d-trt-pluginCMakeLists.txt to: set_target_properties(${PROJECT_NAME} PROPERTIES CUDA_ARCHITECTURES "60;70;75;80;86")export PATH=/usr/local/cuda/bin:$PATHmkdir build && cd buildcmake .. -DTensorRT_ROOT=$TENSORRT_HOME, replace $TENSORRT_HOME with your own TensorRT root directory.make, remember the address of the .so file, replace /opt/grid-sample3d-trt-plugin/build/libgrid_sample_3d_plugin.so in scripts/onnx2trt.py and src/models/predictor.py with your own .so file pathhuggingface-cli download warmshao/FasterLivePortrait --local-dir ./checkpoints. Convert all ONNX models to TensorRT, run sh scripts/all_onnx2trt.sh and sh scripts/all_onnx2trt_animal.sh python run.py \
--src_image assets/examples/source/s10.jpg \
--dri_video assets/examples/driving/d14.mp4 \
--cfg configs/trt_infer.yaml
python run.py \
--src_image assets/examples/source/s10.jpg \
--dri_video 0 \
--cfg configs/trt_infer.yaml \
--realtime
huggingface-cli download warmshao/FasterLivePortrait --local-dir ./checkpoints.pip install onnxruntime. However, cpu inference is extremely slow and not recommended. The latest onnxruntime-gpu still doesn't support grid_sample cuda, but I found a branch that supports it. Follow these steps to install onnxruntime-gpu from source:
git clone https://github.com/microsoft/onnxruntimegit checkout liqun/ImageDecoder-cuda. Thanks to liqun for the grid_sample with cuda implementation!cuda_version and CMAKE_CUDA_ARCHITECTURES according to your machine (your cuDNN version must be 8.x, 9.x is not compatible):./build.sh --parallel \
--build_shared_lib --use_cuda \
--cuda_version 11.8 \
--cuda_home /usr/local/cuda --cudnn_home /usr/local/cuda/ \
--config Release --build_wheel --skip_tests \
--cmake_extra_defines CMAKE_CUDA_ARCHITECTURES="60;70;75;80;86" \
--cmake_extra_defines CMAKE_CUDA_COMPILER=/usr/local/cuda/bin/nvcc \
--disable_contrib_ops \
--allow_running_as_root
pip install build/Linux/Release/dist/onnxruntime_gpu-1.17.0-cp310-cp310-linux_x86_64.whl python run.py \
--src_image assets/examples/source/s10.jpg \
--dri_video assets/examples/driving/d14.mp4 \
--cfg configs/onnx_infer.yaml
python webui.py --mode onnxpython webui.py --mode trthttp://localhost:9870/Hotkeys for webcam mode (when render window is on focus)
Q > exit
S > Stitching
Z > RelativeMotion
X > AnimationRegion
C > CropDrivingVideo
K,L > AdjustSourceScale
N,M > AdjustDriverScale
Changelog
python api.py, For more information, please refer to the tutorial.git pull origin master and install the latest Python dependencies pip install requirements.txt, or simply double-click update.bat on Windows.huggingface-cli download hexgrad/Kokoro-82M --local-dir .\checkpoints\Kokoro-82M.espeak-ng: apt-get -qq -y install espeak-ng > /dev/null 2>&1espeak-ng environment variables. The current read location is here; modify it if your installation path differs.huggingface-cli download TencentGameMate/chinese-hubert-base --local-dir .\checkpoints\chinese-hubert-base and huggingface-cli download jdh-algo/JoyVASA --local-dir ./checkpoints/JoyVASA您的浏览器不支持播放该视频!
update.bat to update, but note that your local code will be overwritten.python run.py now automatically saves the corresponding pickle to the same directory as the driving video, allowing for direct reuse.relative motion.python run.py --src_image assets/examples/source/s39.jpg --dri_video assets/examples/driving/d0.mp4 --cfg configs/trt_infer.yaml --paste_back --animaldocker pull shaoguo/faster_liveportrait:v3python run.py --src_image assets/examples/source/s39.jpg --dri_video assets/examples/driving/d0.mp4 --cfg configs/trt_infer.yaml --paste_back --animaldocker pull shaoguo/faster_liveportrait:v3Added support for animal models.
huggingface-cli download warmshao/FasterLivePortrait --local-dir ./checkpoints, then convert it to TRT format.docker pull shaoguo/faster_liveportrait:v3. Using animal model:python run.py --src_image assets/examples/source/s39.jpg --dri_video 0 --cfg configs/trt_infer.yaml --realtime --animal您的浏览器不支持播放该视频!
Using MediaPipe model to replace InsightFace
python webui.py --mode trt --mp or python webui.py --mode onnx --mppython run.py --src_image assets/examples/source/s12.jpg --dri_video 0 --cfg configs/trt_mp_infer.yamlFasterLivePortrait-windows and double-click scripts/all_onnx2trt.bat to convert onnx files, which will take some time.webui.bat, open the webpage: http://localhost:9870/camera.bat,press q to stop. If you want to change the target image, run in command line: camera.bat assets/examples/source/s9.jpgbrew install ffmpegconda create -n flip python=3.10 && conda activate flippip install -r requirements_macos.txthuggingface-cli download warmshao/FasterLivePortrait --local-dir ./checkpointspython webui.py --mode onnx400 followers · starred Dec 2024
945 followers · starred Mar 2025
696 followers · starred Jul 2024
1,105 followers · starred Jul 2024
Bring portraits to life in Real Time!onnx/tensorrt support!实时肖像驱动!
Python
1,194
110 commits
updated Jun 29, 2025
Original repository: LivePortrait, thanks to the authors for sharing
New features:
If you find this project useful, please give it a star ✨✨
Your browser does not support this video!
Your browser does not support this video!
Your browser does not support this video!
Your browser does not support this video!
Your browser does not support this video!
update.bat to update the code.scripts/all_onnx2trt.bat to convert onnx files to tensorrt files.webui.bat to open the webpage, or double-click camera.bat to open the camera for real-time operation.docker pull shaoguo/faster_liveportrait:v3$FasterLivePortrait_ROOT with the local directory where you downloaded FasterLivePortrait:docker run -it --gpus=all \
--name faster_liveportrait \
-v $FasterLivePortrait_ROOT:/root/FasterLivePortrait \
--restart=always \
-p 9870:9870 \
shaoguo/faster_liveportrait:v3 \
/bin/bash
pip install -r requirements.txtgit clone https://github.com/SeanWangJS/grid-sample3d-trt-pluginCMakeLists.txt to: set_target_properties(${PROJECT_NAME} PROPERTIES CUDA_ARCHITECTURES "60;70;75;80;86")export PATH=/usr/local/cuda/bin:$PATHmkdir build && cd buildcmake .. -DTensorRT_ROOT=$TENSORRT_HOME, replace $TENSORRT_HOME with your own TensorRT root directory.make, remember the address of the .so file, replace /opt/grid-sample3d-trt-plugin/build/libgrid_sample_3d_plugin.so in scripts/onnx2trt.py and src/models/predictor.py with your own .so file pathhuggingface-cli download warmshao/FasterLivePortrait --local-dir ./checkpoints. Convert all ONNX models to TensorRT, run sh scripts/all_onnx2trt.sh and sh scripts/all_onnx2trt_animal.sh python run.py \
--src_image assets/examples/source/s10.jpg \
--dri_video assets/examples/driving/d14.mp4 \
--cfg configs/trt_infer.yaml
python run.py \
--src_image assets/examples/source/s10.jpg \
--dri_video 0 \
--cfg configs/trt_infer.yaml \
--realtime
huggingface-cli download warmshao/FasterLivePortrait --local-dir ./checkpoints.pip install onnxruntime. However, cpu inference is extremely slow and not recommended. The latest onnxruntime-gpu still doesn't support grid_sample cuda, but I found a branch that supports it. Follow these steps to install onnxruntime-gpu from source:
git clone https://github.com/microsoft/onnxruntimegit checkout liqun/ImageDecoder-cuda. Thanks to liqun for the grid_sample with cuda implementation!cuda_version and CMAKE_CUDA_ARCHITECTURES according to your machine (your cuDNN version must be 8.x, 9.x is not compatible):./build.sh --parallel \
--build_shared_lib --use_cuda \
--cuda_version 11.8 \
--cuda_home /usr/local/cuda --cudnn_home /usr/local/cuda/ \
--config Release --build_wheel --skip_tests \
--cmake_extra_defines CMAKE_CUDA_ARCHITECTURES="60;70;75;80;86" \
--cmake_extra_defines CMAKE_CUDA_COMPILER=/usr/local/cuda/bin/nvcc \
--disable_contrib_ops \
--allow_running_as_root
pip install build/Linux/Release/dist/onnxruntime_gpu-1.17.0-cp310-cp310-linux_x86_64.whl python run.py \
--src_image assets/examples/source/s10.jpg \
--dri_video assets/examples/driving/d14.mp4 \
--cfg configs/onnx_infer.yaml
python webui.py --mode onnxpython webui.py --mode trthttp://localhost:9870/Hotkeys for webcam mode (when render window is on focus)
Q > exit
S > Stitching
Z > RelativeMotion
X > AnimationRegion
C > CropDrivingVideo
K,L > AdjustSourceScale
N,M > AdjustDriverScale
Changelog
python api.py, For more information, please refer to the tutorial.git pull origin master and install the latest Python dependencies pip install requirements.txt, or simply double-click update.bat on Windows.huggingface-cli download hexgrad/Kokoro-82M --local-dir .\checkpoints\Kokoro-82M.espeak-ng: apt-get -qq -y install espeak-ng > /dev/null 2>&1espeak-ng environment variables. The current read location is here; modify it if your installation path differs.huggingface-cli download TencentGameMate/chinese-hubert-base --local-dir .\checkpoints\chinese-hubert-base and huggingface-cli download jdh-algo/JoyVASA --local-dir ./checkpoints/JoyVASA您的浏览器不支持播放该视频!
update.bat to update, but note that your local code will be overwritten.python run.py now automatically saves the corresponding pickle to the same directory as the driving video, allowing for direct reuse.relative motion.python run.py --src_image assets/examples/source/s39.jpg --dri_video assets/examples/driving/d0.mp4 --cfg configs/trt_infer.yaml --paste_back --animaldocker pull shaoguo/faster_liveportrait:v3python run.py --src_image assets/examples/source/s39.jpg --dri_video assets/examples/driving/d0.mp4 --cfg configs/trt_infer.yaml --paste_back --animaldocker pull shaoguo/faster_liveportrait:v3Added support for animal models.
huggingface-cli download warmshao/FasterLivePortrait --local-dir ./checkpoints, then convert it to TRT format.docker pull shaoguo/faster_liveportrait:v3. Using animal model:python run.py --src_image assets/examples/source/s39.jpg --dri_video 0 --cfg configs/trt_infer.yaml --realtime --animal您的浏览器不支持播放该视频!
Using MediaPipe model to replace InsightFace
python webui.py --mode trt --mp or python webui.py --mode onnx --mppython run.py --src_image assets/examples/source/s12.jpg --dri_video 0 --cfg configs/trt_mp_infer.yamlFasterLivePortrait-windows and double-click scripts/all_onnx2trt.bat to convert onnx files, which will take some time.webui.bat, open the webpage: http://localhost:9870/camera.bat,press q to stop. If you want to change the target image, run in command line: camera.bat assets/examples/source/s9.jpgbrew install ffmpegconda create -n flip python=3.10 && conda activate flippip install -r requirements_macos.txthuggingface-cli download warmshao/FasterLivePortrait --local-dir ./checkpointspython webui.py --mode onnx400 followers · starred Dec 2024
945 followers · starred Mar 2025
696 followers · starred Jul 2024
1,105 followers · starred Jul 2024