imagine-flux3-klein / README.md
arraypress's picture
README: up to native 4K
d69d7c7 verified
|
Raw History Blame Contribute Delete
7.41 kB
---
license: other
license_name: flux-kommunity-license
license_link: https://huggingface.co/arraypress/imagine-flux3-klein/blob/main/LICENSE.md
base_model: black-forest-labs/flux-3-image-klein
pipeline_tag: text-to-image
extra_gated_prompt: >-
This is a Core AI conversion of FLUX.3 [klein] by Black Forest Labs, under the FLUX
Kommunity License (LICENSE.md): it may be used and distributed for non-commercial
purposes; only a Qualifying User may use its output commercially. You must use content
filters or review output before distributing it, and disclose AI generation where the
law requires. By agreeing you accept that licence.
tags:
- flux3
- text-to-image
- core-ai
- apple-silicon
- non-commercial
---
# FLUX.3 [klein] β€” Core AI
Black Forest Labs' **FLUX.3 [klein]** converted to Core AI diffusion bundles for Apple silicon,
4 steps β€” used by the `imagine` tool. Any shape and size up to native 4K, and editing with up to ten pictures.
Two bundles, the same model:
| | weights | download | use it for |
|---|---|---|---|
| `full/` (`imagine --flux3`) | bfloat16 | 17 GB | **text** β€” signs and handwriting spelled right |
| top level (`imagine --flux3-small`) | 4-bit | 5.4 GB | drafts β€” prints signs, garbles handwriting |
## Files
Each size β€” `full/` (bfloat16, `imagine --flux3`) and the top level (4-bit, `imagine --flux3-small`) β€”
is one set of files that draws and edits every shape:
| file | what | bfloat16 | 4-bit |
|---|---|---|---|
| `Transformer_4k.aimodel` | text to image; image and text lengths variable | 9.1 GB | 2.9 GB |
| `Transformer_img2img_full.aimodel` | editing; image, text and reference lengths variable | 10 GB | 3.2 GB |
| `VAEDecoder_4k.aimodel`, `VAEEncoder_4k.aimodel` | any height and width up to 4096 | 0.16 GB | 0.16 GB |
| `TextEncoder.aimodel`, `tokenizer`, `vae_bn_*.npy` | Qwen3-VL text encoder and sidecars | 8.3 GB | 2.5 GB |
Any width and height in multiples of 16, sides up to 4096; `imagine` allows up to 3840 Γ— 2160 (2880 Γ— 2880 square), the largest measured β€” about 18 minutes at bfloat16 and 16 at 4 bits on a 36 GB Mac, the picture decoded in overlapping 1024-pixel tiles (a whole 4K decode alone ran the Mac out of memory). An edit takes up to ten
pictures, each read whole as diffusers' FLUX.3 pipeline reads it β€” the edited picture at the output's
size, every other one fitted under 1 megapixel at its own shape β€” each at its own position ids. Core AI
compiles each variable function once, for every size.
Measured on an M3 Max (36 GB) through `imagine`: the variable transformer agrees with diffusers' own
forward to cosine 0.999912 on saved reference inputs, exactly as the fixed 1:1 export did; a 2048 Γ— 2048
poster with its title spelled right in 420 s; a 16:9 picture with its sign right in 116 s; a person
dressed from a cardigan's and a beret's pictures (three in all) kept her face, 242 s; at 4 bits a 3:4
picture in 43 s.
The older files β€” 0.20's `*_any.aimodel` (up to 2048) and 0.17–0.19's `Transformer.aimodel`, `VAEDecoder.aimodel`
and `shapes/` β€” are kept for the `imagine` versions that pin earlier revisions; nothing current reads them.
## Editing
Instructions are passed as written β€” the bundles do not include BFL's prompt upsampler β€” and
`imagine guide edit` shows the formats (a full instruction, or a paragraph with a JSON table of boxes
on a 0–1000 grid). Measured against diffusers' own pipeline on the same pictures: a mug recoloured, a
notebook removed with a written instruction (a short "remove the notebook" left it, in diffusers too),
a mug moved by a box record, a person dressed from garments' pictures.
## Licence β€” read this first
- **FLUX Kommunity License v1.0** ([`LICENSE.md`](LICENSE.md)). The model and this conversion may be
used and distributed for **non-commercial purposes**; a **Qualifying User** (under US$5M gross
annual revenue, with affiliates) may also use the pictures commercially. Rights come directly from
Black Forest Labs to you, not from us.
- **Β§2(e):** you must either use **content filters** to prevent unlawful, unsafe or infringing
output, **or review output** before distributing it β€” and **disclose AI generation** where the law
requires. `imagine` writes the IPTC digital-source-type field (`trainedAlgorithmicMedia`) into
every file.
- BFL's Attribution Notice and our modification statement are in [`NOTICE`](NOTICE). This is not an
official Black Forest Labs product.
- The text encoder is the language model of Qwen3-VL as shipped in BFL's release (Apache-2.0,
[`LICENSE-QWEN3-VL`](LICENSE-QWEN3-VL)).
## Conversion
Apple's recipe, [apple/coreai-models](https://github.com/apple/coreai-models) (BSD-3), extended for
FLUX.3 in [arraypress/coreai-models](https://github.com/arraypress/coreai-models) at tag
`1.0.0-nonsquare.8`; source revision `3373376`.
- **bfloat16.** float16 overflows (NaN, in diffusers too). Against diffusers in PyTorch the bfloat16
bundle's output agrees to cosine 0.99992.
- **4-bit:** weights quantized per block of 32, symmetric, scales stored as float32 (Core AI's 4-bit
GPU kernel rejects bfloat16 scales); norms excluded. The VAE is never quantized.
- **Recipe**, as in diffusers' FLUX.3 pipeline: the text window is the prompt rounded up to a multiple
of 80 tokens (up to 1040); padding sits at position 1 inside Qwen3-VL; image positions are scaled
by 0.5; sigmas `linspace(1, 1/n, n)` shifted by 6.93, each step aimed at the next sigma.
- **4 steps** where diffusers runs 16: on text, faces, hands and crowds, 4 steps matched 8 and 16.
## Measured (macOS 27, M3 Max, 36 GB, GPU, 1024 Γ— 1024, 4 steps, through `imagine`)
| Measure | `full/` | 4-bit |
|---|---|---|
| chalk menu "Today: tomato soup", seeds 21–24, spelled right | **4 / 4** | 0 / 4 |
| printed signs, labels, covers: six prompts, one seed | 6 / 6 | 5 / 6 |
| one picture, whole command | 77–98 s | 33–38 s |
| each further picture in the same run | 25–32 s | β€” |
| peak memory footprint / most resident | 6.1–7.7 GB / 23–26 GB | 13.3 GB / 6.3–8.6 GB |
| first run (compiles for this Mac's GPU, cached per program) | β‰ˆ16 min | β‰ˆ30 s |
At 4 bits the model still prints a sign but writes handwriting as near-letters ("yerunaoo soup"), so
the bfloat16 bundle is the one to use for text. Faces, hands and crowds look the same at both.
An 8-bit bundle was measured and dropped: 8 GB, but β‰ˆ190 s a picture (Core AI re-attempts a Neural
Engine compile on every load). Core AI also prints six compiler warnings to standard output on each
load of the 4-bit bundle; `imagine` silences them.
## Use
```sh
imagine model accept flux3 # once: shows these terms, records acceptance
imagine --flux3 "a chalkboard menu that reads 'Today: tomato soup'" -o menu.png
imagine --flux3-small "a lighthouse on a cliff, poster art" -o draft.png
imagine --flux3 "a wide street sign that reads 'Harbour Road'" --aspect 16:9
imagine --flux3 "a Lisbon travel poster with the word 'LISBOA'" --size 2048x2048
imagine --flux3 --edit person.jpg --ref cardigan.jpg --ref beret.jpg "Create a photograph of the woman from the first image wearing the cardigan from the second image and the beret from the third …"
```
Downloading needs a Hugging Face account that has accepted this repository's terms and a token
(`hf auth login`); `imagine` says so with exit 3 when either is missing.