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
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 | Root pipeline (~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 --exclude "base/*" "*/lora/lora.safetensors"
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
The command excludes legacy duplicate weights. To download only the original Lens base, add "teacher-lens/*" "teacher-lens.safetensors" "teacher-flux2-9b/*" "teacher-flux2-9b.safetensors" to the existing --exclude list; keep the root model_index.json, scheduler/, text_encoder/, tokenizer/, transformer/ and vae/. For a single student, exclude only the other student’s directory and root safetensors file.
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 reads the root model_index.json and loads the complete pipeline from the repository root; it does not require a custom remote-code import or the SMD training package.
The original base/ pipeline and nested adapter weights remain available for existing integrations. The runner falls back to base/ when the root pipeline index is absent; --base still accepts an explicit legacy or custom pipeline path. The student loader prefers <variant>.safetensors at the root and falls back to <variant>/lora/lora.safetensors. Root and legacy weights are byte-identical.
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
- 55


