Home

Awesome

An implementation of a server for the Stability AI API

Features

Standard Stable Diffusion features

Enhancements

Installation

Colab (coming soon)

Docker (easiest if you already have Docker, and an Nvidia GPU with 4GB+ VRAM)

docker run --gpus all -it -p 50051:50051 \
  -e HF_API_TOKEN={your huggingface token} \
  -e SD_LISTEN_TO_ALL=1 \
  -v $HOME/.cache/huggingface:/huggingface \
  -v `pwd`/weights:/weights \
  hafriedlander/stable-diffusion-grpcserver:xformers-latest

Localtunnel

The docker image has built-in support for localtunnel, which will expose the GRPC-WEB endpoint on an https domain. It will automatically set an access token key if you don't provide one. Check your Docker log for the values to use

  -e SD_LOCALTUNNEL=1 \

Volume mounts

This will share the weights and huggingface cache, but you can mount other folders into the volume to do other things:

All the server arguments can be provided as environment variables, starting with SD:

Building the image locally

docker build --target main .

Or to build (slowly) with xformers

docker build --target xformers .

Locally (if you have an Nvidia GPU with 4GB+ VRAM, and prefer not to use Docker)

Option 1 (recommended):

Install Miniconda, then in a Conda console:

git clone https://github.com/hafriedlander/stable-diffusion-grpcserver.git
cd stable-diffusion-grpcserver
conda env create -f environment.yaml
conda activate sd-grpc-server

Then for Windows:

set PIP_EXTRA_INDEX_URL=https://download.pytorch.org/whl/cu116 
flit install --pth-file
set HF_API_TOKEN={your huggingface token}
python ./server.py

Or for Linux

PIP_EXTRA_INDEX_URL=https://download.pytorch.org/whl/cu116 flit install --pth-file
HF_API_TOKEN={your huggingface token} python ./server.py

Option 2:

Create a directory and download https://raw.githubusercontent.com/hafriedlander/stable-diffusion-grpcserver/main/engines.yaml into it, then

set PIP_EXTRA_INDEX_URL=https://download.pytorch.org/whl/cu116 
pip install stable-diffusion-grpcserver
set HF_API_TOKEN={your huggingface token} 
sdgrpcserver

Thanks to / Credits:

Roadmap

Core API functions not working yet:

Extra features to add

License

The main codebase is distributed under Apache-2.0. Dependancies are all compatible with that license, except as noted here:

Stable Cabal Logo