topabaem's picture
Make model card concise and image-focused; move full details to linked pages
a99bedb verified
|
Raw History Blame Contribute Delete
2.6 kB

Setup and usage

← Model card · Model details and benchmarks

This repository contains a custom LoRA adapter, not the full base model. Use ultraedit_adapter.py to load it. The file has not been converted to standard PEFT/Diffusers LoRA names, so load_lora_weights() is not the loading path for this release.

1. Prepare the environment

Use a CUDA-enabled PyTorch environment with BF16 support. Install the adapter dependencies and the pipeline revisions used by this project:

pip install huggingface_hub safetensors accelerate
pip install "git+https://github.com/huggingface/diffusers@cc8644b447d8f11074d3df06d0ee0e3e7c91bf75"
pip install "git+https://github.com/huggingface/transformers@207fca7b5b9c5f0444dac9abc968be5d429a650d"

2. Download and load the adapter

The following example downloads the helper before importing it, loads the pinned base transformer, and applies the trained adapter:

from pathlib import Path
import sys
import torch
from huggingface_hub import snapshot_download
from diffusers import QwenImage21Transformer2DModel

local = Path(snapshot_download(
    "Haverbex/Qwen-Image-2.1-UltraFast",
    allow_patterns=["adapter/*", "ultraedit_adapter.py", "configs/*", "LICENSE", "NOTICE"],
))
sys.path.insert(0, str(local))
from ultraedit_adapter import inject_dit_lora, load_adapter

transformer = QwenImage21Transformer2DModel.from_pretrained(
    "Qwen/Qwen-Image-2.1",
    subfolder="transformer",
    revision="790c92633540aa0cb11d9abf19eb46d861714758",
    torch_dtype=torch.bfloat16,
    device_map={"": "cuda:0"},
)
adapters = inject_dit_lora(
    transformer, rank=32, alpha=32, adapter_dtype=torch.bfloat16,
)
load_adapter(adapters, local / "adapter")
transformer.eval()

3. Use the recorded generation setup

The code above loads weights only. Image generation also requires the Qwen-Image-2.1 text/image encoders, processor, scheduler and VAE. The published examples used staged conditioning and FP32 VAE decoding; that complete staged runner is not included in this repository.

Use the eight intervals in configs/schedule.json. Its sigma values are already shifted, and applying another shift changes the trained schedule. Selecting an arbitrary pipeline's default 8 steps does not establish the same setup.

The runtime source lock and training configuration provide the remaining experiment details. No private Mix-STQ implementation or quantized text-encoder weights are included.