ComfyUI教程 5分钟制作丝滑的AI视频-AnimateDiff

1. AnimateDiff的技术原理

AnimateDiff可以搭配扩散模型算法(Stable Diffusion)[来生成高质量的动态视频](https://blog.youkuaiyun.com/weixin_66363548/article/details/134036591),其中动态模型(Motion Models)用来实时跟踪人物的动作以及画面的改变。

2. 环境搭建

这里我们使用ComfyUI来搭配AnimateDiff做视频转视频的工作流。

我预设ComfyUI的环境已经搭建好了,这里就只介绍如何安装AnimateDiff插件。

3. ComfyUI AnimateDiff视频转视频工作流

找到一个真人跳舞视频

提取视频帧,并用ControlNet Openpose提取人物动作信息

根据视频帧里面的动作信息,使用SD重新绘制每一帧视频

组合出完整视频

3.1 读取ComfyUI工作流

直接把下面这张图拖入ComfyUI界面,它会自动载入工作流,或者下载这个工作流的JSON文件,在ComfyUI里面载入文件信息。
在这里插入图片描述

工作流参考
https://pan.quark.cn/s/c828ca989603

3.2 安装缺失的node组件

第一次载入这个工作流之后,ComfyUI可能会提示有node组件未被发现,我们需要通过ComfyUI manager安装,它会自动找到缺失的组件并下载安装(!!需要网络通畅)。
在这里插入图片描述

点击ComfyUI Manager按钮打开组件管理
在这里插入图片描述

再点击Install Missing Custom Nodes安装组件

在这里插入图片描述

安装完成后要重启ComfyUI才能完成载入刚才缺失的组件。

!如果网络状态不好,可能会导致下载组件失败,需要多试几次

3.3 下载一个AI绘画模型

这里比较推荐C站上的Dreamshaper 8这个模型,实测动画人物效果比较好,当然大家也可以自己去测试其他的模型,有好的效果,欢迎评论留言。

下载好的模型放到ComfyUI > models > checkpoints目录。

然后刷新页面

在Load Checkpoint这个组件里可以选择不同的模型
在这里插入图片描述

3.4 再下载一个VAE模型

下载VAE,放到ComfyUI > models > vae这个目录里。

然后刷新页面

在Load VAE里可以选择不同的编码器模型
在这里插入图片描述

3.5 下载AnimateDiff动态特征模型

下载mm_sd_v15_v2.ckpt,放到ComfyUI > custom_nodes > ComfyUI-AnimateDiff-Evolved > models文件夹。

刷新页面

在AnimateDiff Loader里,可以选择我们需要的动态特征模型
在这里插入图片描述

3.6 下载Openpose ControlNet模型

下载control_v11p_sd15_openpose.pth,放到ComfyUI > models > controlnet文件夹。

刷新页面

在 Load ControlNet Model (Advanced)里,选择对应模型
在这里插入图片描述
下载lora

https://huggingface.co/guoyww/animatediff/tree/main
在这里插入图片描述

3.7 上传原视频

以这个视频(点击下载)作为示例

在Load Video(Upload)选择视频素材

在这里插入图片描述

3.8 生成视频

然后就可以点击Queue Prompt开始生成视频了

视频生成的大部分时间都集中在KSampler这个组件里,在生成过程中上面有一个进度条
在这里插入图片描述

另外在打开ComfyUI的windows终端里也可以看到进度以及错误信息
在这里插入图片描述

生成结束后,视频会在AnimateDiff Combine这个组件里合成
在这里插入图片描述

下面是一个结果的对比示例

Ai跳舞教学案例视频

3.9 文生动画案例

链接: https://pan.baidu.com/s/1zrNOKMYO9_C3tdOUW7L0EQ?pwd=7zjd
提取码: 7zjd 复制这段内容后打开百度网盘手机App,操作更方便哦

comfyui 文生动画


在这里插入图片描述

"0" :"Portrait,Elsa of Arendelle,cute,seductive,innocent,light smile,plump lips,slender body,(dark cape),(dark dress),fur trim,single braid,snowflake pattern,snowy mountain background ",
"15" :"girl,cute,seductive,innocent,light smile,plump lips,slender body,high detailed gothic dress,(red|white|black),vibrant color,mistery forest background , (closed eyes:1.8)",
"30" :"Full Body Shot, girl, cute, seductive, innocent, light smile:0.3, plump lips, slender body, trees, intricate, gold leaf accents, decorative surfaces, Klimt's Art Nouveau style, forest background,  ",
"45" :"18 year old, solo, 1girl, long hair, brown hair, blue eyes, long length hair, medium size breasts, petite,,  (white  sleeve short shirt, fitted shirt), beige executive pants, public, seductive smile,rabbit pose,(smileing:1.8)",
"60" :"Cowboy Shot, girl, cute, seductive, innocent, light smile, plump lips, slender body, solo, dark red dress, fog atmosphere, fashion photography, cinematic photography, vibrant colors, cinematic lighting, abandoned old train station, fog background"

宋江的一生


“0” : “a new born baby boy lying on a crib crying, top view, In Songjia Village, Yuncheng County, Shandong”,
“10” : “a new born baby boy lying on a crib crying, top view, In Songjia Village, Yuncheng County, Shandong”,
“20” : “a 3 years old, a young boy named Song Jiang grows up under the care of his family, his eyes sparkling with a thirst for knowledge and curiosity about the world,”,
“30” : “a 3 years old, a young boy named Song Jiang grows up under the care of his family, his eyes sparkling with a thirst for knowledge and curiosity about the world,”,
“40” : “a 5 years old, In the private school, Song Jiang is intently reading classics and histories, with his teachers and classmates praising his intelligence and leadership abilities”,
“50” : “a 5 years old, In the private school, Song Jiang is intently reading classics and histories, with his teachers and classmates praising his intelligence and leadership abilities”,
“60” : “20 years old, As a bailiff in Yuncheng County, Song Jiang is known for his generosity and sense of justice, often seen helping the people in need.”,
“70” : “20 years old, As a bailiff in Yuncheng County, Song Jiang is known for his generosity and sense of justice, often seen helping the people in need.”,
“80” : “30 years old, In an unexpected turn of events, Song Jiang is forced to leave his hometown, disappearing into the night on a perilous journey of exile.”,
“90” : “30 years old, In an unexpected turn of events, Song Jiang is forced to leave his hometown, disappearing into the night on a perilous journey of exile.”,
“100” : “40, years old, On Liangshan Marsh, Song Jiang stands among the heroes, his eyes resolute as he commands one battle after another against the imperial forces, with the Liangshan banner fluttering in the wind.”,
“110” : “40, years old, On Liangshan Marsh, Song Jiang stands among the heroes, his eyes resolute as he commands one battle after another against the imperial forces, with the Liangshan banner fluttering in the wind.”,
“120” : “50, years old, After accepting the amnesty from the court, Song Jiang and his brothers don the uniforms of the imperial army, bravely fighting in the battle against Fang La, despite the complex emotions in their hearts.”,
“130” : “50, years old, After accepting the amnesty from the court, Song Jiang and his brothers don the uniforms of the imperial army, bravely fighting in the battle against Fang La, despite the complex emotions in their hearts.”,
“140” : “60, years old, With the court’s bestowal, Song Jiang becomes the Duke of Martial Virtue, but his brows are furrowed, as he knows the glory hides endless conspiracies and betrayals.”,
“150” : “70 years old, In a dimly lit room, Song Jiang sits quietly at a table, holding a cup of poisoned wine. His eyes reflect a review of the past and helplessness about the future, and finally, he drinks the bitter wine of fate.”,
“160” : “70 years old, In a dimly lit room, Song Jiang sits quietly at a table, holding a cup of poisoned wine. His eyes reflect a review of the past and helplessness about the future, and finally, he drinks the bitter wine of fate.”,
“170” : “70 year old man, top view, lying at a table, eyes closed”

4. Debug

其中有三个组件会储存中间信息帮助分析错误

视频帧
在这里插入图片描述

ControlNet OpenPose处理结果
在这里插入图片描述

结果视频帧
在这里插入图片描述

5. 其他设置

5.1 通过改变图片种子值(seed)来修改图片内容

5.2 修改人物提示词

prompt prefix: 图片主体
在这里插入图片描述

prompt travel: 变化的背景内容,会根据不同的frames添加进图片
在这里插入图片描述

在这个例子中:

第0-23帧,画面提示词是:

High detail, girl, short pant, t-shirt, sneaker, a modern living room

第24-59帧:

High detail, girl, short pant, t-shirt, sneaker, beach and sun

第60帧之后:

High detail, girl, short pant, t-shirt, on the moon

5.3 输入视频参数

在这里插入图片描述

frame_load_cap : 载入视频的最大帧数

select_every_nth : 每隔~帧载入1帧画面,这样会导致跳过一些帧,导致视频不连贯,但是由于减少了需要处理的帧数,这样可以提高处理速度

### Krita 和 ComfyUI教程与使用指南 #### 了解 ComfyUI ComfyUI 是一款专为初学者设计的强大 AI 绘图工具,提供了详细的逐步指导,帮助用户快速上手并掌握其功能[^1]。 #### 安装与设置 为了使 Krita 能够调用 ComfyUI 进行绘画,需要安装名为 `krita-ai-diffusion` 的插件。该插件使得 Krita 可以无缝连接到 ComfyUI 实现实时绘制效果[^2]。对于希望获得更加便捷体验的用户来说,可以考虑使用已经集成了最新版本 Krita (5.26) 和 ComfyUI 组件的一键启动便携版软件包。此版本不仅实现了全面汉化支持,还优化了 ControlNet 功能的应用场景,极大地方便了用户的操作流程[^3]。 #### 基础操作介绍 当完成上述准备工作之后,在 Krita 中打开图像文件后即可通过菜单栏访问由 ComfyUI 提供的各种智能化处理选项。例如,可以通过简单的参数调整来实现风格迁移、色彩校正等功能;也可以借助于内置的人工智能算法自动生成创意草稿或是辅助完成细节描绘等工作任务。值得注意的是,合理构建和管理 controlnet 工作流能够显著提升工作效率以及作品质量[^4]。 #### 应用实例展示 具体而言,在服装印花领域内,利用这些技术手段不仅可以创造出独特而精美的图案样式,而且还可以有效简化传统手工制作过程中涉及到的一些复杂环节——比如精确地创建遮罩区域等操作都可以交给相应的插件自动完成,从而让设计师们把更多精力投入到更具创造性的方面去[^5]。 ```python # Python 示例代码用于说明如何自动化某些重复性高的图形编辑任务 def apply_style_transfer(image_path, style_model='default'): from comfyui import StyleTransferAPI api = StyleTransferAPI() result_image = api.transfer_style( input_image=image_path, model=style_model ) return result_image.save('output.png') ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

赤胜骄阳

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值