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
File size: 2,560 Bytes
7a84461 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | ---
license: mit
base_model:
- black-forest-labs/FLUX.2-klein-4B
- openbmb/MiniCPM5-1B
- black-forest-labs/FLUX.2-small-decoder
tags:
- flux
- flux2
- distillation
- lora
- text-to-image
- diffusers
library_name: diffusers
pipeline_tag: text-to-image
---
# flux2tiny — Distilled FLUX.2-klein-4B with MiniCPM5-1B Text Encoder
This repository contains the **trained adapter and LoRA weights** for flux2tiny,
a distilled version of [FLUX.2-klein-4B](https://huggingface.co/black-forest-labs/FLUX.2-klein-4B)
that replaces the 4B-parameter Qwen3-4B text encoder with
[MiniCPM5-1B](https://huggingface.co/openbmb/MiniCPM5-1B) (1.08B parameters).
## What's in this repo
| File | Size | Description |
|:-----|:-----|:------------|
| `adapter.safetensors` | ~23 MB | Projection adapter (3× Linear 1536→2560, concatenated to 7680) |
| `transformer_lora/adapter_model.safetensors` | ~7.5 MB | PEFT LoRA weights (rank 16) for Flux2Transformer2DModel |
| `transformer_lora/adapter_config.json` | ~1 KB | PEFT LoRA configuration |
## Required base models (downloaded automatically)
- [black-forest-labs/FLUX.2-klein-4B](https://huggingface.co/black-forest-labs/FLUX.2-klein-4B) — Transformer backbone
- [openbmb/MiniCPM5-1B](https://huggingface.co/openbmb/MiniCPM5-1B) — Student text encoder
- [black-forest-labs/FLUX.2-small-decoder](https://huggingface.co/black-forest-labs/FLUX.2-small-decoder) — VAE decoder
## Usage
```python
# Clone the code repo
# git clone https://github.com/ElMiloPy/flux2tiny.git
from pipeline import Flux2TinyPipeline
pipe = Flux2TinyPipeline(
adapter_path="path/to/adapter.safetensors",
lora_path="path/to/transformer_lora",
)
image = pipe("A cat sitting on a windowsill at sunset", height=512, width=512)
image.save("output.png")
```
Or via CLI:
```bash
python generate.py "A cat sitting on a windowsill at sunset" \
--adapter path/to/adapter.safetensors \
--lora path/to/transformer_lora \
--size 512x512
```
## Training details
Trained via a 3-stage knowledge distillation pipeline:
1. **Adapter pre-training** — MSE alignment between MiniCPM5-1B and Qwen3-4B hidden states
2. **Teacher latent generation** — 15,000 latent-prompt pairs from the original FLUX.2 pipeline
3. **Flow Matching LoRA distillation** — Joint training of adapter + transformer LoRA on teacher latents
See [github.com/ElMiloPy/flux2tiny](https://github.com/ElMiloPy/flux2tiny) for full details.
## License
- **These weights**: MIT
- **FLUX.2-klein-4B**: Apache 2.0
- **MiniCPM5-1B**: Apache 2.0
|