Update model card: FLUX.2 Klein, 1024, ReSeed, current folder layout
Browse files- .gitattributes +1 -0
- README.md +103 -45
- assets/klein-collage.webp +3 -0
.gitattributes
CHANGED
|
@@ -8,3 +8,4 @@
|
|
| 8 |
assets/*.png filter=lfs diff=lfs merge=lfs -text
|
| 9 |
coreml_flux2_klein_1024/embed_tokens.f16 filter=lfs diff=lfs merge=lfs -text
|
| 10 |
coreml_flux2_klein_1024/tokenizer.json filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 8 |
assets/*.png filter=lfs diff=lfs merge=lfs -text
|
| 9 |
coreml_flux2_klein_1024/embed_tokens.f16 filter=lfs diff=lfs merge=lfs -text
|
| 10 |
coreml_flux2_klein_1024/tokenizer.json filter=lfs diff=lfs merge=lfs -text
|
| 11 |
+
assets/klein-collage.webp filter=lfs diff=lfs merge=lfs -text
|
README.md
CHANGED
|
@@ -1,80 +1,138 @@
|
|
| 1 |
---
|
| 2 |
-
base_model:
|
|
|
|
|
|
|
| 3 |
pipeline_tag: text-to-image
|
| 4 |
library_name: coreml
|
|
|
|
|
|
|
|
|
|
| 5 |
tags:
|
| 6 |
- coreml
|
| 7 |
- ios
|
| 8 |
- iphone
|
| 9 |
- ane
|
|
|
|
| 10 |
- stable-diffusion-3
|
|
|
|
|
|
|
| 11 |
- mobile-diffusion
|
|
|
|
| 12 |
---
|
| 13 |
|
| 14 |
-
# MobileDiffuser SD3 Medium
|
| 15 |
|
| 16 |
<p>
|
| 17 |
-
<img src="assets/
|
| 18 |
</p>
|
| 19 |
|
| 20 |
-
|
| 21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
|
| 23 |
## Contents
|
| 24 |
|
| 25 |
-
|
| 26 |
-
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
|
| 32 |
-
|
| 33 |
|
| 34 |
-
- `
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
- `MultiModalDiffusionTransformerStage*.mlmodelc`
|
| 38 |
-
- `VAEDecoder.mlmodelc`
|
| 39 |
|
| 40 |
-
The
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
|
|
|
|
|
|
| 44 |
|
| 45 |
-
##
|
| 46 |
|
| 47 |
-
|
| 48 |
-
|
|
|
|
|
|
|
|
|
|
| 49 |
|
| 50 |
-
``
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
|
| 55 |
-
|
| 56 |
-
|
|
|
|
| 57 |
|
| 58 |
-
##
|
| 59 |
|
| 60 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
|
| 62 |
```bash
|
| 63 |
-
|
| 64 |
-
git lfs pull
|
| 65 |
```
|
| 66 |
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
The `.safetensors` checkpoints are also stored through LFS. They are provided so
|
| 71 |
-
the Core ML bundles can be reproduced or re-converted with different splitting
|
| 72 |
-
or quantization settings.
|
| 73 |
|
| 74 |
## Notes
|
| 75 |
|
| 76 |
-
-
|
| 77 |
-
-
|
| 78 |
-
-
|
| 79 |
-
|
| 80 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
base_model:
|
| 3 |
+
- stabilityai/stable-diffusion-3-medium
|
| 4 |
+
- black-forest-labs/FLUX.2-klein-4B
|
| 5 |
pipeline_tag: text-to-image
|
| 6 |
library_name: coreml
|
| 7 |
+
license: other
|
| 8 |
+
license_name: mixed-see-model-card
|
| 9 |
+
license_link: https://huggingface.co/Wenwu2000/MobileDiffuser-SD3-medium#licenses
|
| 10 |
tags:
|
| 11 |
- coreml
|
| 12 |
- ios
|
| 13 |
- iphone
|
| 14 |
- ane
|
| 15 |
+
- apple-neural-engine
|
| 16 |
- stable-diffusion-3
|
| 17 |
+
- flux
|
| 18 |
+
- flux2-klein
|
| 19 |
- mobile-diffusion
|
| 20 |
+
- on-device
|
| 21 |
---
|
| 22 |
|
| 23 |
+
# MobileDiffuser Core ML Models (SD3 Medium and FLUX.2 Klein)
|
| 24 |
|
| 25 |
<p>
|
| 26 |
+
<img src="assets/klein-collage.webp" alt="Collage of fourteen 1024 x 1024 FLUX.2 Klein images generated with the INT8 Core ML stages in this repository">
|
| 27 |
</p>
|
| 28 |
|
| 29 |
+
Compiled Core ML resources for [MobileDiffuser](https://github.com/TWWinde/MobileDiffuser/tree/MCL),
|
| 30 |
+
an open-source iOS app that runs diffusion models entirely on the iPhone with
|
| 31 |
+
Core ML on the Apple Neural Engine (ANE).
|
| 32 |
+
|
| 33 |
+
- **Code:** https://github.com/TWWinde/MobileDiffuser/tree/MCL
|
| 34 |
+
- **Project page:** https://twwinde.github.io/mobilediffuser-project-page/
|
| 35 |
+
|
| 36 |
+
The image above is FLUX.2 Klein, 4 steps, 1024 x 1024, from the Core ML stages in
|
| 37 |
+
this repository (rendered on a Mac).
|
| 38 |
+
|
| 39 |
+
> The repository name says "SD3-medium" for historical reasons; it now also holds
|
| 40 |
+
> the FLUX.2 Klein resources, because the app downloads everything from here.
|
| 41 |
|
| 42 |
## Contents
|
| 43 |
|
| 44 |
+
| Folder | Model | Resolution | Size | Used by the app |
|
| 45 |
+
| --- | --- | ---: | ---: | --- |
|
| 46 |
+
| `coremlsd3_2step/` | SD3 Medium, 2-step distilled | 512 | 2.9 GB | SD3M · 2 steps |
|
| 47 |
+
| `coremlsd3_reseed/` | SD3 Medium, 4-step ReSeed student | 512 | 2.9 GB | SD3M · 4 steps · 512 |
|
| 48 |
+
| `coremlsd3_reseed_1024/` | SD3 Medium, 4-step ReSeed student | 1024 | 2.9 GB | SD3M · 4 steps · 1024 |
|
| 49 |
+
| `coreml_flux2_klein_1024/` | FLUX.2 Klein 4B, 4-step distilled | 1024 | 7.5 GB | FLUX.2 Klein · 1024 |
|
| 50 |
+
| `coreml_flux2_klein_512/` | FLUX.2 Klein 4B, denoiser only | 512 | 3.9 GB | FLUX.2 Klein · 512 and the fast mode |
|
| 51 |
+
| `coremlsd3_4step/`, `coremlsd3_4step_1024/` | SD3 Medium, earlier 4-step student | 512 / 1024 | 2.9 GB each | legacy, no longer used by the app |
|
| 52 |
+
| `sd3-medium-4step-mlx-4bit/` | SD3 Medium 4-step, MLX 4-bit weights | — | 1.3 GB | not used by the Core ML app |
|
| 53 |
+
| `checkpoints/` | Source distilled SD3 Medium checkpoints (`.safetensors`) | — | 16.7 GB | for reproducing the conversion |
|
| 54 |
|
| 55 |
+
### SD3 Medium folders
|
| 56 |
|
| 57 |
+
`TextEncoder.mlmodelc`, `TextEncoder2.mlmodelc` (CLIP-L / CLIP-G), `VAEDecoder.mlmodelc`,
|
| 58 |
+
`MultiModalDiffusionTransformerConditioning.mlmodelc`, the split denoiser
|
| 59 |
+
`MultiModalDiffusionTransformerStage*.mlmodelc`, and the tokenizer files.
|
|
|
|
|
|
|
| 60 |
|
| 61 |
+
- The `coremlsd3_reseed*` folders hold one transformer block per stage (Stage0 … Stage24) and
|
| 62 |
+
`ReSeedBiases.json`. The weights are the [ReSeed](https://twwinde.github.io/reseed-project-page/)
|
| 63 |
+
SD3 Medium 4-step student; ReSeed strength 0 is the plain student, so one set of weights serves
|
| 64 |
+
both modes.
|
| 65 |
+
- The 1024 folders use exact query-chunked attention and are decoded with the 512 VAE as 3 x 3 tiles.
|
| 66 |
+
- Denoiser weights are INT8 (linear symmetric).
|
| 67 |
|
| 68 |
+
### FLUX.2 Klein folders
|
| 69 |
|
| 70 |
+
- `Embed`, `Double0…4`, `Single0…19`, `Final`: the denoiser, one transformer block per stage, INT8.
|
| 71 |
+
- `TextStage0…8` and `embed_tokens.f16`: the first 27 layers of the Qwen3-4B text encoder and its
|
| 72 |
+
token embedding table. Prompts use 256 tokens.
|
| 73 |
+
- `KleinVAEDecoder`: FLUX.2 VAE decoder for a 512 tile; 1024 is decoded as 3 x 3 tiles.
|
| 74 |
+
- `tokenizer.json`, RoPE tables and small JSON configuration files.
|
| 75 |
|
| 76 |
+
The text encoder, VAE and tokenizer exist only in `coreml_flux2_klein_1024/` and are shared by
|
| 77 |
+
both resolutions, so `coreml_flux2_klein_512/` needs the 1024 folder next to it.
|
| 78 |
+
|
| 79 |
+
## Performance
|
| 80 |
+
|
| 81 |
+
iPhone 15 Pro, iOS 18.5, `cpuAndNeuralEngine`, warm runs in the app:
|
| 82 |
+
|
| 83 |
+
| Model | Resolution | Total | App memory |
|
| 84 |
+
| --- | ---: | ---: | ---: |
|
| 85 |
+
| SD3 Medium 2-step | 512 | ~5.6 s | ~86 MB |
|
| 86 |
+
| SD3 Medium 4-step (+ ReSeed) | 512 | ~9.4 s | ~58 MB |
|
| 87 |
+
| SD3 Medium 4-step (+ ReSeed) | 1024 | ~31 s | ~146 MB |
|
| 88 |
+
| FLUX.2 Klein 4-step, full resolution | 1024 | ~77 s | ~185 MB |
|
| 89 |
+
| FLUX.2 Klein 4-step, fast (3 steps at 512, 1 at 1024) | 1024 | ~33 s | ~220 MB |
|
| 90 |
|
| 91 |
+
The first generation after install also compiles the stages on the phone, once (about 45 s for
|
| 92 |
+
SD3 Medium at 1024, a few minutes for FLUX.2 Klein). FLUX.2 Klein at 512 has not been timed on the
|
| 93 |
+
phone. Details are in the [repository docs](https://github.com/TWWinde/MobileDiffuser/tree/MCL/docs).
|
| 94 |
|
| 95 |
+
## Usage
|
| 96 |
|
| 97 |
+
**In the app (recommended).** Build MobileDiffuser from the `MCL` branch, open Settings and download
|
| 98 |
+
the resources for the selected model. No Python, Git LFS or CLI is needed. For FLUX.2 Klein at 512
|
| 99 |
+
or the fast mode, download the 1024 folder as well.
|
| 100 |
+
|
| 101 |
+
**Manually.** Download a folder and place it in the app's
|
| 102 |
+
`Application Support/MobileDiffuserModels/` directory, or bundle it into the app target for
|
| 103 |
+
development:
|
| 104 |
|
| 105 |
```bash
|
| 106 |
+
hf download Wenwu2000/MobileDiffuser-SD3-medium --include "coremlsd3_reseed/*" --local-dir .
|
|
|
|
| 107 |
```
|
| 108 |
|
| 109 |
+
**Reproducing the conversion.** Conversion scripts and notes are in the code repository:
|
| 110 |
+
`docs/REPRODUCING_MODELS.md`, `docs/ANE_1024.md`, `docs/RESEED.md` and `docs/FLUX2_KLEIN.md`.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 111 |
|
| 112 |
## Notes
|
| 113 |
|
| 114 |
+
- The resources are compiled for fixed shapes and are meant for `cpuAndNeuralEngine`.
|
| 115 |
+
- All models are step- and guidance-distilled; use guidance scale 1.0.
|
| 116 |
+
- `checkpoints/sd3-medium-4step.safetensors` is the earlier MobileDiffuser 4-step student used for
|
| 117 |
+
`coremlsd3_4step*`; the `coremlsd3_reseed*` folders were converted from the ReSeed student in
|
| 118 |
+
[Wenwu2000/ReSeed](https://huggingface.co/Wenwu2000/ReSeed).
|
| 119 |
+
|
| 120 |
+
## Licenses
|
| 121 |
+
|
| 122 |
+
- **Stable Diffusion 3 Medium** derivatives (all `coremlsd3_*` folders, `checkpoints/`,
|
| 123 |
+
`sd3-medium-4step-mlx-4bit/`): Stability AI Community License of the upstream model.
|
| 124 |
+
- **FLUX.2 Klein 4B** and its **Qwen3-4B** text encoder (`coreml_flux2_klein_*`): Apache-2.0.
|
| 125 |
+
|
| 126 |
+
Make sure your use complies with the upstream licenses.
|
| 127 |
+
|
| 128 |
+
## Citation
|
| 129 |
+
|
| 130 |
+
```bibtex
|
| 131 |
+
@misc{tang2025mobilediffuser,
|
| 132 |
+
author = {Wenwu Tang and Dong Wang and Olga Saukh},
|
| 133 |
+
title = {MobileDiffuser: On-device Stable Diffusion 3 Medium on iPhone with Core ML},
|
| 134 |
+
year = {2025},
|
| 135 |
+
publisher = {GitHub},
|
| 136 |
+
howpublished = {\url{https://github.com/TWWinde/MobileDiffuser}}
|
| 137 |
+
}
|
| 138 |
+
```
|
assets/klein-collage.webp
ADDED
|
Git LFS Details
|