Git Product home page Git Product logo

diffusion's Introduction

Deforum Stable Diffusion

Last Commit GitHub issues GitHub stars GitHub forks Colab Replicate

Getting Started

  1. install anaconda for managing python environments and packages https://www.anaconda.com/
  2. create a huggingface token which you will need for auto model download: https://huggingface.co/settings/tokens
  3. open a anaconda powershell (on Windows) or terminal (Linux)
  4. install git through anaconda:
conda install -c anaconda git -y

  1. clone the github repository:
git clone -b local https://github.com/deforum/stable-diffusion.git
cd stable-diffusion

  1. create anaconda environment:
conda create -n dsd python=3.9 -y
conda activate dsd
conda install pytorch cudatoolkit=11.6 torchvision torchaudio -c pytorch -c conda-forge -y

  1. install required packages:
python -m pip install -r requirements.txt

  1. check your installation by running the .py
python Deforum_Stable_Diffusion.py

you have successfully installed deforum stable diffusion if the python file runs without any errors. if you get "out of memory" errors you can try installing xformers for your system (see either Windows Users or Linux Users below).

Running Deforum Stable Diffusion

there are four ways to run deforum stable diffusion: locally with the .py file, locally with jupyter, locally through colab, and on colab severs.

Running Locally

make sure the dsd conda environment is active:

conda activate dsd

navigate to the stable-diffusion folder and run either the Deforum_Stable_Diffusion.py or the Deforum_Stable_Diffusion.ipynb. running the .py 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

if you prefer a more colab-like experience you can run the .ipynb in jupyter-lab or jupyter-notebook. activate jupyter-lab or jupyter-notebook from within the stable-diffusion folder with either of the following commands:

jupyter-lab

jupyter notebook

Colab Local Runtime

make sure the dsd conda environment is active:

conda activate dsd

open google colab. file > upload notebook > select .ipynb file in the stable-diffusion folder. enable jupyter extension. note: you only need to run this cell one time.

jupyter serverextension enable --py jupyter_http_over_ws

start server.

jupyter notebook --NotebookApp.allow_origin='https://colab.research.google.com' --port=8888 --NotebookApp.port_retries=0
  

copy paste url token.

Colab Hosted Runtime

Deforum_Stable_Diffusion.ipynb can be uploaded to colab and run normally in a hosted session.

Windows Users

the midas and adabins model downloads are broken for windows at the moment. windows users will need to manually download model weights and place in the models folders. note: if you do not specify an existing models folder, the folder will be created automatically when you run either the .py or .ipynb for the first time.

manual download links:

https://github.com/intel-isl/DPT/releases/download/1_0/dpt_large-midas-2f21e586.pt

https://cloudflare-ipfs.com/ipfs/Qmd2mMnDLWePKmgfS8m6ntAg4nhV5VkUyAydYBp8cWWeB7/AdaBins_nyu.pt

xformers can be installed with the following commands:

wget https://github.com/neonsecret/xformers/releases/download/v0.14/xformers-0.0.14.dev0-cp39-cp39-win_amd64.whl
pip install xformers-0.0.14.dev0-cp39-cp39-win_amd64.whl

xformers can be enabled by switching the attention.py

mv src/ldm/modules/attention.py src/ldm/modules/attention_backup.py
mv src/ldm/modules/attention_xformers.py src/ldm/modules/attention.py

to turn off xformers run the following:

mv src/ldm/modules/attention.py src/ldm/modules/attention_xformers.py 
mv src/ldm/modules/attention_backup.py src/ldm/modules/attention.py

Linux Users

xformers can be installed with the following commands:

conda install xformers -c xformers/label/dev -y

xformers can be enabled by switching the attention.py

mv src/ldm/modules/attention.py src/ldm/modules/attention_backup.py
mv src/ldm/modules/attention_xformers.py src/ldm/modules/attention.py

to turn off xformers run the following:

mv src/ldm/modules/attention.py src/ldm/modules/attention_xformers.py 
mv src/ldm/modules/attention_backup.py src/ldm/modules/attention.py

Starting Over

the stable-diffusion folder can be deleted and the dsd conda environment can be removed with the following set of commands:

conda deactivate
conda env remove -n dsd

with the dsd environment removed you can start over.

diffusion

diffusion's People

Contributors

tooboi avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.