用 Wan2.2 生成视频,快是真的快,但画面风格总是那几种,时间长了确实单调。想让它输出动漫风、油画感或者赛博朋克效果,光靠提示词很难扳过来。
这不是 Wan2.2 的错,定位摆在那里——50 亿参数的轻量模型,能在消费级显卡上秒出视频已经不容易。预训练数据偏向通用场景,风格多样性不是它的强项。
好消息是,不需要重新训练整个模型。LoRA 可以给它打上'风格补丁',几 MB 的小文件一挂,效果立竿见影。我自己折腾过几个风格,踩过一些坑,下面把整个流程梳理出来。
为什么是 LoRA
LoRA 相当于即插即用的风格插件。主干模型不动,只在注意力层旁边插入一小撮可训练参数,微调时就只动这几百万个参数,训练快,文件小,组合起来也方便。
Wan2.2 原版更像一个基本功扎实的画师,但个人风格不突出。LoRA 就是教它一种具体画法,比如吉卜力、水墨、赛博朋克,训练时只要 20-50 张风格统一的图片就行。
环境与数据
训练基础镜像一般自带 PyTorch、diffusers 等工具。我习惯用命令行跑脚本,你也可以用 Jupyter Lab 或 kohya_ss 的 WebUI,效果一样。
数据准备是整个过程最花精力的环节,也是决定上限的一步。10 张糊图不如 30 张精挑细选的图。
目标很明确:收集一组能代表目标风格的图片,风格统一但主题不能太雷同。我训吉卜力风格时,选了宫崎骏电影里的场景截图,有风景、建筑、人物,风格一致但画面各异。
每张图都要配描述文件(同名 .txt),内容要详细,包含风格关键词。比如:
a serene landscape in the style of Studio Ghibli, rolling green hills under a blue sky with fluffy clouds, a small cottage in the distance, anime style, vibrant colors, detailed background
别只写 ghibli style,那样模型学不到足够特征。打标签可以用 BLIP 或 WD14 Tagger 自动生成,再人工校准。
图片尺寸统一成 512x512,Wan2.2 训练分辨率大多是这个。我用 Python 脚本居中裁剪再缩放:
from PIL import Image
import os
input_dir = "./raw_images"
output_dir = "./processed_images"
target_size = (512, 512)
os.makedirs(output_dir, exist_ok=True)
for img_name in os.listdir(input_dir):
if img_name.lower().endswith(('.png', '.jpg', '.jpeg')):
img_path = os.path.join(input_dir, img_name)
img = Image.open(img_path)
# 等比缩放后居中裁剪
img.thumbnail((target_size[0]*2, target_size[1]*2), Image.Resampling.LANCZOS)
width, height = img.size
left = (width - target_size[])/
top = (height - target_size[])/
right = (width + target_size[])/
bottom = (height + target_size[])/
img_cropped = img.crop((left, top, right, bottom))
img_cropped.save(os.path.join(output_dir, img_name))

