A daemon which watches for messages on RabbitMQ and runs Stable Diffusion
- Daemon - existing solutions use a webserver, here we use a daemon which is more lightweight
- No hot loading - Model stored in RAM (10GB~) for faster processing
- Less bloat - code and dependencies have been kept to a minimum
- Flexibility - request daemon, response daemon and queue system can be run independently, allowing for more efficient use of resources
- Easy to use - just run the daemon and send messages to the queue using
send.py
stablediffusiondlistens to request queue- client makes a request which is added to request queue
stablediffusiondgets top item from request queue and runs Stable Diffusion based on requeststablediffusiondplaces response from Stable Diffusion into response queuestablediffusion_responsedservice listens to response queue and opens a socket onlocalhost:50007stablediffusion_responsedgets top item from response queue and returns it to client connected onlocalhost:50007
- RabbitMQ
- Python 3.6+
- conda (optional but recommended)
- pika
- Stable Diffusion and its dependencies
- the Stable Diffusion Model
Run the installation script and follow the instructions
curl -s https://raw.githubusercontent.com/w4ffl35/stablediffusiond/master/install.sh | bash- Edit
settings.pyand fill it out with correct values for your environment.
Your directory structure should look like this:
> stable-diffusion
> [various folders such as `assets`, `classes` and `scripts`]
> stablediffusiond
> [various files such as `receive.py` and `send.py`]
See installation script which contains comments for each step
Currently stablediffusiond depends on a forked branch which contains classes that mirror the code found in the
txt2img and img2img Stable Diffusion scripts. The classes allow us to skip model initialization for each request.
The three classes can be viewed here (compare to scripts/txt2img and scripts/img2img):
Starts a Stable Diffusion request queue runner
- start
sudo systemctl start stablediffusiond.service - restart
sudo systemctl restart stablediffusiond.service - stop
sudo systemctl stop stablediffusiond.service
Starts a Stable Diffusion response queue runner
- start
sudo systemctl start stablediffusion_responsed.service - restart
sudo systemctl restart stablediffusion_responsed.service - stop
sudo systemctl stop stablediffusion_responsed.service
- send a message to running stable diffusion queue
stablediffusion_client '{"prompt": "cat", "seed": 42}'
- Installation is too manual
- Very basic RabbitMQ configuration
- Not production ready
