Skip to content

Deforum v0.7 Notebook

hithereai edited this page Jan 2, 2023 · 26 revisions

This page will contain info on running and special features of the latest Deforum (v0.7) notebook.

Before you start

Before you start installing and using Deforum Stable Diffusion, there are a few things you need to do:

  1. Install ffmpeg. FFmpeg is a free software project that produces libraries and programs for handling multimedia data. You will need it to process audio and video files. Follow the instructions on the website to download and install FFmpeg on your system (https://trac.ffmpeg.org/wiki/CompilationGuide). Once it is installed, make sure it is in your PATH by running ffmpeg -h in your terminal. If you don't get an error message, you're good to go.
  2. Install the latest NVIDIA drivers for CUDA 11.7 (may not be necessary for Windows users). NVIDIA CUDA is a parallel computing platform and programming model that enables developers to use the power of NVIDIA graphics processing units (GPUs) to speed up compute-intensive tasks. You will need to install the latest NVIDIA drivers to use Deforum Stable Diffusion. You can find the drivers here. Follow the instructions on the website to download and install the drivers.
  3. Create a huggingface token. Hugging Face is a natural language processing platform that provides access to state-of-the-art models and tools. You will need to create a token in order to use some of the automatic model download features in Deforum Stable Diffusion. Follow the instructions on the Hugging Face website to create a token.
  4. Install Anaconda. Anaconda is a free and open-source distribution of Python and R. It includes a package manager called conda that makes it easy to install and manage Python environments and packages. Follow the instructions on the Anaconda website to download and install Anaconda on your system.
  5. Install Git for your system. Git is a version control system that helps you track changes to your code and collaborate with other developers. You can install Git with Anaconda by running conda install -c anaconda git -y in your terminal. If you have trouble installing Git via Anaconda, you can use the following links instead:

Once you have completed these steps, you will be ready to install Deforum Stable Diffusion.

Getting started

To install Deforum Stable Diffusion, follow these steps:

  1. Clone the deforum-stable-diffusion repository and navigate to it:
git clone https://github.com/deforum-art/deforum-stable-diffusion.git
cd deforum-stable-diffusion
  1. Create a suitable anaconda environment for Deforum, activate it, and install Pytorch:
conda create -n dsd python=3.10 -y
conda activate dsd
conda install pytorch torchvision torchaudio pytorch-cuda=11.7 -c pytorch -c nvidia -y
  1. Install required packages with the install script:
python install_requirements.py
  1. Check your installation by running the Python script:
python Deforum_Stable_Diffusion.py

Running the notebook

There are five ways to run Deforum Stable Diffusion notebook: locally with the .py file, locally with Jupyter, locally through Colab local-runtime, on Google colab servers, or using any of the available cloud-GPU services like runpod.ai or vast.ai. More info on 3rd party cloud based GPUs coming in the future.

Running locally using colab Local-Runtime (RECOMMENDED)

First, open the latest Deforum (v0.7) notebook using your prefered google account, then press the image button. This will create a copy of the notebook in your GDrive. Bookmark the link to your own copy of the notebook, because you will need it :).
Now open your anaconda prompt (windows) or terminal (linux) and enter:

conda activate dsd
jupyter serverextension enable --py jupyter_http_over_ws
jupyter notebook --NotebookApp.allow_origin='https://colab.research.google.com' --port=8888 --NotebookApp.port_retries=0

The first command will activate your dsd environment; the second one is only needed to be run a single time to enable connections to jupyter or colab, and the last one actually launches the jupyter back-end and gives you a URL which you will need to copy-paste into your colab browser windows as follows:
In your local copy of the deforum notebook browser tab click the arrow next to the connect button, then choose Connect to a local runtime: image
Paste the second URL you got from the latest command (the one that starts with localhost) to the URL field and press connect:
image
If it succseefully connected you will see a 'connected' status with a green circle. Congrats!
Now make sure to remove the / from the model_path and output_path in the Model and Output Paths code cells and uncheck mount_google_drive:
image
At that point you can just continue and run all the cells one by one, until you get the magic animation output 💯

Running locally using Jupyter

Running locally using the .py script

To run Deforum Stable Diffusion locally, make sure the dsd conda environment is active:

conda activate dsd

Then navigate to the stable-diffusion folder and run either the Deforum_Stable_Diffusion.py or the Deforum_Stable_Diffusion.ipynb file. Running the .py file is the quickest and easiest way to check that your installation is working, however, it is not the best environment for tinkering with prompts and settings.

python Deforum_Stable_Diffusion.py

Running on the cloud

Running on a cloud GPU

Running in Google Colab

Resetting the environment/ starting over

If you need to start over from scratch, you can delete the stable-diffusion folder and remove the dsd conda environment with the following set of commands:

conda deactivate
conda env remove -n dsd

With the dsd environment removed, you can start over with a fresh installation.

Exclusive features

Clone this wiki locally