Instructions to use zjwfufu/SMD-FLUX.2-Klein-4B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use zjwfufu/SMD-FLUX.2-Klein-4B 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-base-4B", dtype=torch.bfloat16, device_map="cuda") pipe.load_lora_weights("zjwfufu/SMD-FLUX.2-Klein-4B") 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
SMD-FLUX.2-Klein-4B
4-step SMD for text-to-image generation. The student adapters, standalone inference code and reproducible examples are included. Upstream base components are downloaded separately.
Training code · SMD collection
Example
Both four-step students use the same prompt, seed and resolution.
Prompt: A brown leather luggage tag embossed with "SMD" in large uppercase letters, written horizontally. The tag hangs from a silver suitcase handle. Close-up travel photography, warm airport window light.
Seed: 1234. Size: 1024 × 1024. Steps: 4.
Models
| Variant | Weights | Steps | Size |
|---|---|---|---|
| teacher-9b | LoRA | 4 | 0.58 GB |
| teacher-4b | LoRA | 4 | 0.58 GB |
Both variants use the same 4B student. The 9B teacher is not required for inference. Select teacher-9b or teacher-4b with --variant.
Run
Base: black-forest-labs/FLUX.2-klein-base-4B.
Use Linux, Python 3.12 and an NVIDIA GPU with CUDA support. The included inference code does not import the SMD training repository.
python3.12 -m venv .venv
source .venv/bin/activate
python -m pip install huggingface-hub
# Sign in to Hugging Face.
hf auth login
hf download zjwfufu/SMD-FLUX.2-Klein-4B --local-dir SMD-FLUX.2-Klein-4B --exclude 'teacher-4b/lora/lora.safetensors' 'teacher-9b/lora/lora.safetensors'
cd SMD-FLUX.2-Klein-4B
python -m pip install -r requirements.txt
python infer.py --variant teacher-9b --output outputs
The example was run on an A100 80 GB. Model CPU offload reduces GPU memory usage; enough host RAM is still needed to load the upstream components. Use --prompt, --seed and --output to generate another case. --base accepts a local upstream snapshot.
The first run downloads the upstream base components to the Hugging Face cache. Plan disk space for those components as well as the released weights; subsequent runs reuse the cache.
Weight layout
Student weights are also published at the repository root (teacher-4b.safetensors, teacher-9b.safetensors). The legacy weight paths remain available for existing integrations. The download command above excludes the duplicate legacy weights; the supplied loader prefers root weights and falls back to legacy paths. Adapter configurations, merge precision and sampling schedules are preserved.
Sampling
The released sampler uses raw final-segment scale 0.5. The raw grid is built before the model-specific time shift. The included runner follows <variant>/sampling.json; changing only an upstream pipeline's step count does not reproduce the student.
External classifier-free guidance is disabled for the students. Any embedded guidance remains specified in <variant>/sampling.json.
The supplied loader validates and applies all LoRA matrices and saved replacement tensors, with the recorded merge precision. Omitting replacement tensors or using a different base can change the result.
License and attribution
Base components retain the terms described in the black-forest-labs/FLUX.2-klein-base-4B model card. Original code notices and bundled licenses are retained. Adapter use remains subject to the applicable base-model terms.
- Downloads last month
- 142
Model tree for zjwfufu/SMD-FLUX.2-Klein-4B
Base model
black-forest-labs/FLUX.2-klein-base-4B
