AnyID / README.md
JonneyWang's picture
Upload folder using huggingface_hub
d516b06 verified
|
Raw
History Blame Contribute Delete
8.21 kB
---
license: cc-by-nc-sa-4.0
library_name: diffusers
pipeline_tag: image-to-video
base_model: Wan-AI/Wan2.2-TI2V-5B
base_model_relation: adapter
tags:
- video generation
- identity-preserving
- lora
- wan2.2
- image-to-video
- text-to-video
- cvpr2026
---
<h1 align='center'>AnyID: Ultra-Fidelity Universal Identity-Preserving Video Generation from Any Visual References</h1>
<p align='center'>
β˜† CVPR 2026 β˜†
</p>
<p align="center">
<strong><a href="https://scholar.google.com/citations?hl=en&user=zQnTBEoAAAAJ">Jiahao Wang</a><sup>1</sup></strong>
Β·
<strong><a href="https://scholar.google.com/citations?user=73JaDUQAAAAJ&hl=en&oi=ao">Hualian Sheng</a><sup>2</sup></strong>
Β·
<strong><a href="https://scholar.google.com/citations?user=LMVeRVAAAAAJ&hl=en&oi=ao">Sijia Cai</a><sup>2,&dagger;</sup></strong>
Β·
<strong><a href="https://scholar.google.com/citations?hl=zh-CN&user=WwKt4BEAAAAJ">Yuxiao Yang</a><sup>3</sup></strong>
Β·
<strong><a href="https://gr.xjtu.edu.cn/web/zhangwzh123/">Weizhan Zhang</a><sup>1,*</sup></strong>
Β·
<strong><a href="https://gr.xjtu.edu.cn/web/yancaixia">Caixia Yan</a><sup>1</sup></strong>
Β·
<strong><a href="https://scholar.google.com/citations?user=VQp_ye4AAAAJ&hl=zh-CN&oi=ao">Bing Deng</a><sup>2</sup></strong>
Β·
<strong><a href="https://scholar.google.com/citations?user=T9AzhwcAAAAJ&hl=zh-CN&oi=ao">Jieping Ye</a><sup>2</sup></strong>
<br>
<sup>1</sup>Xi'an Jiaotong University &nbsp;&nbsp;&nbsp;&nbsp;
<sup>2</sup>Alibaba Cloud &nbsp;&nbsp;&nbsp;&nbsp;
<sup>3</sup>Tsinghua University
<br>
<sup>*</sup>Corresponding Author &nbsp;&nbsp;&nbsp;&nbsp; <sup>&dagger;</sup>Project Lead
<br>
<br>
<a href="https://arxiv.org/abs/2603.25188"><img src='https://img.shields.io/badge/+-arXiv-b31b1b' alt='Paper PDF'></a>
<a href="https://johnneywang.github.io/AnyID-webpage"><img src='https://img.shields.io/badge/+-Project_Page-blue' alt='Project Page'></a>
<a href="https://github.com/JoHnneyWang/AnyID"><img src='https://img.shields.io/badge/+-GitHub-black'></a>
<a href="https://huggingface.co/JonneyWang/AnyID"><img src='https://img.shields.io/badge/+-HuggingFace-yellow'></a>
<br>
<br>
Please give us a star⭐ on GitHub if you like our work.
</p>
## πŸ“ Intro
**AnyID** is an **ultra-fidelity, universal identity-preserving video generation framework** that overcomes the limitations of single-reference methods by leveraging **multiple free-form inputs**, including faces, portraits, and video clips. By unifying heterogeneous references through a **scalable omni-referenced architecture** and employing a **primary-referenced generation paradigm with differential prompts**, AnyID achieves **precise attribute-level controllability** while maintaining **robust identity consistency** across varying angles and expressions. Further refined by **human-centric reinforcement learning**, the framework delivers superior visual quality, ensuring both **high-fidelity character preservation** and **accurate adherence to user instructions**. Hope you have fun with this demo! 🎬
![](./assets/teaser.jpg)
> ⚠️ **Preview release.** The weights hosted in this repository are a **preview version**,
> released for research and evaluation purposes. They may be updated or replaced with an
> improved version in the future.
## 🧩 Model Card
This repository hosts the **AnyID LoRA**, a lightweight adapter trained on top of the
**[Wan2.2 TI2V-5B](https://huggingface.co/Wan-AI/Wan2.2-TI2V-5B)** video diffusion backbone.
It does **not** contain the base model β€” download Wan2.2 TI2V-5B separately (see [Quick Start](#-quick-start)).
| Item | Value |
|-----------------|--------------------------------------------------------------------|
| Version | **Preview** (subject to future updates) |
| Model type | LoRA adapter (PEFT) |
| Base model | [Wan-AI/Wan2.2-TI2V-5B](https://huggingface.co/Wan-AI/Wan2.2-TI2V-5B) |
| Rank / Alpha | 256 / 256 (scaling = 1.0) |
| Target modules | All `nn.Linear` layers (self-/cross-attention `q,k,v,o`, FFN, embeddings, head) |
| Precision | bf16 |
| Task | Identity-preserving text/image/video β†’ video generation |
### Files in this repository
| File | Description |
|--------------------------|----------------------------------------------|
| `anyid_lora.safetensors` | AnyID LoRA weights |
| `lora_config.json` | PEFT LoRA config (rank / alpha / targets) |
## πŸš€ Quick Start
The inference code lives in the [GitHub repository](https://github.com/JoHnneyWang/AnyID).
**1. Get the code and set up the environment** (NVIDIA A100, CUDA 12.1):
```bash
git clone https://github.com/JoHnneyWang/AnyID.git
cd AnyID
conda create -n anyid python=3.10 -y
conda activate anyid
pip install torch torchvision --index-url https://download.pytorch.org/whl/cu121
pip install flash-attn --no-build-isolation
pip install -r requirements.txt
```
**2. Download the weights** β€” the base Wan2.2 TI2V-5B and this AnyID LoRA:
```bash
# Base model (T5 + VAE + base DiT)
huggingface-cli download Wan-AI/Wan2.2-TI2V-5B --local-dir checkpoints/Wan2.2-TI2V-5B
# AnyID LoRA (this repository)
huggingface-cli download JonneyWang/AnyID --local-dir checkpoints/AnyID
```
**3. Merge the LoRA into the DiT.** Injecting the LoRA dynamically takes minutes to load,
so pre-merge it into the DiT once (the merged weights are written into the LoRA directory):
```bash
PYTHONPATH=. python trainer/models/wan22/merge_lora.py \
--ckpt_dir checkpoints/Wan2.2-TI2V-5B \
--lora_path checkpoints/AnyID
```
**4. Run inference** β€” T5/VAE are loaded from the base folder, the merged DiT from the AnyID folder:
```bash
CKPT_DIR=checkpoints/Wan2.2-TI2V-5B \
MERGED_DIT=checkpoints/AnyID \
bash scripts/infer.sh
```
Or call the generator directly:
```bash
PYTHONPATH=. torchrun --nproc_per_node=1 \
trainer/models/wan22/generate.py \
--task ti2v-5B --size 1280*704 \
--ckpt_dir checkpoints/Wan2.2-TI2V-5B \
--merged_dit checkpoints/AnyID \
--prompt prompts/example.json \
--frame_num 121 \
--sample_guide_scale 4.0 --sample_shift 5.0 \
--convert_model_dtype --offload_model False \
--out_dir outputs
```
## πŸ“₯ Input Format
The prompt file is a JSON list of items. Each item carries a **differential prompt** and a single
unified **`ref`** field β€” a path or a list of paths β€” that works for both image and video
references. The **first** reference is the primary reference; the rest are auxiliary. Use **either**
up to **five images** **or** **one video** (they cannot be mixed). See
[`prompts/example.json`](https://github.com/JoHnneyWang/AnyID/blob/main/prompts/example.json) in the
GitHub repo for a runnable example.
```json
[
{
"ref": ["person_primary.png", "person_auxiliary.png"],
"prompt": "..."
}
]
```
## πŸ“š Citation
If you find AnyID useful in your research, please consider citing:
```bibtex
@InProceedings{Wang_2026_CVPR,
author = {Wang, Jiahao and Sheng, Hualian and Cai, Sijia and Yang, Yuxiao and Zhang, Weizhan and Yan, Caixia and Deng, Bing and Ye, Jieping},
title = {AnyID: Ultra-Fidelity Universal Identity-Preserving Video Generation from Any Visual References},
booktitle = {Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)},
month = {June},
year = {2026},
pages = {12808-12817}
}
```
## πŸ™ Acknowledgements
We would like to express our sincere thank to [Wan Team](https://github.com/Wan-Video) for their support.
## πŸ“„ License
This model is released under the [CC BY-NC-SA 4.0](LICENSE) license. You are free to share and
adapt this work for **non-commercial** purposes only, with proper attribution and under the same
license.