grabbou commited on
Commit
6ecea59
·
verified ·
1 Parent(s): 020159f

Add model card

Browse files
Files changed (1) hide show
  1. README.md +79 -0
README.md ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ base_model: black-forest-labs/FLUX.2-klein-4B
4
+ base_model_relation: quantized
5
+ pipeline_tag: text-to-image
6
+ library_name: coreai
7
+ tags:
8
+ - coreai
9
+ - ios
10
+ - text-to-image
11
+ - flux
12
+ - react-native
13
+ ---
14
+
15
+ # FLUX.2 klein 4B for Core AI on iPhone
16
+
17
+ [black-forest-labs/FLUX.2-klein-4B](https://huggingface.co/black-forest-labs/FLUX.2-klein-4B) (4B parameters, step-distilled text-to-image) exported to Apple Core AI for iOS with the [`apple/coreai-models`](https://github.com/apple/coreai-models) recipe. It runs on iOS 27 and macOS 27 with the `FlowTransformerPipeline` from the `CoreAIDiffusion` product of `coreai-models`, and generates 512x512 images in 4 steps.
18
+
19
+ ## Files
20
+
21
+ `ios/` holds the text-to-image components of the recipe's iOS export, 4-bit weights (4.0 GB):
22
+
23
+ | File | Size | |
24
+ | --- | --- | --- |
25
+ | `Transformer_512.aimodel` | 2.0 GB | DiT, 25 blocks, 512x512 |
26
+ | `TextEncoder.aimodel` | 1.6 GB | Qwen3 text encoder |
27
+ | `VAEDecoder_half.aimodel` | 95 MB | latent to 512x512 image |
28
+ | `tokenizer/`, `metadata.json`, `vae_bn_*.npy` | 11 MB | |
29
+
30
+ The image-to-image transformer and VAE encoder of the full iOS export are left out. The pipeline loads one component at a time by default (`lazyModelLoading`), so it fits in the memory an iPhone 17 Pro gives an app.
31
+
32
+ ## Use
33
+
34
+ With [`@react-native-ai/core-ai`](https://github.com/callstackincubator/ai), download the `ios` folder and pass its path:
35
+
36
+ ```typescript
37
+ import { coreAI } from '@react-native-ai/core-ai'
38
+ import { generateImage } from 'ai'
39
+
40
+ const { image } = await generateImage({
41
+ model: coreAI.imageModel({
42
+ id: 'flux2-klein-4b',
43
+ source: { type: 'file', uri: fluxModelPath },
44
+ }),
45
+ prompt: 'a red apple on a wooden table',
46
+ size: '512x512',
47
+ seed: 42,
48
+ providerOptions: { 'core-ai': { stepCount: 4 } },
49
+ })
50
+ ```
51
+
52
+ In Swift:
53
+
54
+ ```swift
55
+ import CoreAIDiffusionPipeline
56
+
57
+ let pipeline = try await FlowTransformerPipeline(from: modelURL)
58
+ let configuration = PipelineConfiguration(
59
+ prompt: "a red apple on a wooden table",
60
+ seed: 42,
61
+ stepCount: 4,
62
+ guidanceScale: 1.0,
63
+ schedulerType: .discreteFlow
64
+ )
65
+ let image = try await pipeline.generateImages(configuration: configuration) { _ in true }.images[0]
66
+ ```
67
+
68
+ ## Export
69
+
70
+ From [`apple/coreai-models`](https://github.com/apple/coreai-models) at `5de95c6` (1.0.0), with `coreai-core` 1.0.0b3. This is `--platform iOS` (4-bit, single-function, 512) without the image-to-image components:
71
+
72
+ ```bash
73
+ uv run coreai.diffusion.export flux2-klein-4b --single-function \
74
+ --components transformer_512 text_encoder vae_decoder_half
75
+ ```
76
+
77
+ ## License
78
+
79
+ Apache-2.0, as the original model. The weights were converted to Core AI and quantized to 4 bits, and are otherwise unchanged. FLUX.2 [klein] is by [Black Forest Labs](https://bfl.ai).