A FastAPI server for decomposing images into semantic layers using the Qwen-Image-Layered diffusion model.
- Decompose input images into multiple semantic layers
- RESTful API with automatic documentation
- GPU acceleration support
- Returns layered outputs as a ZIP file containing PNG images
- Python 3.11 or higher
- CUDA-capable GPU (recommended for performance)
- uv package manager
- Clone the repository:
git clone https://github.com/creative-graphic-design/simple-qwen-image-layered-inference
cd simple-qwen-image-layered-inference- Install dependencies:
uv syncuv run fastapi runThe server will start at http://localhost:8000
Once the server is running, visit:
- Interactive API docs:
http://localhost:8000/docs - Alternative docs:
http://localhost:8000/redoc
POST /decompose
Decomposes an uploaded image into semantic layers.
curl -X POST "http://localhost:8000/decompose?layers=4&num_inference_steps=50&seed=42" \
-H "accept: application/zip" \
-H "Content-Type: multipart/form-data" \
-F "image_file=@your_image.jpg" \
--output decomposed_layers.zipimage_file: The image to decompose (required)layers: Number of layers to generate (default: 4)num_inference_steps: Denoising steps (default: 50, higher = better quality but slower)seed: Random seed for reproducibility (default: 0)prompt: Optional text prompt to guide layer generationtrue_cfg_scale: Guidance scale for classifier-free guidance (default: 4.0)resolution: Output resolution, choose from 640 or 1024 (default: 640)
The endpoint returns a ZIP file containing the decomposed layers as PNG images (layer_1.png, layer_2.png, etc.).
MIT