# myniuuu/anicrafter architecture

> Architecture diagram of the GitHub repository myniuuu/anicrafter, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/myniuuu/anicrafter
- Repository: https://github.com/myniuuu/anicrafter

## Overview

AniCrafter creates human-centric animated video by conditioning video diffusion on a rendered 3D Gaussian-splat avatar and a background scene. The documented workflow reconstructs an avatar from a character image, animates it using SMPLX motion, combines its renderings with a background, then generates and saves the result. For in-the-wild replacement, preprocessing adds human-mask parsing, pose/SMPLX estimation, and background inpainting. The README documents these stages; excerpts show pipeline setup and rendering-related code but do not expose every orchestration call, so uncertain wiring is omitted.

Main entry points: [`diffsynth/pipelines/wan_video_v2v_combine.py`](https://github.com/myniuuu/anicrafter/blob/main/diffsynth/pipelines/wan_video_v2v_combine.py) (AniCrafter diffusion), [`run_pipeline_with_preprocess.py`](https://github.com/myniuuu/anicrafter/blob/main/run_pipeline_with_preprocess.py) (Replacement entry), [`run_pipeline.py`](https://github.com/myniuuu/anicrafter/blob/main/run_pipeline.py) (Avatar-background condition), [`diffsynth/models/model_manager.py`](https://github.com/myniuuu/anicrafter/blob/main/diffsynth/models/model_manager.py) (Model loading)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_preprocess["Video preprocessing"]
  node_mask["Human masks<br/>[inference.py]"]
  node_pose["Pose and SMPLX<br/>[pose_estimator.py]"]
  node_inpaint["Background inpainting"]
end

subgraph group_avatar["Avatar reconstruction"]
  node_lhm["Avatar reconstruction<br/>[human_lrm.py]"]
end

subgraph group_render["Motion and conditioning"]
  node_smplx["SMPLX model<br/>[smpl_x.py]"]
  node_avatar_render["Animated avatar render<br/>[synthesizer.py]"]
  node_condition["Avatar-background condition<br/>[run_pipeline.py]"]
end

subgraph group_generation["Video generation"]
  node_wan_pipeline["AniCrafter diffusion"]
  node_wan_models["Video diffusion models<br/>[wan_video_dit.py]"]
end

subgraph group_runtime["Inference runtime"]
  node_model_manager["Model loading<br/>[model_manager.py]"]
  node_single_runner["Single-GPU entry<br/>[run_pipeline.py]"]
  node_multi_runner["USP entry"]
  node_preprocess_runner["Replacement entry"]
  node_output["Rendered video output<br/>[run_pipeline.py]"]
end

node_user(("User"))
node_character["Character image"]
node_scene["Scene or video"]

node_user -->|"provides"| node_character
node_user -->|"provides"| node_scene
node_scene -.->|"parse masks"| node_mask
node_scene -.->|"estimate motion"| node_pose
node_scene -.->|"remove person"| node_inpaint
node_character -->|"reconstructs"| node_lhm
node_lhm -->|"provides avatar"| node_avatar_render
node_pose -.->|"provides motion"| node_smplx
node_smplx -->|"drives animation"| node_avatar_render
node_avatar_render -->|"supplies renderings"| node_condition
node_scene -->|"supplies background"| node_condition
node_inpaint -.->|"supplies clean background"| node_condition
node_condition -->|"conditions"| node_wan_pipeline
node_model_manager -->|"loads models for"| node_wan_pipeline
node_wan_pipeline -->|"runs diffusion models"| node_wan_models
node_single_runner -->|"loads"| node_model_manager
node_single_runner -->|"invokes"| node_wan_pipeline
node_multi_runner -->|"loads"| node_model_manager
node_multi_runner -->|"invokes with USP"| node_wan_pipeline
node_preprocess_runner -->|"invokes"| node_mask
node_preprocess_runner -->|"invokes"| node_pose
node_preprocess_runner -->|"invokes"| node_inpaint
node_preprocess_runner -->|"loads"| node_model_manager
node_preprocess_runner -->|"invokes"| node_wan_pipeline
node_wan_pipeline -->|"generates"| node_output

click node_mask "https://github.com/myniuuu/anicrafter/blob/main/engine/BiRefNet/inference.py"
click node_pose "https://github.com/myniuuu/anicrafter/blob/main/engine/pose_estimation/pose_estimator.py"
click node_inpaint "https://github.com/myniuuu/anicrafter/blob/main/ProPainter/inference_propainter.py"
click node_lhm "https://github.com/myniuuu/anicrafter/blob/main/LHM/runners/infer/human_lrm.py"
click node_smplx "https://github.com/myniuuu/anicrafter/blob/main/LHM/models/rendering/smpl_x.py"
click node_avatar_render "https://github.com/myniuuu/anicrafter/blob/main/LHM/models/rendering/synthesizer.py"
click node_condition "https://github.com/myniuuu/anicrafter/blob/main/run_pipeline.py"
click node_wan_pipeline "https://github.com/myniuuu/anicrafter/blob/main/diffsynth/pipelines/wan_video_v2v_combine.py"
click node_wan_models "https://github.com/myniuuu/anicrafter/blob/main/diffsynth/models/wan_video_dit.py"
click node_model_manager "https://github.com/myniuuu/anicrafter/blob/main/diffsynth/models/model_manager.py"
click node_single_runner "https://github.com/myniuuu/anicrafter/blob/main/run_pipeline.py"
click node_multi_runner "https://github.com/myniuuu/anicrafter/blob/main/run_pipeline_usp.py"
click node_preprocess_runner "https://github.com/myniuuu/anicrafter/blob/main/run_pipeline_with_preprocess.py"
click node_output "https://github.com/myniuuu/anicrafter/blob/main/run_pipeline.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_mask,node_pose,node_inpaint,node_user toneBlue
class node_lhm toneAmber
class node_smplx,node_avatar_render,node_condition toneMint
class node_wan_pipeline,node_wan_models toneRose
class node_model_manager,node_single_runner,node_multi_runner,node_preprocess_runner,node_output,node_character,node_scene toneIndigo
```

## Components

### Video preprocessing

- [Human masks](https://github.com/myniuuu/anicrafter/blob/main/engine/BiRefNet/inference.py): `engine/BiRefNet/inference.py`
- [Pose and SMPLX](https://github.com/myniuuu/anicrafter/blob/main/engine/pose_estimation/pose_estimator.py): `engine/pose_estimation/pose_estimator.py`
- [Background inpainting](https://github.com/myniuuu/anicrafter/blob/main/ProPainter/inference_propainter.py): `ProPainter/inference_propainter.py`

### Avatar reconstruction

- [Avatar reconstruction](https://github.com/myniuuu/anicrafter/blob/main/LHM/runners/infer/human_lrm.py): `LHM/runners/infer/human_lrm.py`

### Motion and conditioning

- [SMPLX model](https://github.com/myniuuu/anicrafter/blob/main/LHM/models/rendering/smpl_x.py): `LHM/models/rendering/smpl_x.py`
- [Animated avatar render](https://github.com/myniuuu/anicrafter/blob/main/LHM/models/rendering/synthesizer.py): `LHM/models/rendering/synthesizer.py`
- [Avatar-background condition](https://github.com/myniuuu/anicrafter/blob/main/run_pipeline.py): `run_pipeline.py`

### Video generation

- [AniCrafter diffusion](https://github.com/myniuuu/anicrafter/blob/main/diffsynth/pipelines/wan_video_v2v_combine.py): `diffsynth/pipelines/wan_video_v2v_combine.py`
- [Video diffusion models](https://github.com/myniuuu/anicrafter/blob/main/diffsynth/models/wan_video_dit.py): `diffsynth/models/wan_video_dit.py`

### Inference runtime

- [Model loading](https://github.com/myniuuu/anicrafter/blob/main/diffsynth/models/model_manager.py): `diffsynth/models/model_manager.py`
- [Single-GPU entry](https://github.com/myniuuu/anicrafter/blob/main/run_pipeline.py): `run_pipeline.py`
- [USP entry](https://github.com/myniuuu/anicrafter/blob/main/run_pipeline_usp.py): `run_pipeline_usp.py`
- [Replacement entry](https://github.com/myniuuu/anicrafter/blob/main/run_pipeline_with_preprocess.py): `run_pipeline_with_preprocess.py`
- [Rendered video output](https://github.com/myniuuu/anicrafter/blob/main/run_pipeline.py): `run_pipeline.py`

### Other components

- **User**
- **Character image**
- **Scene or video**

## Connections

- User → Character image: provides
- User → Scene or video: provides
- Scene or video → Human masks: parse masks
- Scene or video → Pose and SMPLX: estimate motion
- Scene or video → Background inpainting: remove person
- Character image → Avatar reconstruction: reconstructs
- Avatar reconstruction → Animated avatar render: provides avatar
- Pose and SMPLX → SMPLX model: provides motion
- SMPLX model → Animated avatar render: drives animation
- Animated avatar render → Avatar-background condition: supplies renderings
- Scene or video → Avatar-background condition: supplies background
- Background inpainting → Avatar-background condition: supplies clean background
- Avatar-background condition → AniCrafter diffusion: conditions
- Model loading → AniCrafter diffusion: loads models for
- AniCrafter diffusion → Video diffusion models: runs diffusion models
- Single-GPU entry → Model loading: loads
- Single-GPU entry → AniCrafter diffusion: invokes
- USP entry → Model loading: loads
- USP entry → AniCrafter diffusion: invokes with USP
- Replacement entry → Human masks: invokes
- Replacement entry → Pose and SMPLX: invokes
- Replacement entry → Background inpainting: invokes
- Replacement entry → Model loading: loads
- Replacement entry → AniCrafter diffusion: invokes
- AniCrafter diffusion → Rendered video output: generates
