Reference:

How to run Stable Video Diffusion img2vid - Stable Diffusion Art (stable-diffusion-art.com)

https://video-stable-diffusion.com/install-svd-on-linux/

使用的是 SVD XT模型

SVD – trained to generate 14 frames at resolution 576×1024.

SVD XT – trained to generate 25 frames at resolution 576×1024.

本教程在Ubuntu 22.04.3 x86_64上奏效。

准备

创建文件夹,把自己的项目隔离开

mkdir ./xxx

进入刚刚创建的文件夹

cd xxx

克隆

拉取远程仓库

git clone https://github.com/Stability-AI/generative-models
cd generative-models

下载模型

(由于huggingface.co被屏蔽,这里使用镜像)

stabilityai/stable-video-diffusion-img2vid at main (huggingface.co)

stabilityai/stable-video-diffusion-img2vid-xt at main (huggingface.co)

此处先下载 svd.safetensors 模型

mkdir checkpoints
cd checkpoints
wget https://hf-mirror.com/stabilityai/stable-video-diffusion-img2vid/resolve/main/svd.safetensors

下载完后返回到项目根目录

cd ..

安装依赖

conda 与 Python

先安装anaconda(若已安装可以跳过)

wget https://repo.anaconda.com/archive/Anaconda3-2023.09-0-Linux-x86_64.sh
bash Anaconda3-2023.09-0-Linux-x86_64.sh

注意安装的时候要先统一协议,填yes,然后继续

安装完成可以删掉安装脚本

rm Anaconda3-2023.09-0-Linux-x86_64.sh

检查是否安装成功

conda --v

应该会显示版本号。

没成功的话,可以手动配置环境变量。

echo ". ~/anaconda3/etc/profile.d/conda.sh" >> ~/.bashrc
source ~/.bashrc

使用带有 Python 3.10 的 conda 创建 Python 环境

conda create --name svd python=3.10 -y

项目依赖

conda activate svd

此时应该会进入虚拟环境。

可以设置使用国内镜像源

pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple/
pip config set install.trusted-host pypi.tuna.tsinghua.edu.cn

在项目根目录输入命令安装依赖:

pip3 install -r requirements/pt2.txt
pip3 install .

启动

先设置环境变量,否则会报错

echo 'export PYTHONPATH=/generative-models:$PYTHONPATH' >> ~/.bashrc
source ~/.bashrc

(如果)由于被屏蔽了,要手动下载文件,不用输下面的代码

~~git clone https://hf-mirror.com/laion/CLIP-ViT-H-14-laion2B-s32B-b79K ~/.cache/huggingface/hub/CLIP-ViT-H-14-laion2B-s32B-b79K
wget https://openaipublic.azureedge.net/clip/models/b8cca3fd41ae0c99ba7e8951adf17d267cdb84cd88be6f7c2e0eca1737a03836/ViT-L-14.pt -P ~/.cache/clip/~~

或者试一下以下的代码,设置替换镜像站。首次运行的时候加一下参数就好了,后面不需要

HF_ENDPOINT=https://hf-mirror.com streamlit run scripts/demo/video_sampling.py  --server.address  0.0.0.0  --server.port 4801

修改 -server.port 参数可以设置访问的端口。

使用

访问 http://<ip>:4801



标题:国内服务器部署Stable Video Diffusion教程
作者:shiquda
地址:https://shiquda.link/articles/2023/12/05/1701780603849.html
除非特别说明,本博客上的所有内容均在CC BY-SA 4.0许可下提供。 如需转载请注明作者与来源,谢谢!