From ef501c4919917cadb3a146e9c26db4119bddea7e Mon Sep 17 00:00:00 2001 From: Cherrytest Date: Wed, 13 Aug 2025 10:34:09 +0000 Subject: [PATCH] Upload Qwen-Image-Lightning-8steps-V1.1-bf16.safetensors with ModelScope SDK --- ...age-Lightning-4steps-V1.0-bf16.safetensors | 3 ++ Qwen-Image-Lightning-4steps-V1.0.safetensors | 3 ++ ...age-Lightning-8steps-V1.1-bf16.safetensors | 3 ++ Qwen-Image-Lightning-8steps-V1.1.safetensors | 3 ++ README.md | 51 ++++++++++++++++++- 5 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 Qwen-Image-Lightning-4steps-V1.0-bf16.safetensors create mode 100644 Qwen-Image-Lightning-4steps-V1.0.safetensors create mode 100644 Qwen-Image-Lightning-8steps-V1.1-bf16.safetensors create mode 100644 Qwen-Image-Lightning-8steps-V1.1.safetensors diff --git a/Qwen-Image-Lightning-4steps-V1.0-bf16.safetensors b/Qwen-Image-Lightning-4steps-V1.0-bf16.safetensors new file mode 100644 index 0000000..22c8dbd --- /dev/null +++ b/Qwen-Image-Lightning-4steps-V1.0-bf16.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b01c59cba1454cfb16d069711233371eabf63603481b589f585659e852af7255 +size 134 diff --git a/Qwen-Image-Lightning-4steps-V1.0.safetensors b/Qwen-Image-Lightning-4steps-V1.0.safetensors new file mode 100644 index 0000000..cfe6431 --- /dev/null +++ b/Qwen-Image-Lightning-4steps-V1.0.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:af76d68526a238c860e4524e67be8e8ca8524c76b0159ede0bb7241604e2749d +size 135 diff --git a/Qwen-Image-Lightning-8steps-V1.1-bf16.safetensors b/Qwen-Image-Lightning-8steps-V1.1-bf16.safetensors new file mode 100644 index 0000000..6cccf27 --- /dev/null +++ b/Qwen-Image-Lightning-8steps-V1.1-bf16.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b12733a664f6c43401d37d73d6cf5f899c44dbf807ace167794ea313ec93ad91 +size 134 diff --git a/Qwen-Image-Lightning-8steps-V1.1.safetensors b/Qwen-Image-Lightning-8steps-V1.1.safetensors new file mode 100644 index 0000000..8c74eec --- /dev/null +++ b/Qwen-Image-Lightning-8steps-V1.1.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:cc2fa0f2b5a1f79bcde95fc76f002246583368ea17855b68470669fe10cdf5bb +size 135 diff --git a/README.md b/README.md index 957cb67..bd09c22 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,55 @@ pipeline_tag: text-to-image tags: - Qwen-Image; - distillation; +- LoRA +library_name: diffusers --- -Please refer to [Qwen-Image-Lightning github](https://github.com/ModelTC/Qwen-Image-Lightning/) to learn how to use the models. \ No newline at end of file +Please refer to [Qwen-Image-Lightning github](https://github.com/ModelTC/Qwen-Image-Lightning/) to learn how to use the models. + +use with diffusers 🧨: + +make sure to install diffusers from `main` (`pip install git+https://github.com/huggingface/diffusers.git`) +``` +from diffusers import DiffusionPipeline, FlowMatchEulerDiscreteScheduler +import torch +import math + +# From https://github.com/ModelTC/Qwen-Image-Lightning/blob/342260e8f5468d2f24d084ce04f55e101007118b/generate_with_diffusers.py#L82C9-L97C10 +scheduler_config = { + "base_image_seq_len": 256, + "base_shift": math.log(3), # We use shift=3 in distillation + "invert_sigmas": False, + "max_image_seq_len": 8192, + "max_shift": math.log(3), # We use shift=3 in distillation + "num_train_timesteps": 1000, + "shift": 1.0, + "shift_terminal": None, # set shift_terminal to None + "stochastic_sampling": False, + "time_shift_type": "exponential", + "use_beta_sigmas": False, + "use_dynamic_shifting": True, + "use_exponential_sigmas": False, + "use_karras_sigmas": False, +} +scheduler = FlowMatchEulerDiscreteScheduler.from_config(scheduler_config) +pipe = DiffusionPipeline.from_pretrained( + "Qwen/Qwen-Image", scheduler=scheduler, torch_dtype=torch.bfloat16 +).to("cuda") +pipe.load_lora_weights( + "lightx2v/Qwen-Image-Lightning", weight_name="Qwen-Image-Lightning-8steps-V1.0.safetensors" +) + +prompt = "a tiny astronaut hatching from an egg on the moon, Ultra HD, 4K, cinematic composition." +negative_prompt = " " +image = pipe( + prompt=prompt, + negative_prompt=negative_prompt, + width=1024, + height=1024, + num_inference_steps=8, + true_cfg_scale=1.0, + generator=torch.manual_seed(0), +).images[0] +image.save("qwen_fewsteps.png") +``` \ No newline at end of file