AnimateDiff简介
Stable Diffusion的AnimateDiff插件是一个用于生成和操作图像的强大工具,它属于Stable Diffusion模型的一个扩展。

如果放在几年前,你告诉我说只需一分钟就能做出一段这样的动画,我是万万不相信的,但是当AI时代来临之后,一切都有了可能。
今天给大家介绍一个可以快速在sd中生成动画的方法,就是一个叫做AnimateDiff的免费开源项目。现在已经整合到了webUI上面,使用起来非常方便。

AnimateDiff安装和配置
AnimateDiff的github主页:https://github.com/continue-revolution/sd-webui-animatediff
安装插件主体
- 方法一
在stable diffusion的“扩展(extensions)”菜单,选择“可用(available)”,点击“加载自(load from)”,搜索“animatediff”,点击“安装(install)
- 方法二
访问animatediff的github主页,点击绿色按钮“code”,点击复制HTTPS的按钮复制animatediff的库链接
打开stable diffusion,找到“扩展(extensions)”菜单,选择“从网址安装(install from URL)”子菜单,将上面复制的库网址粘贴到“扩展的git仓库网址(URL ro extension’s git repository)”,最后点击“安装(install)”
- 方法三
访问animatediff的github主页,点击绿色按钮“code”,点击“Download ZIP”,将animatediff的库ZIP压缩包下载到本地,将下载的ZIP压缩包剪切到“\stable-diffusion-webui\extensions”文件夹下面,然后右键选择“解压到当前文件夹”
animatediff本体安装成功
这一步安装成功之后,就可以在stable diffusion的文生图和图生图都可以找到“AnimateDiff”这个插件

下载安装模型
ainimateDiff的huggingface的模型下载页面:https://huggingface.co/guoyww/animatediff/tree/main
网盘下载(备用):model、animatediff
下载3个主模型放在“\stable-diffusion-webui\extensions\sd-webui-animatediff\model”文件夹;

下载8个lora模型放在“\stable-diffusion-webui\models\Lora\animatediff”文件夹,其中的“animatediff”文件夹为lora文件夹下面自行新建的一个文件夹,避免与其他的lora模型混淆;
使用
目前最新的是mm_sd_v15_v2.safetensors,动画的活动范围更大,效果也最好。

帧率默认是8,如果我们想要一个4秒的动画,总帧数设置为32就可以了。

开启闭环可以得到一个无限循环的动画。

输出格式,通常我们会选择GIF,如果想要每一帧单独的输出,可以选择png。

接下来,我们选择模型,并输入提示词,我描述的是“一只在草原上奔跑的白马”。

参数可以按照正常出图的思路设置,尺寸512×512,根据电脑配置量力而行。

点击生成,就可以得到一幅白马奔跑的小动画了,不过这幅图的马腿脚看上去有点不太自然。

同时,这个动画插件还可以在图生图中使用。比如我们在文生图中生成了一张白马的静态图片,然后将它发送到图生图中。

提示词中我们可以增加“流动的云、奔跑的马”等提示词。

重绘幅度设置为0.8,数值越大,动态越明显,如果数值太小,马就不会跑起来。

我们可以看到,白马就奔跑了起来,而且天空中有云层的流动。当然我们有一说一,这个马奔跑的效果还不是很完美。

AnimateDiff 与 Lora 结合使用
您可以使用运动 LoRA 将摄像机运动添加到视频中。它们的使用方式与标准 LoRA相同。
我们还可以配合lora来做一些镜头控制,可以让动画的控制变得更强。lora的下载地址为:https://github.com/guoyww/AnimateDiff#features,包括有向左平移、向右平移、逆时针转动、顺时针转动、向下移动、向上移动、放大、缩小。

我们先使用文生图生成一个女孩在街头的动态图片,可以看到这时候的镜头是稳定不动的。

接下来我增加一个v2_lora_Zoomout的lora,来控制镜头的缩小。

我们就得到了一个希区柯克式的变焦效果,拍摄效果非常不错。

更多的例子:
AnimateDiff+PanLeft(镜头左移)
正面提示词: ((best quality)), ((masterpiece)), ((realistic)), long highlighted hair, cybergirl, futuristic silver armor suit, confident stance, high-resolution, living room, smiling, head tilted <lora:v2_lora_PanLeft:1> 负面提示词: (worst quality:1.2), (low quality:1.2), (lowres:1.1), (monochrome:1.1), (greyscale), multiple views, comic, sketch, (((bad anatomy))), (((deformed))), (((disfigured))), watermark, multiple_views, mutation hands, mutation fingers, extra fingers, missing fingers, watermark, nude, nsfw 您会看到背景向右移动,表明相机正在向左平移。
AnimateDiff+PanRight(镜头右移)
正面提示词: ((best quality)), ((masterpiece)), ((realistic)), long highlighted hair, cybergirl, futuristic silver armor suit, confident stance, high-resolution, living room, smiling, head tilted <lora:v2_lora_PanRight:0.75> 负面提示词: (worst quality:1.2), (low quality:1.2), (lowres:1.1), (monochrome:1.1), (greyscale), multiple views, comic, sketch, (((bad anatomy))), (((deformed))), (((disfigured))), watermark, multiple_views, mutation hands, mutation fingers, extra fingers, missing fingers, watermark, nude, nsfw
AnimateDiff+RollingAnticlockwise(镜头逆时针滚动)
正面提示词: ((best quality)), ((masterpiece)), ((realistic)), long highlighted hair, cybergirl, futuristic silver armor suit, confident stance, high-resolution, living room, smiling, head tilted <lora:v2_lora_RollingAnticlockwise:0.75> 负面提示词: (worst quality:1.2), (low quality:1.2), (lowres:1.1), (monochrome:1.1), (greyscale), multiple views, comic, sketch, (((bad anatomy))), (((deformed))), (((disfigured))), watermark, multiple_views, mutation hands, mutation fingers, extra fingers, missing fingers, watermark, nude, nsfw
AnimateDiff+RollingClockwise(镜头顺时针滚动)
正面提示词: ((best quality)), ((masterpiece)), ((realistic)), long highlighted hair, cybergirl, futuristic silver armor suit, confident stance, high-resolution, living room, smiling, head tilted <lora:v2_lora_RollingClockwise:0.75> 负面提示词: (worst quality:1.2), (low quality:1.2), (lowres:1.1), (monochrome:1.1), (greyscale), multiple views, comic, sketch, (((bad anatomy))), (((deformed))), (((disfigured))), watermark, multiple_views, mutation hands, mutation fingers, extra fingers, missing fingers, watermark, nude, nsfw
AnimateDiff+TiltDown(镜头下沉)
正面提示词: ((best quality)), ((masterpiece)), ((realistic)), long highlighted hair, cybergirl, futuristic silver armor suit, confident stance, high-resolution, living room, smiling, head tilted <lora:v2_lora_TiltDown:0.75> 负面提示词: (worst quality:1.2), (low quality:1.2), (lowres:1.1), (monochrome:1.1), (greyscale), multiple views, comic, sketch, (((bad anatomy))), (((deformed))), (((disfigured))), watermark, multiple_views, mutation hands, mutation fingers, extra fingers, missing fingers, watermark, nude, nsfw
AnimateDiff+TiltUp(镜头上升)
正面提示词: ((best quality)), ((masterpiece)), ((realistic)), long highlighted hair, cybergirl, futuristic silver armor suit, confident stance, high-resolution, living room, smiling, head tilted <lora:v2_lora_TiltUp:0.75> 负面提示词: (worst quality:1.2), (low quality:1.2), (lowres:1.1), (monochrome:1.1), (greyscale), multiple views, comic, sketch, (((bad anatomy))), (((deformed))), (((disfigured))), watermark, multiple_views, mutation hands, mutation fingers, extra fingers, missing fingers, watermark, nude, nsfw
AnimateDiff+ZoomIn(镜头拉近)
正面提示词: ((best quality)), ((masterpiece)), ((realistic)), long highlighted hair, cybergirl, futuristic silver armor suit, confident stance, high-resolution, living room, smiling, head tilted <lora:v2_lora_ZoomIn:0.75> 负面提示词: (worst quality:1.2), (low quality:1.2), (lowres:1.1), (monochrome:1.1), (greyscale), multiple views, comic, sketch, (((bad anatomy))), (((deformed))), (((disfigured))), watermark, multiple_views, mutation hands, mutation fingers, extra fingers, missing fingers, watermark, nude, nsfw
AnimateDiff+ZoomOut(镜头拉远)
正面提示词: ((best quality)), ((masterpiece)), ((realistic)), long highlighted hair, cybergirl, futuristic silver armor suit, confident stance, high-resolution, living room, smiling, head tilted <lora:v2_lora_ZoomOut:0.75> 负面提示词: (worst quality:1.2), (low quality:1.2), (lowres:1.1), (monochrome:1.1), (greyscale), multiple views, comic, sketch, (((bad anatomy))), (((deformed))), (((disfigured))), watermark, multiple_views, mutation hands, mutation fingers, extra fingers, missing fingers, watermark, nude, nsfw