- Zig 94.4%
- Python 5.6%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| build | ||
| docs | ||
| python | ||
| src | ||
| .gitignore | ||
| build.zig | ||
| build.zig.zon | ||
| LICENSE | ||
| package.json | ||
| README.md | ||
Imagine.zig
Imagine.zig generates and edits images on NVIDIA GPUs. It is written in Zig, GPU kernels included, and needs no CUDA toolkit, cuBLAS or Python at run time.
Quick start · Build from source · Supported models · Documentation · License
Quick start
You need an NVIDIA GPU of compute capability 8.0 or higher (8.9 for FP8) and a CUDA 13.0 driver or newer.
Prebuilt static binaries of imagine are not published yet. Until they are,
build from source.
./imagine --help
Build from source
You also need:
- a Zig compiler with the self-hosted PTX backend, at least
the version in
build.zig.zon; ptxas,fatbinaryandcuobjdumpfrom a CUDA toolkit, which the build runs.
zig build --release
./zig-out/bin/imagine # choose a model, then chat
./zig-out/bin/imagine --preset z-image-turbo "A red fox in the snow, watercolor"
./zig-out/bin/imagine --preset flux-2-klein-4b-fp8 "A lighthouse on a cliff at dusk"
./zig-out/bin/imagine --preset flux-2-klein-4b --image fox.png "Give the fox a red scarf"
./zig-out/bin/imagine --preset qwen-image-2.1 --image photo.png "Make it a night scene"
./zig-out/bin/imagine --checkpoint black-forest-labs/FLUX.2-klein-base-4B "A lighthouse at dusk"
./zig-out/bin/imagine search --pipeline flux-2-klein
Supported models
imagine runs four pipelines. A preset names a pipeline, a checkpoint and the steps and guidance of
a generation. --checkpoint runs another checkpoint of these pipelines from Hugging Face or from a
folder, and imagine search finds such checkpoints on the Hub;
Presets, checkpoints and quantization explains both.
| Pipeline | --pipeline |
Images | Guidance |
|---|---|---|---|
| Qwen-Image 2.1 | qwen-image |
edits them | no |
| Z-Image | z-image |
none | yes |
| FLUX.2 [klein] | flux-2-klein |
references | yes |
| Krea 2 | krea-2 |
none | yes |
--preset |
Checkpoint | Weights | Steps | Guidance | License |
|---|---|---|---|---|---|
qwen-image-2.1 |
Qwen-Image 2.1 | BF16 | 40 | 1 | Apache 2.0 |
z-image-turbo |
Z-Image-Turbo | BF16 | 8 | 1 | Apache 2.0 |
z-image |
Z-Image | BF16 | 50 | 6 | Apache 2.0 |
flux-2-klein-4b |
FLUX.2 [klein] 4B | BF16 | 4 | 1 | Apache 2.0 |
flux-2-klein-4b-fp8 |
FLUX.2 [klein] 4B with the transformer of FLUX.2 [klein] 4B FP8 | FP8 transformer | 4 | 1 | Apache 2.0 |
flux-2-klein-base-4b |
FLUX.2 [klein] Base 4B | BF16 | 50 | 4 | Apache 2.0 |
flux-2-klein-9b |
FLUX.2 [klein] 9B | BF16 | 4 | 1 | FLUX Non-Commercial License, gated |
flux-2-klein-9b-fp8 |
FLUX.2 [klein] 9B with the transformer of FLUX.2 [klein] 9B FP8 | FP8 transformer | 4 | 1 | FLUX Non-Commercial License, gated |
krea-2-turbo |
Krea 2 Turbo | BF16 | 8 | 1 | Krea 2 Community License, gated |
--quantize fp8 quantizes the BF16 weights of any checkpoint to FP8 as they load.
Generating and editing images explains the Images column.
Documentation
| To | Read |
|---|---|
run imagine, generate and edit images, chat, and generate an image again |
Generating and editing images |
| run a checkpoint from the Hub, search the Hub, quantize, or set the guidance | Presets, checkpoints and quantization |
| change the defaults, or keep weights in host memory | Options and memory placement |
download ahead of time, manage the cache, and see what imagine writes and sends |
Downloads, files and network |
| find your way in the source, add code, build for your GPU, or read the API | Development |
| run the tests and the benchmarks | Tests and benchmarks |
License
The code is under the MIT license (LICENSE), and copies of the program and of its cubins must include that notice. This repository contains no model weights. The weights that the program downloads, and the checkpoint files that it writes from them, stay under the terms that their repositories state; Supported models names the license of each model.