antirez/flux2.c logo

antirez/flux2.c

Free

Flux 2 image generation model pure C inference

FreeFree tier
Type
Open Source

About antirez/flux2.c

Iris is an inference pipeline that generates images from text prompts using open weights diffusion transformer models. It is implemented entirely in C, with zero external dependencies beyond the C standard library. MPS and BLAS acceleration are optional but recommended. Supports FLUX.2 Klein (4B distilled, 4B base, 9B distilled, 9B base) and Z-Image-Turbo 6B models. Includes CLI tool and model download scripts. The pure C implementation allows easy compilation on multiple platforms without complex dependencies.

Key Features

Implemented entirely in C with zero external dependencies (only C standard library)
Optional MPS acceleration for Apple Silicon (fastest backend)
Optional BLAS acceleration for Intel Mac and Linux
Supports FLUX.2 Klein models (4B distilled, 4B base, 9B distilled, 9B base)
Supports Z-Image-Turbo 6B model from Tongyi-MAI
Distilled models support fast 4-step generation
Base models support high-quality 50-step generation with classifier-free guidance
Includes CLI tool for text-to-image generation
Provides shell and Python scripts for model downloading
Can run on CPU-only via generic backend

Pros & Cons

Pros
  • No external dependencies, easy to build from source
  • Cross-platform (macOS, Linux, Windows via generic backend)
  • High-quality output from state-of-the-art open models
  • Fast inference with distilled models (4 steps, ~1 second on M3 Max)
  • Optimized for Apple Silicon with MPS backend
  • Open source with permissive license (MIT implied)
  • Lightweight and straightforward codebase for learning
Cons
  • Requires downloading large model files (16-30 GB depending on variant)
  • Only supports specific model families (FLUX.2 Klein and Z-Image-Turbo)
  • 9B models are under non-commercial license
  • No built-in safety filter or NSFW moderation
  • May be slower than optimized PyTorch/CUDA implementations
  • No native Windows GPU acceleration (only MPS for Mac, BLAS for Intel/Linux)

Best For

Text-to-image generation on local machines without powerful GPUsRunning open-weight diffusion models in resource-constrained environmentsEducational study of transformer inference implementation in pure CPrototyping image generation pipelines with simple CLIGenerating images on Apple Silicon with MPS hardware acceleration

FAQ

What models does Iris support?
Iris supports FLUX.2 Klein models (4B distilled, 4B base, 9B distilled, 9B base) from Black Forest Labs and Z-Image-Turbo 6B from Tongyi-MAI.
How do I build Iris?
Use 'make mps' for Apple Silicon (fastest), 'make blas' for Intel Mac/Linux with OpenBLAS, or 'make generic' for pure C without dependencies.
How do I download a model?
Use the provided script: ./download_model.sh 4b or python download_model.py 4b. For 9B models, you need to accept the license on HuggingFace and provide a token via --token YOUR_TOKEN.
What is the license for Iris and the models?
The Iris codebase is open source (check LICENSE file, likely MIT). Model licenses vary: FLUX.2 9B models have non-commercial licenses; 4B models and Z-Image-Turbo may have different terms.
Can I run Iris on Windows?
Windows is supported via the generic backend, but without MPS or BLAS acceleration, performance may be slower.