Ryuko Matoi 🎬 Wan2.1-T2V-14B
详情
下载文件
模型描述
描述
"管你什么意见,我走我的路,不管别人怎么说。" —— 真子琉子
使用方法
触发词是 "Ryuko-chan"。
我没有固定的提示词格式(仍在试验中),但我通常所有提示都以 "High quality 2D art animation." 开头。例如:"High quality 2d art animation. Ryuko-chan, with long red hair and a black trench coat, stands on top of a ruined skyscraper. The city burns in the distance, smoke rising into the dark sky. The wind makes her coat billow as she crosses her arms. The camera suddenly zooms in on her determined face. She smirks, tilts her head slightly, and winks."
推理时,我使用 Kijai 的包装器。遗憾的是,Civitai 似乎无法解析其元数据,但每个片段中应已嵌入工作流。为防万一,这里有一个 JSON 格式的工作流示例。它仍在开发中,右侧有些杂乱,但整体功能完备。
我发布的所有片段均为 LoRA 的原始输出,未使用超分辨率或帧插值(这些会歪曲 LoRA 的真实能力)。所有片段使用以下恒定参数:
Sampler: unipc
Steps: 20
Cfg: 6
Shift: 7
如果你查看我的工作流,你会发现我使用了自 Wan2.1 发布以来所有可能的优化技术。我真心感谢软件开发者和机器学习工程师(Comfyanonymous、Kijai、TeaCache 团队以及许多其他人),是他们让在消费级显卡上以令人满意的速度运行 Kling 级别的视频模型成为可能,且(几乎)不牺牲画质。
我最初使用的是“纯”FP8 + SDPA,以下是每种优化技术带来的速度提升明细。
参考配置:RTX 3090,64GB 内存,Win 11,Python 3.11.6,Torch 2.7.0.dev20250311+cu126,Sage Attention 2.1.1,Triton 3.2.0,NVIDIA 驱动 572.16,ComfyUI portable v0.3.26。
我下面提到的时间不包括画廊中展示片段的渲染时间,这些片段大多是 640x480x81,会额外增加约两分钟。但没关系,因为我通常一次启动 50–60 个提示,几小时后再回来收集结果。
然而,对我而言最重要的是在测试和比较不同 LoRA 版本时运行 Wan-14B T2V 的时间。在此阶段,我使用 512x512x65 的尺寸。99% 的测试片段生成后立即被删除,但它们能清晰反映 LoRA 的质量,因此我必须尽可能缩短测试推理时间。
对于 512x512x65 片段,20 步,UniPC 采样器:
(仅考虑 DiT 推理阶段,因为优化不影响 UMT5 编码提示或 VAE 解码潜变量所需的时间,且这些时间可忽略不计,仅需 2–3 秒。)
fp8_e4m3fn + sdpa -> 09:24(28.24 秒/步)
fp8_e4m3fn + sageattention 2 -> 06:53(20.70 秒/步)+36%(1.36x)
fp8_e52m + torch.compile + sageattention 2 -> 06:21(19.08 秒/步)+48%(1.48x)
fp8_e52m + torch.compile + sageattention 2 + teacache (0.250/6) -> 04:29(13.50 秒/步)+109%(2.09x)
fp8_e52m + torch.compile + sageattention 2 + teacache + fp16_fast -> 03:23(10.19 秒/步)+177%(2.77x)
因此,速度提升了近三倍,而画质损失极小(至少对我而言;你的体验可能不同)。我使用相同种子,对比启用和禁用 TeaCache/Sage Attention 2 的片段,老实说,我无法察觉明显的画质下降。也许在极其复杂、运动剧烈的提示中会有轻微差异,但即使在“原始”模式下,这些片段本身也经常表现不佳。如果有必要,我还大量使用 Enhance-A-Video 和 SLG(第 9 层,0.2–0.8),它们似乎对片段质量有正面影响,能改善画质并减轻运动伪影。
速度提升是我从 HV 切换到 Wan 的主要因素之一。虽然 Wan 的画质更好,但我习惯 HV 的快速渲染,而 Wan 能达到相近的速度,让这次切换变得值得。
训练
我使用了 215 张图像(大部分是从《Kill la Kill》全部 25 集的 18,461 张屏幕截图中手动挑选的,外加少量官方艺术图)。使用 THUDM/cogvlm2-llama3-chat-19B 进行标注,提示如下:
"详细描述这幅作品,聚焦于视觉风格、场景、氛围和艺术技法。当画面中出现黑发女性角色时,称其为 Ryuko-chan。提及她的服装、配饰和姿态,但不要描述她的面部特征、身体比例或生理属性。包含具体艺术风格术语(如赛璐珞上色、绘画性、水彩、数字插画)和定义美学的视觉元素。描述光线、配色方案、构图及任何显著的艺术影响。"
我的想法是,以一种方式标注,使我能够自由更改琉子的服装和发色,同时保持其外观的其他方面(面部、身体等)真实可辨。这确实奏效了,WanVideo 表现得非常出色(我希望你能从我发布的例子中看到)。遗憾的是,齿轮状瞳孔未被模型记住,但我的数据集中缺乏足够多的特写镜头。
除了 Ryuko,我没有用任何其他名字标注内容,因此模型可能学习了 Senketsu 和剪刀刀刃的视觉特征,但明确提及它们可能无效(尽管我未充分测试)。但这本就是我的意图——只想教会模型关于 Ryuko 本人及其外貌的内容。
如果未明确描述她的服装和发色,系统通常会默认使用她原版的服装。在日常场景中,她会穿普通校服;而在战斗和激烈场景中,她更倾向于穿 Senketsu。
(最初我计划制作一个纯角色 LoRA,这样我也可以用写实风格绘制 Ryuko,但数据集偏差太强,最终只能呈现原作风格,这其实也不算坏事。更准确地说,这应该是一个混合角色/风格 LoRA。)
第一个版本的 LoRA 使用 13 亿参数模型通过 diffusion-pipe 训练,但我不满意结果——13 亿模型(在我看来)太小,画质无法与 HV 竞争(唯一优势是速度和资源需求)。第二个版本使用 ai-toolkit 训练,但 LoRA 效果也未达预期(我认为是因为 ai-toolkit 尚不支持带标注训练)。
最终,成功版本是使用 140 亿模型通过 musubi-tuner 训练的。以下是我使用的命令(我通常为启动 musubi-tuner 流程创建 .bat 文件,因此训练命令采用此格式)。简要说明:几乎所有重要参数与默认值相同,唯独学习率修改为 7e-5。我训练了 40 个周期(共 17,630 步,每周期 430 步),经过三天测试,选择第 15,050 步的检查点为最佳结果。我本可训练更多步数,因为模型似乎仍在进步,训练损失趋势也令人鼓舞。
- 缓存潜变量(vae):
python wan_cache_latents.py --dataset_config G:/samples/musubi-tuner/_ryuko_matoi_wan14b_config.toml --vae G:/samples/musubi-tuner/wan14b/vae/wan_2.1_vae.safetensors
- 缓存提示(t_enc):
python wan_cache_text_encoder_outputs.py --dataset_config G:/samples/musubi-tuner/_ryuko_matoi_wan14b_config.toml --t5 G:/samples/musubi-tuner/wan14b/tenc/models_t5_umt5-xxl-enc-bf16.pth --batch_size 16
- 数据集配置(我未手动编写,而是用小脚本扫描图像文件夹,计算每张图像的缩放分辨率,确保最大尺寸不超过 720 像素,同时保持近似宽高比且尺寸能被 16 整除——但不实际重绘图像,仅提前为 musubi-tuner 的分桶机制做准备,再将相同尺寸的图像分组到子文件夹,并生成包含元数据的 YAML 文件):
[general]
caption_extension = ".txt"
batch_size = 1
enable_bucket = true
bucket_no_upscale = false
[[datasets]]
resolution = [528, 768]
image_directory = "H:/datasets/ryuko_matoi_wan_video/1057x1516x1"
cache_directory = "H:/datasets/ryuko_matoi_wan_video/1057x1516x1/cache"
num_repeats = 2
[[datasets]]
resolution = [768, 432]
image_directory = "H:/datasets/ryuko_matoi_wan_video/1280x720x1"
cache_directory = "H:/datasets/ryuko_matoi_wan_video/1280x720x1/cache"
num_repeats = 2
[[datasets]]
resolution = [592, 768]
image_directory = "H:/datasets/ryuko_matoi_wan_video/1600x2033x1"
cache_directory = "H:/datasets/ryuko_matoi_wan_video/1600x2033x1/cache"
num_repeats = 2
[[datasets]]
resolution = [400, 768]
image_directory = "H:/datasets/ryuko_matoi_wan_video/1727x3264x1"
cache_directory = "H:/datasets/ryuko_matoi_wan_video/1727x3264x1/cache"
num_repeats = 2
[[datasets]]
resolution = [720, 768]
image_directory = "H:/datasets/ryuko_matoi_wan_video/1917x2002x1"
cache_directory = "H:/datasets/ryuko_matoi_wan_video/1917x2002x1/cache"
num_repeats = 2
[[datasets]]
resolution = [768, 432]
image_directory = "H:/datasets/ryuko_matoi_wan_video/1920x1080x1"
cache_directory = "H:/datasets/ryuko_matoi_wan_video/1920x1080x1/cache"
num_repeats = 2
[[datasets]]
resolution = [736, 768]
image_directory = "H:/datasets/ryuko_matoi_wan_video/1920x1963x1"
cache_directory = "H:/datasets/ryuko_matoi_wan_video/1920x1963x1/cache"
num_repeats = 2
[[datasets]]
resolution = [480, 768]
image_directory = "H:/datasets/ryuko_matoi_wan_video/1920x3038x1"
cache_directory = "H:/datasets/ryuko_matoi_wan_video/1920x3038x1/cache"
num_repeats = 2
[[datasets]]
resolution = [768, 576]
image_directory = "H:/datasets/ryuko_matoi_wan_video/2363x1813x1"
cache_directory = "H:/datasets/ryuko_matoi_wan_video/2363x1813x1/cache"
num_repeats = 2
[[datasets]]
resolution = [768, 624]
image_directory = "H:/datasets/ryuko_matoi_wan_video/3877x3208x1"
cache_directory = "H:/datasets/ryuko_matoi_wan_video/3877x3208x1/cache"
num_repeats = 2
[[datasets]]
resolution = [640, 768]
image_directory = "H:/datasets/ryuko_matoi_wan_video/690x820x1"
cache_directory = "H:/datasets/ryuko_matoi_wan_video/690x820x1/cache"
num_repeats = 2
[[datasets]]
resolution = [576, 768]
image_directory = "H:/datasets/ryuko_matoi_wan_video/690x920x1"
cache_directory = "H:/datasets/ryuko_matoi_wan_video/690x920x1/cache"
num_repeats = 2
[[datasets]]
resolution = [512, 768]
image_directory = "H:/datasets/ryuko_matoi_wan_video/800x1195x1"
cache_directory = "H:/datasets/ryuko_matoi_wan_video/800x1195x1/cache"
num_repeats = 2
[[datasets]]
resolution = [768, 496]
image_directory = "H:/datasets/ryuko_matoi_wan_video/935x608x1"
cache_directory = "H:/datasets/ryuko_matoi_wan_video/935x608x1/cache"
num_repeats = 2
- 采样文件:
# prompt 1
Ryuko-chan with blonde hair is walking on the beach, camera zoom out. --w 384 --h 384 --f 45 --d 7 --s 20
# prompt 2
Ryuko-chan dancing in the bar. --w 384 --h 384 --f 45 --d 7 --s 20
- 训练命令:
accelerate launch --num_cpu_threads_per_process 1 --mixed_precision bf16 wan_train_network.py ^
--task t2v-14B ^
--dit G:/samples/musubi-tuner/wan14b/dit/wan2.1_t2v_14B_bf16.safetensors ^
--vae G:/samples/musubi-tuner/wan14b/vae/wan_2.1_vae.safetensors ^
--t5 G:/samples/musubi-tuner/wan14b/tenc/models_t5_umt5-xxl-enc-bf16.pth ^
--dataset_config G:/samples/musubi-tuner/_ryuko_matoi_wan14b_config.toml ^
--sdpa ^
--mixed_precision bf16 ^
--fp8_base ^
--fp8_t5 ^
--optimizer_type adamw8bit ^
--learning_rate 7e-5 ^
--gradient_checkpointing ^
--max_data_loader_n_workers 2 ^
--persistent_data_loader_workers ^
--network_module networks.lora_wan ^
--network_dim 32 ^
--network_alpha 32 ^
--timestep_sampling shift ^
--discrete_flow_shift 3.0 ^
--max_train_epochs 50 ^
--save_every_n_epochs 1 ^
--seed 42 ^
--output_dir G:/samples/musubi-tuner/output ^
--output_name ryuko_matoi_wan14b ^
--log_config ^
--log_with tensorboard ^
--logging_dir G:/samples/musubi-tuner/logs ^
--sample_prompts G:/samples/musubi-tuner/_ryuko_matoi_wan14b_sampling.txt ^
--save_state ^
--sample_every_n_epochs 1
训练期间速度约为 4 秒/步,VRAM 使用约 21GB。除 --fp8_base 和 --fp8_t5 外,未应用其他特定优化。
尚未对与其他 LoRA 的兼容性进行测试(也无计划进行)。
也未在 I2V 模型上测试过(事实上,我甚至还没下载任何一个)。
(哦,我还随 LoRA 一起发布了数据集,但其中并无特别之处。)
结论
这是我第一个(成功的)针对 Wan Video 2.1-T2V 14B 的 LoRA,我必须说我对这个模型感到非常兴奋。训练它是一种享受,而且它对概念和风格的理解能力极强(基于我目前有限的经验)。我迫不及待想训练我计划中的所有 LoRA!迄今为止,我仅训练过用于风格的生成式 AI 模型,但现在我非常热衷于训练不仅涵盖风格,还包括视觉特效、概念、动作等的模型。
回到这个 LoRA,我不能说它完美无缺,但在生成的三个片段中,有一个是成功的(即符合提示且无不良伪影),我认为这已算成功。我将此归功于模型本身。尽管我仅使用图像训练了这个 LoRA(未来的 LoRA 我也会使用视频片段),但模型学习(或更准确地说,推断)了大量关于原系列动画技术与视觉特征的内容,例如户外场景中过度(且并不总是恰当 xD)使用的镜头光晕、夸张的面部动画等。
我还觉得,这个模型得益于多样化的数据集(至少 100 张图像)和较低的学习率(1e-4 太高了)。对于我的下一个 LoRA,我将使用不超过 5e-5 的学习率。虽然可能需要更多训练步数,但这样能更好地学习所有细节而不出现过拟合。




















