This repo will run a fast api for text to image Stable Diffusion. Most of the work here was done by Christian Cantrell. Please check him out!
conda env create -f environment.yaml
conda activate sd-api-server
uvicorn server:app --reload --host 0.0.0.0
If you don't have conda installed, you can use pip with:
python3 -m venv sd-api-server-env
source sd-api-server-env/bin/activate
pip install -r requirements.txt -q -U/
This will create a virtual environment with all the dependencies you need and then run the server. If you don't have the Stable Diffusion model downloaded, this will download it before running the server.
Create your environment by following this link pre-populated with config you need.
Install the Brev CLI and open your Stable Diffusion Fast Api environmnent:
brev open stable-diffusion-fast-api --wait
Then activate your environment and run the server:
conda activate sd-api-server
uvicorn server:app --reload --host 0.0.0.0
Then to make requests:
- Forward port 8000 in VScode
- Go to http://127.0.0.1:8000/docs or make calls through http://127.0.0.1:8000/txt2img?prompt=Snoop+Dogg
With Brev exposing ports publically is super easy! Just go to console.brev.dev and under Environment Settings you'll be able to expose ports publically. Make sure you expose port 8000!