模型概述
模型特點
模型能力
使用案例
🚀 Wan2.1
Wan2.1是一套全面且開放的視頻基礎模型套件,突破了視頻生成的邊界。它具有卓越的性能,支持消費級GPU,能完成多種任務,還具備視覺文本生成能力和強大的視頻VAE。
🚀 快速開始
安裝
克隆倉庫:
git clone https://github.com/Wan-Video/Wan2.1.git
cd Wan2.1
安裝依賴:
# 確保torch >= 2.4.0
pip install -r requirements.txt
模型下載
模型 | 下載鏈接 | 說明 |
---|---|---|
T2V-14B | 🤗 Huggingface 🤖 ModelScope | 支持480P和720P |
I2V-14B-720P | 🤗 Huggingface 🤖 ModelScope | 支持720P |
I2V-14B-480P | 🤗 Huggingface 🤖 ModelScope | 支持480P |
T2V-1.3B | 🤗 Huggingface 🤖 ModelScope | 支持480P |
⚠️ 重要提示
1.3B模型能夠生成720P分辨率的視頻。然而,由於在該分辨率下的訓練有限,與480P相比,結果通常不太穩定。為獲得最佳性能,建議使用480P分辨率。
使用🤗 huggingface-cli下載模型:
pip install "huggingface_hub[cli]"
huggingface-cli download Wan-AI/Wan2.1-I2V-14B-480P --local-dir ./Wan2.1-I2V-14B-480P
使用🤖 modelscope-cli下載模型:
pip install modelscope
modelscope download Wan-AI/Wan2.1-I2V-14B-480P --local_dir ./Wan2.1-I2V-14B-480P
運行圖像到視頻生成
與文本到視頻類似,圖像到視頻也分為有提示擴展步驟和無提示擴展步驟的過程。具體參數及其對應設置如下:
任務 | 480P分辨率 | 720P分辨率 | 模型 |
---|---|---|---|
i2v-14B | ❌ | ✔️ | Wan2.1-I2V-14B-720P |
i2v-14B | ✔️ | ❌ | Wan2.1-T2V-14B-480P |
(1)無提示擴展
- 單GPU推理
python generate.py --task i2v-14B --size 832*480 --ckpt_dir ./Wan2.1-I2V-14B-480P --image examples/i2v_input.JPG --prompt "Summer beach vacation style, a white cat wearing sunglasses sits on a surfboard. The fluffy-furred feline gazes directly at the camera with a relaxed expression. Blurred beach scenery forms the background featuring crystal-clear waters, distant green hills, and a blue sky dotted with white clouds. The cat assumes a naturally relaxed posture, as if savoring the sea breeze and warm sunlight. A close-up shot highlights the feline's intricate details and the refreshing atmosphere of the seaside."
💡 使用建議
對於圖像到視頻任務,
size
參數表示生成視頻的區域,其寬高比遵循原始輸入圖像的寬高比。
- 使用FSDP + xDiT USP進行多GPU推理
pip install "xfuser>=0.4.1"
torchrun --nproc_per_node=8 generate.py --task i2v-14B --size 832*480 --ckpt_dir ./Wan2.1-I2V-14B-480P --image examples/i2v_input.JPG --dit_fsdp --t5_fsdp --ulysses_size 8 --prompt "Summer beach vacation style, a white cat wearing sunglasses sits on a surfboard. The fluffy-furred feline gazes directly at the camera with a relaxed expression. Blurred beach scenery forms the background featuring crystal-clear waters, distant green hills, and a blue sky dotted with white clouds. The cat assumes a naturally relaxed posture, as if savoring the sea breeze and warm sunlight. A close-up shot highlights the feline's intricate details and the refreshing atmosphere of the seaside."
(2)使用提示擴展
使用Qwen/Qwen2.5-VL-7B-Instruct
進行本地提示擴展運行:
python generate.py --task i2v-14B --size 832*480 --ckpt_dir ./Wan2.1-I2V-14B-480P --image examples/i2v_input.JPG --use_prompt_extend --prompt_extend_model Qwen/Qwen2.5-VL-7B-Instruct --prompt "Summer beach vacation style, a white cat wearing sunglasses sits on a surfboard. The fluffy-furred feline gazes directly at the camera with a relaxed expression. Blurred beach scenery forms the background featuring crystal-clear waters, distant green hills, and a blue sky dotted with white clouds. The cat assumes a naturally relaxed posture, as if savoring the sea breeze and warm sunlight. A close-up shot highlights the feline's intricate details and the refreshing atmosphere of the seaside."
使用dashscope
進行遠程提示擴展運行:
DASH_API_KEY=your_key python generate.py --task i2v-14B --size 832*480 --ckpt_dir ./Wan2.1-I2V-14B-480P --image examples/i2v_input.JPG --use_prompt_extend --prompt_extend_method 'dashscope' --prompt "Summer beach vacation style, a white cat wearing sunglasses sits on a surfboard. The fluffy-furred feline gazes directly at the camera with a relaxed expression. Blurred beach scenery forms the background featuring crystal-clear waters, distant green hills, and a blue sky dotted with white clouds. The cat assumes a naturally relaxed posture, as if savoring the sea breeze and warm sunlight. A close-up shot highlights the feline's intricate details and the refreshing atmosphere of the seaside."
(3)運行本地Gradio
cd gradio
# 如果只在Gradio中使用480P模型
DASH_API_KEY=your_key python i2v_14B_singleGPU.py --prompt_extend_method 'dashscope' --ckpt_dir_480p ./Wan2.1-I2V-14B-480P
# 如果只在Gradio中使用720P模型
DASH_API_KEY=your_key python i2v_14B_singleGPU.py --prompt_extend_method 'dashscope' --ckpt_dir_720p ./Wan2.1-I2V-14B-720P
# 如果在Gradio中同時使用480P和720P模型
DASH_API_KEY=your_key python i2v_14B_singleGPU.py --prompt_extend_method 'dashscope' --ckpt_dir_480p ./Wan2.1-I2V-14B-480P --ckpt_dir_720p ./Wan2.1-I2V-14B-720P
✨ 主要特性
- 👍 SOTA性能:Wan2.1在多個基準測試中始終優於現有的開源模型和最先進的商業解決方案。
- 👍 支持消費級GPU:T2V - 1.3B模型僅需8.19 GB顯存,幾乎與所有消費級GPU兼容。它可以在RTX 4090上約4分鐘內生成一個5秒的480P視頻(不使用量化等優化技術),其性能甚至可與一些閉源模型相媲美。
- 👍 多任務支持:Wan2.1在文本到視頻、圖像到視頻、視頻編輯、文本到圖像和視頻到音頻等任務中表現出色,推動了視頻生成領域的發展。
- 👍 視覺文本生成:Wan2.1是首個能夠同時生成中文和英文文本的視頻模型,具有強大的文本生成能力,增強了其實用性。
- 👍 強大的視頻VAE:Wan - VAE具有出色的效率和性能,能夠對任意長度的1080P視頻進行編碼和解碼,同時保留時間信息,非常適合視頻生成任務。
📚 詳細文檔
人工評估
我們對圖像到視頻模型的性能進行了廣泛的人工評估,結果如下所示。結果清楚地表明,Wan2.1優於閉源和開源模型。
不同GPU上的計算效率
我們在不同的GPU上測試了不同Wan2.1模型的計算效率,結果以總時間 (s) / 峰值GPU內存 (GB) 的格式呈現。
此表中測試的參數設置如下: (1)對於8個GPU上的1.3B模型,設置
--ring_size 8
和--ulysses_size 1
; (2)對於1個GPU上的14B模型,使用--offload_model True
; (3)對於單個4090 GPU上的1.3B模型,設置--offload_model True --t5_cpu
; (4)對於所有測試,均未應用提示擴展,即未啟用--use_prompt_extend
。
Wan2.1介紹
Wan2.1基於主流的擴散變壓器範式設計,通過一系列創新在生成能力方面取得了顯著進展。這些創新包括新穎的時空變分自編碼器(VAE)、可擴展的訓練策略、大規模數據構建和自動化評估指標。這些貢獻共同提升了模型的性能和通用性。
(1)3D變分自編碼器
我們提出了一種新穎的3D因果VAE架構,稱為Wan - VAE,專門用於視頻生成。通過結合多種策略,我們提高了時空壓縮率,減少了內存使用,並確保了時間因果性。與其他開源VAE相比,Wan - VAE在性能效率方面具有顯著優勢。此外,我們的Wan - VAE可以對無限長度的1080P視頻進行編碼和解碼,而不會丟失歷史時間信息,特別適合視頻生成任務。
(2)視頻擴散DiT
Wan2.1在主流擴散變壓器範式內使用流匹配框架進行設計。我們的模型架構使用T5編碼器對多語言文本輸入進行編碼,每個變壓器塊中的交叉注意力將文本嵌入到模型結構中。此外,我們使用一個帶有線性層和SiLU層的MLP來處理輸入時間嵌入,並分別預測六個調製參數。這個MLP在所有變壓器塊中共享,每個塊學習一組不同的偏差。我們的實驗結果表明,在相同的參數規模下,這種方法顯著提高了性能。
模型 | 維度 | 輸入維度 | 輸出維度 | 前饋維度 | 頻率維度 | 頭數 | 層數 |
---|---|---|---|---|---|---|---|
1.3B | 1536 | 16 | 16 | 8960 | 256 | 12 | 30 |
14B | 5120 | 16 | 16 | 13824 | 256 | 40 | 40 |
數據
我們策劃並去重了一個包含大量圖像和視頻數據的候選數據集。在數據策劃過程中,我們設計了一個四步的數據清理過程,重點關注基本維度、視覺質量和運動質量。通過強大的數據處理管道,我們可以輕鬆獲得高質量、多樣化和大規模的圖像和視頻訓練集。
與SOTA模型的比較
我們將Wan2.1與領先的開源和閉源模型進行了比較,以評估其性能。使用我們精心設計的1035個內部提示集,我們在14個主要維度和26個子維度上進行了測試。然後,我們通過對每個維度的分數進行加權計算得出總分,權重來自匹配過程中的人類偏好。詳細結果如下所示,這些結果表明我們的模型優於開源和閉源模型。
📄 許可證
本倉庫中的模型遵循Apache 2.0許可證。我們對您生成的內容不主張任何權利,允許您自由使用這些內容,但您的使用必須符合本許可證的規定。您應對模型的使用負全部責任,不得使用模型分享任何違反適用法律、傷害個人或群體、傳播用於傷害的個人信息、傳播錯誤信息或針對弱勢群體的內容。有關完整的限制列表和您的權利詳情,請參閱許可證全文。
致謝
我們感謝SD3、Qwen、umt5 - xxl、diffusers和HuggingFace倉庫的貢獻者們的開放研究。
聯繫我們





