Stable diffusion webui provides a powerful tool for AI image generation. However, the webui api has some limitations:
- a blocking REST api call, which might take more than 30s to return the final value. Most gateways don't allow such long blocking time on api call.
- webui api is a single thread process. Once the thread is occupied, other webui api will fail. (Even though there is a multi thread mode in stable diffusion webui)
This repo is aiming to solve the above problems.
- Python 3
- Stable diffusion Webui
https://github.com/marciovrl/fastapi-example.git
pip install -r requirements.txt
uvicorn app.main:app --reload --port 5001
http://127.0.0.1:8000/docs
There is an extra filed in txt2img/img2img api:
options: Optional[dict]
You can swtich stable diffusion by using this options.
"options":
{
"sd_model_checkpoint": <The model you want to use>
}