FLUX.2 klein 4B: Core AI model card
Browse files
README.md
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
base_model: black-forest-labs/FLUX.2-klein-4B
|
| 4 |
+
tags:
|
| 5 |
+
- core-ai
|
| 6 |
+
- coreai
|
| 7 |
+
- text-to-image
|
| 8 |
+
- flux
|
| 9 |
+
- flux2
|
| 10 |
+
- on-device
|
| 11 |
+
- apple-silicon
|
| 12 |
+
pipeline_tag: text-to-image
|
| 13 |
+
library_name: coreai
|
| 14 |
+
---
|
| 15 |
+
|
| 16 |
+
# FLUX.2 klein 4B — Core AI
|
| 17 |
+
|
| 18 |
+
[Black Forest Labs' **FLUX.2 [klein] 4B**](https://huggingface.co/black-forest-labs/FLUX.2-klein-4B)
|
| 19 |
+
converted to **Core AI** for on-device image generation on Apple Silicon (macOS 27+),
|
| 20 |
+
running on Apple's official diffusion runtime in
|
| 21 |
+
[apple/coreai-models](https://github.com/apple/coreai-models).
|
| 22 |
+
|
| 23 |
+
FLUX.2 [klein] is step-distilled: **4 denoising steps at guidance 1.0** produce a full
|
| 24 |
+
1024×1024 image. It pairs a 4B flow-matching diffusion transformer (DiT) with an 8B
|
| 25 |
+
Qwen3 text encoder.
|
| 26 |
+
|
| 27 |
+
## Components
|
| 28 |
+
|
| 29 |
+
| Component | Description |
|
| 30 |
+
| --- | --- |
|
| 31 |
+
| `Transformer.aimodel` | Flow-matching DiT (25 blocks), 1024×1024 |
|
| 32 |
+
| `TextEncoder.aimodel` | Qwen3 text encoder (hidden states 9 / 18 / 27) |
|
| 33 |
+
| `VAEDecoder.aimodel` | Latent → 1024×1024 RGB image |
|
| 34 |
+
| `VAEEncoder.aimodel` | 1024×1024 RGB image → latent (image-to-image) |
|
| 35 |
+
| `tokenizer/`, `pipeline.json`, `vae_bn_*.npy` | Sidecar assets (auto-loaded) |
|
| 36 |
+
|
| 37 |
+
Weights are 4-bit quantized (int4, per-block, block size 32); compute precision
|
| 38 |
+
float16. The full bundle is **4.0 GB** — Transformer 2.0 GB · TextEncoder 1.8 GB ·
|
| 39 |
+
VAE 0.16 GB.
|
| 40 |
+
|
| 41 |
+
## Usage
|
| 42 |
+
|
| 43 |
+
### Sample app (easiest)
|
| 44 |
+
|
| 45 |
+
[**CoreAIImageGenMac**](https://github.com/mlboydaisuke/coreai-samples) — pick
|
| 46 |
+
"FLUX.2 klein 4B", tap **Download & Load**, type a prompt, **Generate**.
|
| 47 |
+
|
| 48 |
+
### Swift
|
| 49 |
+
|
| 50 |
+
```swift
|
| 51 |
+
import CoreAIDiffusionPipeline
|
| 52 |
+
|
| 53 |
+
let pipeline = try await Flux2Pipeline(from: modelURL)
|
| 54 |
+
let config = PipelineConfiguration(
|
| 55 |
+
prompt: "a photo of a cat",
|
| 56 |
+
stepCount: 4,
|
| 57 |
+
guidanceScale: 1.0,
|
| 58 |
+
schedulerType: .discreteFlow
|
| 59 |
+
)
|
| 60 |
+
let result = try await pipeline.generateImages(configuration: config) { _ in true }
|
| 61 |
+
let image = result.images.first!
|
| 62 |
+
```
|
| 63 |
+
|
| 64 |
+
### Command line (zoo reference tool)
|
| 65 |
+
|
| 66 |
+
```bash
|
| 67 |
+
swift run -c release diffusion-runner \
|
| 68 |
+
--model path/to/FLUX.2-klein-4B \
|
| 69 |
+
--prompt "a photo of a cat" --steps 4 --guidance-scale 1.0
|
| 70 |
+
```
|
| 71 |
+
|
| 72 |
+
## How it was converted
|
| 73 |
+
|
| 74 |
+
```bash
|
| 75 |
+
uv run coreai.diffusion.export flux2-klein-4b --platform macOS
|
| 76 |
+
```
|
| 77 |
+
|
| 78 |
+
## Performance
|
| 79 |
+
|
| 80 |
+
M4 Max (128 GB): **~17 s** for a 4-step 1024×1024 image (cold model load + 4 denoising
|
| 81 |
+
steps + VAE decode). The distilled 4-step schedule means no negative prompt / CFG is
|
| 82 |
+
needed (guidance 1.0).
|
| 83 |
+
|
| 84 |
+
## License
|
| 85 |
+
|
| 86 |
+
Apache 2.0, inherited from the base model
|
| 87 |
+
[black-forest-labs/FLUX.2-klein-4B](https://huggingface.co/black-forest-labs/FLUX.2-klein-4B).
|
| 88 |
+
The converted weights are redistributed under the same terms, with attribution to
|
| 89 |
+
Black Forest Labs.
|