This repository stands as an example on how to serve an AI Model / Checkpoint (from HuggingFace, CivitAI or where-ever) as a Python REST API.
- requests are processed in-line
- if not CUDA, MPS is used. Please switch to CPU if you're running this in a non-CUDA and non-MPS environment (see here for guide: https://stackoverflow.com/questions/53266350/how-to-tell-pytorch-to-not-use-the-gpu)
create/initialize python virtual environment
python3 -m venv .env
source .env/bin/activate
install dependencies
pip install -r requirements.txt
uvicorn api:app --reload --port 8001
POST localhost:8000/generate
{"prompt": "photograph: 35mm 3/4 eye-level portrait, lighting: natural, subject: actress pin-up style, expression: amused, pose: cowboy-shot, background: industrial", "negative_prompt": "blurry, dark photo, blue, deformed body features, mutated body parts, disfigured"}
Using this repository, the following images were generated. Prompts are included in the filename