Spaces:
Sleeping
Sleeping
|
Download README.md from kajalan/hf-image-api: direct link, hf CLI and curl.
- Browser
- Download file 1.65 kB
-
https://huggingface.co/spaces/kajalan/hf-image-api/resolve/main/README.md
- Command line
-
hf download hf://spaces/kajalan/hf-image-api/README.md
-
curl -L -o README.md https://huggingface.co/spaces/kajalan/hf-image-api/resolve/main/README.md
1.65 kB
| title: HF Image API | |
| emoji: πΌοΈ | |
| colorFrom: blue | |
| colorTo: purple | |
| sdk: docker | |
| pinned: false | |
| app_port: 7860 | |
| # HF CPU Image Generation API | |
| A job-queue REST API for Stable Diffusion image generation on CPU using Hugging Face Diffusers. | |
| **Swagger UI:** `https://your-space-url.hf.space/docs` | |
| ## Job flow | |
| ``` | |
| POST /generate β { job_id, status: "queued" } | |
| GET /jobs/{id} β { status: "processing", progress: 45 } | |
| GET /jobs/{id} β { status: "completed", download_url: "..." } | |
| GET /jobs/{id}/download β image.png | |
| DELETE /jobs/{id} β removes job + image | |
| ``` | |
| ## API endpoints | |
| | Method | Path | Description | | |
| |---|---|---| | |
| | `POST` | `/generate` | Submit a generation job | | |
| | `GET` | `/jobs` | List all jobs | | |
| | `GET` | `/jobs/{id}` | Poll job status & progress | | |
| | `GET` | `/jobs/{id}/download` | Download the PNG | | |
| | `DELETE` | `/jobs/{id}` | Delete job + image | | |
| | `GET` | `/health` | Pipeline & queue status | | |
| | `GET` | `/models` | List supported models | | |
| | `POST` | `/models/load` | Hot-swap model | | |
| ## CPU optimisations | |
| - `torch.float32` (mandatory for CPU) | |
| - `DPMSolverMultistepScheduler` β converges at 20 steps | |
| - `enable_attention_slicing` β lower peak RAM | |
| - `low_cpu_mem_usage=True` β no double-buffering | |
| - `safety_checker=None` β saves ~300 MB RAM | |
| ## Default model | |
| `nota-ai/bk-sdm-small` (~500 MB) β fastest on CPU, ~60β120s per 512Γ512 image. | |
| ## HF Spaces Secrets | |
| Set these under **Settings β Secrets** in your Space: | |
| | Secret | Description | | |
| |---|---| | |
| | `HF_TOKEN` | Your HuggingFace token (faster downloads) | | |
| | `MODEL_ID` | Override model (e.g. `runwayml/stable-diffusion-v1-5`) | | |