animatediff-lightning_pytorch AIGC文本转动图算法模型

AnimateDiff-Lightning

论文

AnimateDiff-Lightning: Cross-Model Diffusion Distillation

模型结构

模型由多个不同的基础AnimateDiff模型组成(不同stable diffusion模型),其中motion module为可训练的共享模块,Base module为不可训练的独立模块。

算法原理

该算法为蒸馏distillation算法,通过渐进式的蒸馏方式,将Teacher(教师模型)的知识(能力)转移至Student(学生模型),同时使用了对抗蒸馏的方法对采样质量和模型收敛性进行了平衡。

环境配置

Docker(方法一)

docker pull image.sourcefind.cn:5000/dcu/admin/base/dtk:23.10-ubuntu20.04-py310

docker run --shm-size 10g --network=host --name=ad_lightning --privileged --device=/dev/kfd --device=/dev/dri --group-add video --cap-add=SYS_PTRACE --security-opt seccomp=unconfined -v 项目地址(绝对路径):/home/ -v /opt/hyhal:/opt/hyhal:ro -it <your IMAGE ID> bash

pip install torch-2.1.0a0%2Bgit793d2b5.abi0.dtk2310-cp310-cp310-manylinux2014_x86_64.whl  (whl.zip文件中)

pip install torchvision-0.16.0+git267eff6.abi0.dtk2310.torch2.1.0-cp310-cp310-linux_x86_64.whl  (whl.zip文件中)

pip install -r requirements.txt

git clone https://github.com/comfyanonymous/ComfyUI.git 

cd ComfyUI

pip install -r requirements.txt

cd custom_nodes && git clone https://github.com/Kosinkadink/ComfyUI-AnimateDiff-Evolved && git clone https://github.com/Kosinkadink/ComfyUI-VideoHelperSuite && git clone https://github.com/Kosinkadink/ComfyUI-Advanced-ControlNet && git clone https://github.com/Fannovel16/comfyui_controlnet_aux

apt-get update && apt-get install ffmpeg

注意:所有github库都可手动下载并放入相应的位置。

Dockerfile(方法二)

# 需要在对应的目录下
docker build -t <IMAGE_NAME>:<TAG> .

docker run --shm-size 10g --network=host --name=ad_lightning --privileged --device=/dev/kfd --device=/dev/dri --group-add video --cap-add=SYS_PTRACE --security-opt seccomp=unconfined -v 项目地址(绝对路径):/home/ -v /opt/hyhal:/opt/hyhal:ro -it <your IMAGE ID> bash

pip install torch-2.1.0a0%2Bgit793d2b5.abi0.dtk2310-cp310-cp310-manylinux2014_x86_64.whl  (whl.zip文件中)

pip install torchvision-0.16.0+git267eff6.abi0.dtk2310.torch2.1.0-cp310-cp310-linux_x86_64.whl  (whl.zip文件中)

pip install -r requirements.txt

git clone https://github.com/comfyanonymous/ComfyUI.git 

cd ComfyUI

pip install -r requirements.txt

cd custom_nodes && git clone https://github.com/Kosinkadink/ComfyUI-AnimateDiff-Evolved && git clone https://github.com/Kosinkadink/ComfyUI-VideoHelperSuite && git clone https://github.com/Kosinkadink/ComfyUI-Advanced-ControlNet && git clone https://github.com/Fannovel16/comfyui_controlnet_aux

apt-get update && apt-get install ffmpeg

注意:所有github库都可手动下载并放入相应的位置。

Anaconda (方法三)

1、关于本项目DCU显卡所需的特殊深度学习库可从光合开发者社区下载安装: https://developer.hpccube.com/tool/

DTK驱动:dtk23.10.1
python:python3.10
torch:2.1.0
torchvision:0.16.0

Tips:以上dtk驱动、python、torch等DCU相关工具版本需要严格一一对应

2、其它非特殊库参照requirements.txt安装

pip install torch-2.1.0a0%2Bgit793d2b5.abi0.dtk2310-cp310-cp310-manylinux2014_x86_64.whl  (whl.zip文件中)

pip install torchvision-0.16.0+git267eff6.abi0.dtk2310.torch2.1.0-cp310-cp310-linux_x86_64.whl  (whl.zip文件中)

pip install -r requirements.txt

git clone https://github.com/comfyanonymous/ComfyUI.git 

cd ComfyUI

pip install -r requirements.txt

cd custom_nodes && git clone https://github.com/Kosinkadink/ComfyUI-AnimateDiff-Evolved && git clone https://github.com/Kosinkadink/ComfyUI-VideoHelperSuite && git clone https://github.com/Kosinkadink/ComfyUI-Advanced-ControlNet && git clone https://github.com/Fannovel16/comfyui_controlnet_aux

conda install -c conda-forge ffmpeg

数据集

推理

模型下载

https://huggingface.co/ByteDance/AnimateDiff-Lightning/tree/main

名称+urlsave_path类型
1stepComfyUI/custom_nodes/ComfyUI-AnimateDiff-Evolved/models/运动模块
2stepComfyUI/custom_nodes/ComfyUI-AnimateDiff-Evolved/models/运动模块
4stepComfyUI/custom_nodes/ComfyUI-AnimateDiff-Evolved/models/运动模块
8stepComfyUI/custom_nodes/ComfyUI-AnimateDiff-Evolved/models/运动模块
emilianJR/epiCRealismComfyUI/models/checkpoints基础模型
XXMix_9realisticComfyUI/models/checkpoints基础模型

以上模型可以按需下载,并放入相应的路径。这里仅列出部分基础模型,可以下载其他模型(sd1.5)使用,运动模块选择一个即可。

除了手动下载这些模型并在ComfyUI中使用,也可以使用diffuser自动下载并以代码的方式调用。

注意:可以使用https://hf-mirror.com加速下载相应的模型权重。

命令行

# export HF_ENDPOINT=https://hf-mirror.com (按需)

# 快速测试
python scripts/quick_inference.py --step [1 2 4 8] --prompt <your prompt>

ComfyUI(建议)

cd ComfyUI

HIP_VISIBLE_DEVICES=0 python main.py --listen=0.0.0.0 --port=12341

注意:关于ComfyUI的使用方法需自行学习,comfyui_workflow中提供了示例工作流,可在UI界面中加载使用。

result

prompt: Red hair girl, red eyes, long hair, childish, white clothes, in a green grass field with a blue cloud sky, anime style, cute, smiling

seed: 99999

base model: Ether Real Mix

1step2step4step8step
time<1s2s6s14s
结果

精度

应用场景

算法类别

AIGC

热点应用行业

媒体,科研,教育

源码仓库及问题反馈

参考资料

  • 13
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

技术瘾君子1573

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

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

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

打赏作者

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

抵扣说明:

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

余额充值