--- title: Wan 2.2 Animate Character Replace emoji: 🎬 colorFrom: purple colorTo: pink sdk: gradio sdk_version: 5.43.1 app_file: app.py pinned: false license: apache-2.0 short_description: Replace a video's character with Wan 2.2 Animate --- # Wan 2.2 Animate — Character Replace Upload a reference image (the character to insert) and a source video. The pipeline detects pose, face and body mask in the video with ViTPose/YOLO/SAM2, then re-renders it with the reference character using **Wan 2.2 Animate** on a free [ZeroGPU](https://huggingface.co/docs/hub/en/spaces-zerogpu) GPU. This Space is a vendored ComfyUI checkout (core + 4 custom node packs) driven headlessly by `app.py`, which wraps a workflow exported with [ComfyUI-to-Python-Extension](https://github.com/pydn/ComfyUI-to-Python-Extension) in a Gradio UI, following [Run ComfyUI workflows on Spaces](https://huggingface.co/blog/run-comfyui-workflows-on-spaces). ## How it's put together - `app.py` — Gradio UI + the exported workflow, adapted to: - download every model from the Hub at first launch (`download_models()`) instead of committing weights to the repo, - load the fixed models (UNET + LoRAs, CLIP, CLIP Vision, VAE, SAM2, detector) once at startup and keep them resident, and - run only the per-request part of the graph inside a `@spaces.GPU(duration=300)` function. - `custom_nodes/` — the 4 node packs this workflow depends on: - [ComfyUI-KJNodes](https://github.com/kijai/ComfyUI-KJNodes) - [ComfyUI-VideoHelperSuite](https://github.com/Kosinkadink/ComfyUI-VideoHelperSuite) - [ComfyUI-WanAnimatePreprocess](https://github.com/kijai/ComfyUI-WanAnimatePreprocess) - [ComfyUI-segment-anything-2](https://github.com/kijai/ComfyUI-segment-anything-2) - everything else (`comfy/`, `nodes.py`, `execution.py`, ...) is an unmodified checkout of [ComfyUI](https://github.com/comfyanonymous/ComfyUI). ## Models (downloaded automatically on first launch) | File | Source | |---|---| | `umt5_xxl_fp8_e4m3fn_scaled.safetensors` | `Comfy-Org/Wan_2.1_ComfyUI_repackaged` | | `clip_vision_h.safetensors` | `Comfy-Org/Wan_2.1_ComfyUI_repackaged` | | `wan_2.1_vae.safetensors` | `Comfy-Org/Wan_2.2_ComfyUI_Repackaged` | | `Wan2_2-Animate-14B_fp8_e4m3fn_scaled_KJ.safetensors` | `Kijai/WanVideo_comfy_fp8_scaled` | | `lightx2v_I2V_14B_480p_cfg_step_distill_rank64_bf16.safetensors` | `Kijai/WanVideo_comfy` | | `WanAnimate_relight_lora_fp16.safetensors` | `Kijai/WanVideo_comfy` | | `sam2.1_hiera_base_plus.safetensors` | `Kijai/sam2-safetensors` | | `yolov10m.onnx` | `Wan-AI/Wan2.2-Animate-14B` | | `vitpose-l-wholebody.onnx` | `JunkyByte/easy_ViTPose` | ## Known limitations - **ZeroGPU duration.** A full Wan 2.2 Animate render (14B UNET + SAM2 + ViTPose + YOLO, chained) can run long for a video model, but free-tier ZeroGPU rejects any `@spaces.GPU(duration=...)` above roughly 120s regardless of what the docs imply is possible (a 300s request was rejected outright as "illegal duration", partly because the `large` GPU size multiplies the requested duration for quota accounting). `app.py` is set to `duration=120`. A free account's *daily* ZeroGPU quota is also only 5 minutes total, so even a couple of runs near that ceiling can exhaust the whole day. Keep `Frame Load Cap` low while testing, and consider a PRO account (higher duration ceiling and 40 min/day quota) or a GPU quota grant for real use. - **VRAM.** ZeroGPU's default `large` size gives 48GB; if you see OOM errors, request `size="xlarge"` (96GB, 2x quota cost) on the `@spaces.GPU` decorator in `app.py`. - First launch is slow: it downloads ~20-30GB of models before the UI becomes usable.