今天在HAI算力实例下部署体验了一下Magic-animate——可以单张图像+一组动作序列(Motion Sequence)生成高质量视频的工具,很强,脸部处理虽然差了一点但还是很有意思。
论文:https://arxiv.org/abs/2311.16498
仓库地址:https://github.com/magic-research/magic-animate/
以下是环境配置和部署过程。
(本文同步个人博客https://aiopen.pro)
HAI算力容器实例选择
实例创建成功后,点击Jupyterlab连接实例,点击Terminal进入终端交互。
项目克隆
git clone https://github.com/magic-research/magic-animate.git
cd magic-animate
通过conda创建配置并激活虚拟环境
这个算力容器已经配置有miniconda,不需要再安装conda,通过environment.yaml配置文件来创建项目需要的虚拟环境。(仓库中同时有pip安装配置环境依赖的选项,但是强烈建议通过conda配置一个独立的虚拟环境来避免一些默认环境冲突和项目依赖冲突。)
conda env create -f environment.yaml
conda activate manimate
模型下载
进入激活的manimate环境后,按照以下目录结构配置项目需要的model——也就是需要三个模型组:magicanimate模型、sd1.5模型、vae模型:
magic-animate
|----pretrained_models
|----MagicAnimate
|----appearance_encoder
|----diffusion_pytorch_model.safetensors
|----config.json
|----densepose_controlnet
|----diffusion_pytorch_model.safetensors
|----config.json
|----temporal_attention
|----temporal_attention.ckpt
|----sd-vae-ft-mse
|----...
|----stable-diffusion-v1-5
|----...
|----...
因此需要先在项目目录下新建pretrained_models文件夹并进入:
mkdir pretrained_models
cd pretrained_models
原仓库给出了模型的链接(托管在huggingface),可通过以下方式依次下载:
(截止今天,HAI没有预安装lfs(大文件下载)的git子命令,所以在运行以下大模型下载命令之前先运行apt-get install git-lfs
命令来安装lfs,安装完成后依次执行以下命令:
git lfs clone https://huggingface.co/zcxu-eric/MagicAnimate
来下载模型。git lfs clone https://huggingface.co/runwayml/stable-diffusion-v1-5
git lfs clone https://huggingface.co/stabilityai/sd-vae-ft-mse
在所有准备工作做完之后,运行graodio进行视频生成会出现error:Unexpected token '<', "<html>?<h"... is not valid JSON
参见这个issue:https://github.com/magic-research/magic-animate/issues/73#issuecomment-1849753916
【必要步骤】解决方案:
更改demo/gradio_animate.py
此文件,第96行,改为:
demo.queue().launch(share=True)
然后进入到项目主目录下:
cd
cd magic-animate
然后运行(单GPU下)gradio UI界面交互:
python3 -m demo.gradio_animate
(多GPU运行命令为:python3 -m demo.gradio_animate_dist
)
加载后点击Running on public URL:gradio链接 即可体验。
【附】如有需要使用自定义动作的,自行部署参见此开源方案:https://github.com/Flode-Labs/vid2densepose
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。