README.md
1.9 KB · 64 lines · markdown Raw
1 ---
2 license: apache-2.0
3 language:
4 - en
5 - zh
6 base_model:
7 - Qwen/Qwen-Image
8 pipeline_tag: text-to-image
9 tags:
10 - Qwen-Image
11 - distillation
12 - LoRA
13 - lora
14 library_name: diffusers
15 ---
16
17 Please refer to [Qwen-Image-Lightning github](https://github.com/ModelTC/Qwen-Image-Lightning/) to learn how to use the models.
18
19 use with diffusers 🧨:
20
21 make sure to install diffusers from `main` (`pip install git+https://github.com/huggingface/diffusers.git`)
22 ```
23 from diffusers import DiffusionPipeline, FlowMatchEulerDiscreteScheduler
24 import torch
25 import math
26
27 # From https://github.com/ModelTC/Qwen-Image-Lightning/blob/342260e8f5468d2f24d084ce04f55e101007118b/generate_with_diffusers.py#L82C9-L97C10
28 scheduler_config = {
29 "base_image_seq_len": 256,
30 "base_shift": math.log(3), # We use shift=3 in distillation
31 "invert_sigmas": False,
32 "max_image_seq_len": 8192,
33 "max_shift": math.log(3), # We use shift=3 in distillation
34 "num_train_timesteps": 1000,
35 "shift": 1.0,
36 "shift_terminal": None, # set shift_terminal to None
37 "stochastic_sampling": False,
38 "time_shift_type": "exponential",
39 "use_beta_sigmas": False,
40 "use_dynamic_shifting": True,
41 "use_exponential_sigmas": False,
42 "use_karras_sigmas": False,
43 }
44 scheduler = FlowMatchEulerDiscreteScheduler.from_config(scheduler_config)
45 pipe = DiffusionPipeline.from_pretrained(
46 "Qwen/Qwen-Image", scheduler=scheduler, torch_dtype=torch.bfloat16
47 ).to("cuda")
48 pipe.load_lora_weights(
49 "lightx2v/Qwen-Image-Lightning", weight_name="Qwen-Image-Lightning-8steps-V1.0.safetensors"
50 )
51
52 prompt = "a tiny astronaut hatching from an egg on the moon, Ultra HD, 4K, cinematic composition."
53 negative_prompt = " "
54 image = pipe(
55 prompt=prompt,
56 negative_prompt=negative_prompt,
57 width=1024,
58 height=1024,
59 num_inference_steps=8,
60 true_cfg_scale=1.0,
61 generator=torch.manual_seed(0),
62 ).images[0]
63 image.save("qwen_fewsteps.png")
64 ```