kimi000's picture
Add validated standalone four-step 2000-step EMA and demo
fc7eaf0 verified
|
Raw History Blame Contribute Delete
5.03 kB
---
library_name: diffusers
pipeline_tag: text-to-image
base_model: black-forest-labs/FLUX.1-dev
license: other
license_name: flux-1-dev-non-commercial-license
license_link: LICENSE.md
tags:
- diffusers
- custom-pipeline
- flux
- distilled
---
# FLUX.1-dev Four-Step · 2000
Standalone Diffusers-format **generator EMA from exactly 2000 optimizer updates**. Includes merged transformer weights, CLIP and T5 encoders, tokenizers, VAE, custom pipeline/scheduler, `demo.py`, dependencies, validation report and sample images. No training checkout, PEFT adapter merge or separate base-model download is needed.
This checkpoint uses native single-time conditioning and a global velocity readout with 128 bases. The included transformer integrates those outputs over each denoising interval. All 838 EMA adapter tensors across 419 attention/MLP/output modules are merged into the base model. Conditioning projections remain frozen. The fake model and optimizer states are not needed for inference and are not included.
## Install and run
Use Python 3.10+ and a CUDA GPU. Install a CUDA-enabled PyTorch build for your hardware, then:
```bash
hf download kimi000/Flux1-Dev-4Step-2000 --local-dir Flux1-Dev-4Step-2000
cd Flux1-Dev-4Step-2000
python -m pip install -r requirements.txt
python demo.py --model . --cpu-offload --prompt 'A vintage pastel illustration of a tropical beach with palm trees and gentle waves.' --output beach.png
python demo.py --model . --cpu-offload --prompt 'A white ceramic mug with the words "GOOD MORNING" printed in large blue letters.' --output mug.png
```
Alternatively, download just `demo.py` and `requirements.txt`; the demo defaults to `kimi000/Flux1-Dev-4Step-2000` and automatically downloads the weights. `--revision <commit>` pins model and custom code. With `--cpu-offload`, components move to CUDA when needed; without it, components stay on GPU and need substantially more VRAM. Host RAM and GPU needs depend on software and resolution. If downloads stall, retry with `HF_HUB_DISABLE_XET=1`.
## Python API
```python
import torch
from diffusers import DiffusionPipeline
repo = "kimi000/Flux1-Dev-4Step-2000"
pipe = DiffusionPipeline.from_pretrained(
repo, custom_pipeline=repo, trust_remote_code=True,
torch_dtype=torch.bfloat16,
)
pipe.enable_model_cpu_offload()
image = pipe(
prompt='A white ceramic mug with the words "GOOD MORNING" printed in blue.',
num_inference_steps=4, guidance_scale=3.5,
height=1024, width=1024,
generator=torch.Generator(device="cpu").manual_seed(0),
).images[0]
image.save("result.png")
```
## Required settings
- **Use four steps and `guidance_scale=3.5`.** The guidance value is the native FLUX.1-dev distilled guidance embedding. No additional two-pass classifier-free guidance or negative prompt is used.
- **Use the included custom pipeline, transformer and scheduler together.** Standard `FluxPipeline` cannot interpret the expanded output projection. The backbone receives the current time only; the interval endpoint controls the integrated readout. The raw schedule is `1-j/3.3` for `j=0..3`, followed by zero, with rational shift `exp(1.15)` and final-step scale `0.3`.
- Loading requires `custom_pipeline=repo, trust_remote_code=True`. Review the included Python files before enabling remote code.
- Transformer and text encoders use **BF16**; VAE decoding remains **FP32**. The custom VAE loader preserves this. Do not cast the entire pipeline to BF16.
- Use a **CPU** `torch.Generator` to match the training noise path. Initial noise is BF16 rounded, integration is FP32. Results can vary across hardware and library versions.
- Training resolution is **1024×1024**. Dimensions must be multiples of 16 and at least 64. CLIP and T5 prompts are truncated to 77 and 512 tokens respectively. No prompt upsampler is used.
- The English training prompt mixture is 50% MJHQ, 25% sampled TextAtlas and 25% text-rendering reward prompts. Training uses prompts without target images, global batch size 128, and AdamW betas `(0, 0.999)`.
- This is an experimental four-step checkpoint. Numerical parity and valid image files do not establish visual quality or OCR accuracy; text can contain errors.
- EMA deltas are merged in FP32 and rounded into BF16 weights. The included validation compares the exported sampler with the training model loaded with those exact merged weights.
## Examples and validation
![Beach](example.png)
![Text-rendering demo](demo_mug.png)
See `validation_report.json` for actual GPU parity, component precision, four transformer calls and sampling results. `export_metadata.json` identifies the source step, checkpoint checksum and merged tensor hashes. `file_manifest.json` provides checksums for the uploaded artifacts.
## License
The original **FLUX.1 [dev] Non-Commercial License** applies. See `LICENSE.md`, `NOTICE.md` and `BASE_MODEL_CARD.md`. This derivative is published by kimi000 and is not an official Black Forest Labs release. Base revision: `3de623fc3c33e44ffbe2bad470d0f45bccf2eb21`.