Note: This article was translated with the assistance of AI. I wrote the original in Chinese. If you can read Chinese, you are welcome to read the original Chinese version for the most authentic and unfiltered expression.

Reference:

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

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

This tutorial uses the SVD XT model.

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

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

This tutorial works on Ubuntu 22.04.3 x86_64.

Preparation

Create a folder to isolate your project.

1
mkdir ./xxx

Enter the folder you just created.

1
cd xxx

Cloning

Pull the remote repository.

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

Downloading the Model

(Since huggingface.co is blocked, we use a mirror here.)

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

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

First, download the svd.safetensors model.

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

After downloading, return to the project root directory.

1
cd ..

Installing Dependencies

conda and Python

First install Anaconda (skip this if you already have it).

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

Note: during installation, you need to accept the license agreement first, type yes, and then continue.

After installation, you can delete the installer script.

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

Check whether the installation was successful.

1
conda --v

You should see a version number.

If it didn’t work, you can manually configure the environment variables.

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

Use conda to create a Python environment with Python 3.10.

1
conda create --name svd python=3.10 -y

Project Dependencies

1
conda activate svd

At this point, you should be in the virtual environment.

You can configure a domestic mirror source.

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

Run the following command in the project root directory to install dependencies:

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

Launching

First set the environment variables, otherwise you’ll get an error.

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

(If) it’s blocked and you need to manually download files, you don’t need to run the code below.

1
2
3
# [Deprecated] If manually downloading files:
# 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/

Or try the code below to replace the mirror site. Just add the parameter on the first run; you won’t need it afterward.

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

You can change the -server.port parameter to set the access port.

Usage

Visit http://<ip>:4801