🚀 PostMalone Lora for WanVideo2.1
本项目是针对WanVideo2.1的PostMalone LoRA模型,可用于文本到视频的生成,通过特定触发词能生成带有PostMalone风格的视频。
🚀 快速开始
触发词
你需要使用 malone
来触发视频生成。
使用Diffusers库
pip install git+https://github.com/huggingface/diffusers.git
import torch
from diffusers.utils import export_to_video
from diffusers import AutoencoderKLWan, WanPipeline
from diffusers.schedulers.scheduling_unipc_multistep import UniPCMultistepScheduler
model_id = "Wan-AI/Wan2.1-T2V-14B-Diffusers"
vae = AutoencoderKLWan.from_pretrained(model_id, subfolder="vae", torch_dtype=torch.float32)
pipe = WanPipeline.from_pretrained(model_id, vae=vae, torch_dtype=torch.bfloat16)
flow_shift = 5.0
pipe.scheduler = UniPCMultistepScheduler.from_config(pipe.scheduler.config, flow_shift=flow_shift)
pipe.to("cuda")
pipe.load_lora_weights("shauray/PostMalone_WanLora")
pipe.enable_model_cpu_offload()
prompt = "malone a man walking through texas"
output = pipe(
prompt=prompt,
height=480,
width=720,
num_frames=81,
guidance_scale=5.0,
).frames[0]
export_to_video(output, "output.mp4", fps=16)
模型下载
该模型的权重以Safetensors格式提供。
在 文件与版本 选项卡中下载。
✨ 主要特性
- 效果展示:提供了不同训练步数(750步、1000步、1250步)生成的视频示例,其中1000步训练的模型可下载。
- 触发机制:使用特定触发词
malone
即可生成具有特定风格的视频。
- 兼容性:可与Diffusers库配合使用,适用于不同分辨率的视频生成。
📦 安装指南
使用以下命令安装所需的Diffusers库:
pip install git+https://github.com/huggingface/diffusers.git
💻 使用示例
基础用法
import torch
from diffusers.utils import export_to_video
from diffusers import AutoencoderKLWan, WanPipeline
from diffusers.schedulers.scheduling_unipc_multistep import UniPCMultistepScheduler
model_id = "Wan-AI/Wan2.1-T2V-14B-Diffusers"
vae = AutoencoderKLWan.from_pretrained(model_id, subfolder="vae", torch_dtype=torch.float32)
pipe = WanPipeline.from_pretrained(model_id, vae=vae, torch_dtype=torch.bfloat16)
flow_shift = 5.0
pipe.scheduler = UniPCMultistepScheduler.from_config(pipe.scheduler.config, flow_shift=flow_shift)
pipe.to("cuda")
pipe.load_lora_weights("shauray/PostMalone_WanLora")
pipe.enable_model_cpu_offload()
prompt = "malone a man walking through texas"
output = pipe(
prompt=prompt,
height=480,
width=720,
num_frames=81,
guidance_scale=5.0,
).frames[0]
export_to_video(output, "output.mp4", fps=16)
高级用法
在实际使用中,你可以根据需求调整参数,如 height
、width
、num_frames
、guidance_scale
等,以生成不同分辨率、帧数和风格的视频。例如:
import torch
from diffusers.utils import export_to_video
from diffusers import AutoencoderKLWan, WanPipeline
from diffusers.schedulers.scheduling_unipc_multistep import UniPCMultistepScheduler
model_id = "Wan-AI/Wan2.1-T2V-14B-Diffusers"
vae = AutoencoderKLWan.from_pretrained(model_id, subfolder="vae", torch_dtype=torch.float32)
pipe = WanPipeline.from_pretrained(model_id, vae=vae, torch_dtype=torch.bfloat16)
flow_shift = 3.0
pipe.scheduler = UniPCMultistepScheduler.from_config(pipe.scheduler.config, flow_shift=flow_shift)
pipe.to("cuda")
pipe.load_lora_weights("shauray/PostMalone_WanLora")
pipe.enable_model_cpu_offload()
prompt = "malone a man dancing in the rain"
output = pipe(
prompt=prompt,
height=480,
width=640,
num_frames=100,
guidance_scale=6.0,
).frames[0]
export_to_video(output, "rain_dance.mp4", fps=20)
📄 许可证
本项目采用Apache-2.0许可证。
📚 详细文档
模型信息
属性 |
详情 |
模型类型 |
基于Wan-AI/Wan2.1-T2V-14B的LoRA模型 |
训练数据 |
未提及 |
示例视频说明
- 前2个视频来自 [750步训练]
- 中间2个视频来自 [1000步训练],该模型可下载
- 最后2个视频来自 [1250步训练]