How kwaivgi/liveportrait works
LivePortrait is a PyTorch portrait-animation application for human and animal subjects. Users provide a source portrait or video and driving video or motion template through the command-line or Gradio interfaces; the runtime prepares crops and motion, animates frames, and produces image or video output. The graph separates human and animal pipelines, shared preprocessing, and the learned model components. README-described editing and regional controls are represented in the Gradio branch. Some internal calls are omitted where excerpts show imports or partial code but not execution; dashed links mark unverified integration.
Main entry points: live_portrait_pipeline.py Human pipeline · live_portrait_pipeline_animal.py Animal pipeline · cropper.py Face cropper · gradio_pipeline.py Gradio controls
Components 17
User interfaces
- CLI inference
inference.py - Animal CLI
inference_animals.py - Gradio controls
src/gradio_pipeline.py
Animation runtime
- Human pipeline
src/live_portrait_pipeline.py - Animal pipeline
src/live_portrait_pipeline_animal.py - Inference wrapper
src/live_portrait_wrapper.py - Runtime configuration
src/config/inference_config.py
Input preparation
- Face cropper
src/utils/cropper.py - Crop geometry
src/utils/crop.py - Landmark detection
src/utils/human_landmark_runner.py - Animal landmarks
src/utils/animal_landmark_runner.py - Image video I/O
src/utils/io.py - Video utilities
src/utils/video.py
Learned models
- Animation networks
src/modules - X-Pose dependency
src/utils/dependencies/XPose
Other components
- User
- Generated media
Connections 23
- User → CLI inference: supplies inputs
- User → Animal CLI: supplies inputs
- User → Gradio controls: edits animation
- CLI inference → Human pipeline: runs
inference.py - Animal CLI → Animal pipeline: runs
inference_animals.py - Gradio controls → Human pipeline: dispatches
src/gradio_pipeline.py - Gradio controls → Animal pipeline: dispatches
src/gradio_pipeline.py - Human pipeline → Runtime configuration: uses settings
src/live_portrait_pipeline.py - Animal pipeline → Runtime configuration: uses settings
src/live_portrait_pipeline_animal.py - Human pipeline → Face cropper: crops frames
src/live_portrait_pipeline.py - Animal pipeline → Face cropper: crops frames
src/live_portrait_pipeline_animal.py - Human pipeline → Inference wrapper: runs inference
src/live_portrait_pipeline.py - Animal pipeline → Inference wrapper: runs inference
src/live_portrait_pipeline_animal.py - Human pipeline → Image video I/O: loads media
src/live_portrait_pipeline.py - Animal pipeline → Image video I/O: loads media
src/live_portrait_pipeline_animal.py - Human pipeline → Video utilities: reads video metadata
src/live_portrait_pipeline.py - Face cropper → Crop geometry: uses geometry
src/utils/cropper.py - Face cropper → Landmark detection: requests landmarks
src/utils/cropper.py - Face cropper → Animal landmarks: requests landmarks
src/utils/cropper.py - Animal landmarks → X-Pose dependency: detects keypoints
- Inference wrapper → Animation networks: runs networks
- Human pipeline → Generated media: writes animation
- Animal pipeline → Generated media: writes animation