antirez/iris.c
Flux 2 image generation model pure C inference
What it solves
Iris addresses the problem of running large image-generation models (like FLUX and Z-Image) without a heavy Python ML stack. It provides a pure C implementation that works on systems with limited memory (even 8GB RAM) by using memory-mapped weights, and it can be accelerated with GPU backends on Apple, NVIDIA, and AMD hardware.
How it works
Iris is an inference pipeline written entirely in C, with no external dependencies beyond the C standard library. It loads open-weight diffusion transformer models from HuggingFace (FLUX.2 Klein, FLUX.3 Image Klein, Z-Image-Turbo) and performs text-to-image generation directly on the GPU or CPU. The pipeline includes a built-in Qwen3 text encoder, so no separate embedding step is required. It supports both distilled (fast, few steps) and base (slower, higher quality) variants, and offers text-to-image, image-to-image, and multi-reference generation.
Who it’s for
Iris is for developers, researchers, and hobbyists who want to generate images from text on hardware where Python-based ML frameworks are too heavy or unavailable. It is particularly suited for Apple Silicon Macs (with MPS acceleration), NVIDIA or AMD GPUs, and even CPU-only Linux systems. The terminal display and interactive mode make it convenient for command-line work.
Highlights
- Zero dependencies: pure C implementation, runs standalone.
- GPU acceleration: Metal (Apple), CUDA (NVIDIA), ROCm (AMD), plus optional BLAS for CPU.
- Fast: on Apple Silicon MPS, it outperforms PyTorch's optimized MPS pipeline at multiple resolutions.
- Memory efficient: memory-mapped weights reduce peak memory from ~16GB to ~4-5GB, enabling 8GB RAM systems.
- Supports FLUX.2 Klein (4B/9B), FLUX.3 Image Klein, and Z-Image-Turbo models.
- Text-to-image, image-to-image, and multi-reference (up to 16) generation.
- Interactive CLI mode with commands for size, seed, steps, and more.
- Terminal image display via Kitty protocol or iTerm2 inline images.
- PNG metadata stores seed and model info for reproducibility.
- Tests ensure output correctness with reference vectors.
Related
- Project
- Project
- Project
- Project