Instructions to use Emilio407/flux2tiny-MiniCPM5-1B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use Emilio407/flux2tiny-MiniCPM5-1B with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("black-forest-labs/FLUX.2-klein-4B,openbmb/MiniCPM5-1B,black-forest-labs/FLUX.2-small-decoder", dtype=torch.bfloat16, device_map="cuda") pipe.load_lora_weights("Emilio407/flux2tiny-MiniCPM5-1B") prompt = "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k" image = pipe(prompt).images[0] - Inference
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- Draw Things
- DiffusionBee
Upload README.md with huggingface_hub
Browse files
README.md
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: mit
|
| 3 |
+
base_model:
|
| 4 |
+
- black-forest-labs/FLUX.2-klein-4B
|
| 5 |
+
- openbmb/MiniCPM5-1B
|
| 6 |
+
- black-forest-labs/FLUX.2-small-decoder
|
| 7 |
+
tags:
|
| 8 |
+
- flux
|
| 9 |
+
- flux2
|
| 10 |
+
- distillation
|
| 11 |
+
- lora
|
| 12 |
+
- text-to-image
|
| 13 |
+
- diffusers
|
| 14 |
+
library_name: diffusers
|
| 15 |
+
pipeline_tag: text-to-image
|
| 16 |
+
---
|
| 17 |
+
|
| 18 |
+
# flux2tiny — Distilled FLUX.2-klein-4B with MiniCPM5-1B Text Encoder
|
| 19 |
+
|
| 20 |
+
This repository contains the **trained adapter and LoRA weights** for flux2tiny,
|
| 21 |
+
a distilled version of [FLUX.2-klein-4B](https://huggingface.co/black-forest-labs/FLUX.2-klein-4B)
|
| 22 |
+
that replaces the 4B-parameter Qwen3-4B text encoder with
|
| 23 |
+
[MiniCPM5-1B](https://huggingface.co/openbmb/MiniCPM5-1B) (1.08B parameters).
|
| 24 |
+
|
| 25 |
+
## What's in this repo
|
| 26 |
+
|
| 27 |
+
| File | Size | Description |
|
| 28 |
+
|:-----|:-----|:------------|
|
| 29 |
+
| `adapter.safetensors` | ~23 MB | Projection adapter (3× Linear 1536→2560, concatenated to 7680) |
|
| 30 |
+
| `transformer_lora/adapter_model.safetensors` | ~7.5 MB | PEFT LoRA weights (rank 16) for Flux2Transformer2DModel |
|
| 31 |
+
| `transformer_lora/adapter_config.json` | ~1 KB | PEFT LoRA configuration |
|
| 32 |
+
|
| 33 |
+
## Required base models (downloaded automatically)
|
| 34 |
+
|
| 35 |
+
- [black-forest-labs/FLUX.2-klein-4B](https://huggingface.co/black-forest-labs/FLUX.2-klein-4B) — Transformer backbone
|
| 36 |
+
- [openbmb/MiniCPM5-1B](https://huggingface.co/openbmb/MiniCPM5-1B) — Student text encoder
|
| 37 |
+
- [black-forest-labs/FLUX.2-small-decoder](https://huggingface.co/black-forest-labs/FLUX.2-small-decoder) — VAE decoder
|
| 38 |
+
|
| 39 |
+
## Usage
|
| 40 |
+
|
| 41 |
+
```python
|
| 42 |
+
# Clone the code repo
|
| 43 |
+
# git clone https://github.com/ElMiloPy/flux2tiny.git
|
| 44 |
+
|
| 45 |
+
from pipeline import Flux2TinyPipeline
|
| 46 |
+
|
| 47 |
+
pipe = Flux2TinyPipeline(
|
| 48 |
+
adapter_path="path/to/adapter.safetensors",
|
| 49 |
+
lora_path="path/to/transformer_lora",
|
| 50 |
+
)
|
| 51 |
+
|
| 52 |
+
image = pipe("A cat sitting on a windowsill at sunset", height=512, width=512)
|
| 53 |
+
image.save("output.png")
|
| 54 |
+
```
|
| 55 |
+
|
| 56 |
+
Or via CLI:
|
| 57 |
+
```bash
|
| 58 |
+
python generate.py "A cat sitting on a windowsill at sunset" \
|
| 59 |
+
--adapter path/to/adapter.safetensors \
|
| 60 |
+
--lora path/to/transformer_lora \
|
| 61 |
+
--size 512x512
|
| 62 |
+
```
|
| 63 |
+
|
| 64 |
+
## Training details
|
| 65 |
+
|
| 66 |
+
Trained via a 3-stage knowledge distillation pipeline:
|
| 67 |
+
|
| 68 |
+
1. **Adapter pre-training** — MSE alignment between MiniCPM5-1B and Qwen3-4B hidden states
|
| 69 |
+
2. **Teacher latent generation** — 15,000 latent-prompt pairs from the original FLUX.2 pipeline
|
| 70 |
+
3. **Flow Matching LoRA distillation** — Joint training of adapter + transformer LoRA on teacher latents
|
| 71 |
+
|
| 72 |
+
See [github.com/ElMiloPy/flux2tiny](https://github.com/ElMiloPy/flux2tiny) for full details.
|
| 73 |
+
|
| 74 |
+
## License
|
| 75 |
+
|
| 76 |
+
- **These weights**: MIT
|
| 77 |
+
- **FLUX.2-klein-4B**: Apache 2.0
|
| 78 |
+
- **MiniCPM5-1B**: Apache 2.0
|