🚀 fast serverless ai image gen as an api
uses modal.com to generate images in ~2s from POST request (cold start not included)
git clone https://github.com/zhaobenny/serverless-img-gen.git && cd serverless-img-gen
pip install modal python-dotenv
modal token new
modal deploy app.py
curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer a-good-auth-token" -d '{"prompt":"<Misato:0.4>, (masterpiece, best quality, highres), selfie, misato katsuragi, long hair, (brown eyes), blue hair, (purple hair), solo, white shirt", "negative_prompt":"FastNegativeV2"}' <URL> -o output.png
Prompt uses Compel syntax, see their docs
LoRA syntax is <Misato:0.4>
in the prompt where Misato
is the filename of the LoRA in loras
folder, and an suitable weight after the colon.
FastNegativeV2, and Misato LyCORIS is included by default for demo purposes.
Place your (diffusers/diffusion model compatible) LoRAs / embeddings in the loras
folder, and they will be automatically uploaded to modal.com on deployment.
(make sure your embeddings are .pt
and loras are .safetensors
)
Check available concepts on a deployment at <URL>/loras
and <URL>/embeddings