Instructions to use zjwfufu/SMD-Lens with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use zjwfufu/SMD-Lens with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("fill-in-base-model", dtype=torch.bfloat16, device_map="cuda") pipe.load_lora_weights("zjwfufu/SMD-Lens") prompt = "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k" image = pipe(prompt).images[0] - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- Draw Things
- DiffusionBee
import torch
from diffusers import DiffusionPipeline
# switch to "mps" for apple devices
pipe = DiffusionPipeline.from_pretrained("fill-in-base-model", dtype=torch.bfloat16, device_map="cuda")
pipe.load_lora_weights("zjwfufu/SMD-Lens")
prompt = "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k"
image = pipe(prompt).images[0]Lens and SMD-Lens
Generate with original Lens or either four-step SMD-Lens student from one self-contained model repository. The Lens base, text encoder, tokenizer, VAE, adapters and inference code are included. The SMD training repository is not required for inference.
Training code · SMD collection
Choose a model
--variant |
Model | Denoising steps | Guidance | Weights |
|---|---|---|---|---|
base |
Original Lens | 20 | CFG 5.0 | base/ (~30.56 GB including encoder and VAE) |
teacher-lens |
Lens student distilled from Lens | 4 | 1.0 | Shared base + ~1.82 GB adapter |
teacher-flux2-9b |
Lens student distilled from FLUX.2 Klein 9B | 4 | 1.0 | Shared base + ~1.82 GB adapter |
The student variants use the same Lens architecture and base. The teacher name identifies the distillation teacher; it is not an additional model to download.
Quickstart
Use Linux, Python 3.12 and an NVIDIA GPU with CUDA support. These runners were exercised on an A100 80 GB using model CPU offload. The GPT-OSS encoder is stored in MXFP4 and dequantized to BF16 at load time; allow sufficient host RAM for the expanded encoder and model components.
python3.12 -m venv .venv
source .venv/bin/activate
python -m pip install huggingface-hub
hf auth login
hf download zjwfufu/SMD-Lens --local-dir SMD-Lens
cd SMD-Lens
python -m pip install -r requirements.txt
# Original Lens
python infer.py --variant base --output outputs/base
# Four-step Lens student
python infer.py --variant teacher-lens --output outputs/teacher-lens
# Four-step student distilled from FLUX.2 Klein 9B
python infer.py --variant teacher-flux2-9b --output outputs/teacher-flux2-9b
To download only one variant, exclude the other adapter by adding --exclude "teacher-flux2-9b/*" or --exclude "teacher-lens/*" to the download command above. Keep the shared base/ files.
Use --prompt "your description" and --seed 42 to generate another image. Each run writes sample.png and generation.json, which records the prompt, seed, dimensions, model variant and output SHA-256. The default example is 1024 × 1024.
Reproducible example
Prompt: A kraft paper parcel on a wooden table, partly open with a blue ceramic vase inside. A white shipping label on the box reads "SMD". Warm window light, natural product photography.
Seed: 42. Resolution: 1024 × 1024.
The following images were generated by the included standalone runner using the same prompt, seed and resolution. Original Lens uses 20 steps; both SMD students use 4 steps.
Case metadata and generation receipts are stored alongside each image: Original Lens, Lens teacher, FLUX.2 teacher. Small numerical differences are possible across GPU architectures and dependency versions.
Loading and sampling details
lens/ provides LensPipeline, LensGptOssEncoder and LensTransformer2DModel. infer.py loads these components directly from base/; it does not require a custom remote-code import or the SMD training package.
Each adapter contains LoRA matrices and two saved replacement tensors. The supplied loader validates and applies both, using the precision recorded in <variant>/lora/adapter_config.json. A generic LoRA loader that omits the replacement tensors will not reproduce the released student.
Student sampling uses four Euler segments. The final raw segment has relative size 0.5, followed by Lens's empirical time shift with the 50-step reference setting. External classifier-free guidance is disabled. <variant>/sampling.json and the supplied scheduler retain these settings; changing only num_inference_steps in a base pipeline is insufficient.
License
Lens code and model weights are provided under the MIT license; see LICENSE. Original copyright notices are retained. Bundled components retain their respective upstream terms. The SMD inference helper's Apache-2.0 notice is retained in its source.
- Downloads last month
- -


