mayur7garg / stable-diffusion-docker

Runs the official Stable Diffusion release in a Docker container.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Stable Diffusion in Docker

Runs the official Stable Diffusion v1.4 release on Huggingface in a GPU accelerated Docker container.

./build.sh run 'An impressionist painting of a parakeet eating spaghetti in the desert'

An impressionist painting of a parakeet eating spaghetti in the desert 1 An impressionist painting of a parakeet eating spaghetti in the desert 2

Before you start

The pipeline uses the full model and weights which requires 8GB+ of GPU RAM. On smaller GPUs you may need to modify some of the parameters. It should take a few seconds to create one image.

Since it uses the official model, you will need to create a user access token in your Huggingface account. Save the user access token in a file called token.txt and make sure it is available when building the container.

Quickstart

The pipeline is managed using a single build.sh script. You must build the image before it can be run.

Build

Make sure your user access token is saved in a file called token.txt. The token content should begin with hf_...

To build:

./build.sh build  # or just ./build.sh

Run

To run:

./build.sh run 'A high tech solarpunk utopia in the Amazon rainforest'

Options

Some of the options from txt2img.py are implemented for compatibility:

  • --prompt [PROMPT]: the prompt to render into an image
  • --n_samples [N_SAMPLES]: number of images to create (default 1)
  • --H [H]: image height in pixels (default 512)
  • --W [W]: image width in pixels (default 512)
  • --scale [SCALE]: unconditional guidance scale (default 7.5)
  • --seed [SEED]: RNG seed for repeatability (default is a random seed)
  • --ddim_steps [DDIM_STEPS]: number of sampling steps (default 50)

Other options:

  • --half: use float16 tensors instead of float32 (default float32)

Examples

These commands are both identical:

./build.sh run 'abstract art'
./build.sh run --prompt 'abstract art'

Set the seed to 42:

./build.sh run --seed 42 'abstract art'

Options can be combined:

./build.sh run --scale 7.0 --seed 42 'abstract art'

Outputs

Model

The model and other files are cached in a volume called huggingface.

Images

The images are saved as PNGs in the output folder using the prompt text. The build.sh script creates and mounts this folder as a volume in the container.

About

Runs the official Stable Diffusion release in a Docker container.

License:GNU Affero General Public License v3.0


Languages

Language:Python 73.4%Language:Shell 16.5%Language:Dockerfile 10.1%