Instructions to use PrunaAI/P-Q-Image-2.1 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use PrunaAI/P-Q-Image-2.1 with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("Qwen/Qwen-Image-2.1", dtype=torch.bfloat16, device_map="cuda") pipe.load_lora_weights("PrunaAI/P-Q-Image-2.1") 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
Update README.md
Browse files1234567891011121314151617181920212223242526275 unmodified lines333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283---license: otherlicense_name: qwen-researchlicense_link: LICENSEbase_model: Qwen/Qwen-Image-2.1base_model_relation: adapterlibrary_name: diffuserspipeline_tag: text-to-imagetags:- diffusers- qwen- image-generation- image-editing- rgba- lora- distilled- few-step---# Qwen-Image-2.1-P-Turbo**Improved using Qwen.** A five-step LoRA adapter for [Qwen Image 2.1](https://huggingface.co/Qwen/Qwen-Image-2.1). The adapter weights are a modification of the base model; its license applies. The `_comfyui_bf16.safetensors` file is for ComfyUI. Use LoRA strength 1.0, BF16 timestep frequencies, float32 Euler updates, and sigma schedule `1 β 13/14 β 6/7 β 2/3 β 0.4 β 0`.## Quick Start```bashpip install 'torch>=2.4.0' 'transformers>=5.17' accelerate peft pillow5 unmodified linesimport torchfrom PIL import Imagefrom diffusers import FlowMatchEulerDiscreteScheduler, QwenImage21Pipelinefrom diffusers.schedulers.scheduling_flow_match_euler_discrete import FlowMatchEulerDiscreteSchedulerOutputclass Float32EulerScheduler(FlowMatchEulerDiscreteScheduler):def step(self, model_output, timestep, sample, return_dict=True, **kwargs):if self.step_index is None:self._init_step_index(timestep)dt = self.sigmas[self.step_index + 1] - self.sigmas[self.step_index]prev = (sample.float() + dt * model_output.float()).to(model_output.dtype)self._step_index += 1return FlowMatchEulerDiscreteSchedulerOutput(prev_sample=prev) if return_dict else (prev,)pipe = QwenImage21Pipeline.from_pretrained("Qwen/Qwen-Image-2.1", torch_dtype=torch.bfloat16).to("cuda")pipe.load_lora_weights("PrunaAI/Qwen-Image-2.1-P-Turbo",weight_name="p_qwen_image_2.1_5step_v1.0.safetensors",)# Match the BF16 timestep embedding used by this adapter.time_proj = pipe.transformer.time_text_embed.time_projtime_proj.freqs = time_proj.freqs.to(torch.bfloat16)pipe.scheduler = Float32EulerScheduler.from_config(pipe.scheduler.config,use_dynamic_shifting=False,shift=1.0,shift_terminal=None,)sigmas = [1.0, 13 / 14, 6 / 7, 2 / 3, 0.4] # terminal 0 is appended# Text-to-imageimage = pipe(prompt='A neon shop sign that reads "QWEN IMAGE 2.1", rainy night',width=1024, height=1024,num_inference_steps=5, sigmas=sigmas, true_cfg_scale=1.0, use_kv_cache=False,generator=torch.Generator("cuda").manual_seed(42),).images[0]image.save("t2i_example.png")# Image editinginput_image = Image.open("input.png").convert("RGB")image = pipe(prompt="Change the background to a sunset beach",image=input_image,num_inference_steps=5, sigmas=sigmas, true_cfg_scale=1.0, use_kv_cache=False,generator=torch.Generator("cuda").manual_seed(42),).images[0]image.save("edit_example.png")```123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869705 unmodified lines767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177---license: otherlicense_name: qwen-researchbase_model: Qwen/Qwen-Image-2.1library_name: diffuserspipeline_tag: text-to-imagetags:- qwen- image-generation- image-editing- rgba- lora- distilled- few-step---<!-- header start --><!-- 200823 --><div style="width: auto; margin-left: auto; margin-right: auto"><a href="https://docs.pruna.ai/en/stable/index.html" target="_blank" rel="noopener noreferrer"><img src="https://imgur.com/rVAgqMY.png" alt="PrunaAI" style="width: 100%; min-width: 400px; display: block; margin: auto;"></a></div><!-- header end -->[](https://github.com/PrunaAI/pruna) [](https://twitter.com/PrunaAI) [](https://www.linkedin.com/company/pruna-ai) [](https://discord.com/invite/JFQmtFKCjd) [](https://dashboard.pruna.ai/login?utm_source=huggingface&utm_medium=org_card&utm_campaign=hf_traffic)<div align="center"><h1 style="color: #9334E9;">β‘ Qwen-Image-2.1-P-Turbo</h1><h2>Few-step LoRA adapters for Qwen-Image-2.1</h2><h3><span style="color: #9334E9;">5 or 8 steps</span> Β· <span style="color: #9334E9;">No CFG</span> Β· Text-to-image and image editing</h3></div>**Qwen-Image-2.1-P-Turbo is a set of LoRA adapters that let[`Qwen/Qwen-Image-2.1`](https://huggingface.co/Qwen/Qwen-Image-2.1) generateand edit images in only 5 or 8 steps. The adapters load on top of the basemodel, so the pipeline, text encoder and VAE stay unchanged. Training is basedon DMD. Improved using Qwen.**> **v0.1: first release, work in progress.** P-Turbo does not yet match the> visual quality of the base model. We are still improving the distillation and> will update this repository as new versions become available.## VariantsBoth adapters are v0.1. Pick one based on whether you need quality or speed.| File | Steps | Trade-off ||---|:---:|---|| `p_qwen_image_2.1_8step_v0.1.safetensors` | 8 | **Higher quality.** Recommended as the default. || `p_qwen_image_2.1_5step_v0.1.safetensors` | 5 | **Higher speed**, with noticeably lower visual quality. |Each adapter is trained for its own sigma schedule. Load only one at a time.## QuickstartRuns text-to-image and image editing with the same pipeline. Needs a **CUDA GPU**.```bashpip install 'torch>=2.4.0' 'transformers>=5.17' accelerate peft pillow5 unmodified linesimport torchfrom PIL import Imagefrom diffusers import FlowMatchEulerDiscreteScheduler, QwenImage21PipelineSTEPS = 8 # 8 for higher quality, 5 for higher speed# The terminal sigma 0 is appended by the scheduler.SIGMAS = {5: [1.0, 13 / 14, 6 / 7, 2 / 3, 0.4],8: [1.0, 14 / 15, 6 / 7, 10 / 13, 2 / 3, 6 / 11, 0.4, 2 / 9],}[STEPS]pipe = QwenImage21Pipeline.from_pretrained("Qwen/Qwen-Image-2.1", torch_dtype=torch.bfloat16).to("cuda")pipe.load_lora_weights("PrunaAI/Qwen-Image-2.1-P-Turbo",weight_name=f"p_qwen_image_2.1_{STEPS}step_v0.1.safetensors",)# Use the sigmas exactly as given: no extra shifting.pipe.scheduler = FlowMatchEulerDiscreteScheduler.from_config(pipe.scheduler.config,use_dynamic_shifting=False,shift=1.0,shift_terminal=None,)settings = dict(num_inference_steps=STEPS,sigmas=SIGMAS,true_cfg_scale=1.0,use_kv_cache=False,)# Text-to-image: longer, more descriptive prompts give better results.image = pipe(prompt=('A glowing neon shop sign that reads "QWEN IMAGE 2.1", mounted on a brick wall '"in a narrow city alley at night. Heavy rain, wet pavement reflecting pink and ""blue light, shallow depth of field, cinematic photograph."),width=1024,height=1024,generator=torch.Generator("cuda").manual_seed(42),**settings,).images[0]image.save("t2i_example.png")# Image editingimage = pipe(prompt="Change the background to a sunset beach",image=Image.open("input.png").convert("RGB"),generator=torch.Generator("cuda").manual_seed(42),**settings,).images[0]image.save("edit_example.png")```## Recommended settings- **Use the sigma schedule that matches your adapter**, and keep the schedulerat `shift=1.0` with dynamic shifting off so the sigmas are not shifted twice.- 8-step: `1 β 14/15 β 6/7 β 10/13 β 2/3 β 6/11 β 0.4 β 2/9 β 0`(shift 2, computed as `Ο = 2t / (1 + t)` on evenly spaced `t`)- 5-step: `1 β 13/14 β 6/7 β 2/3 β 0.4 β 0`- **No CFG.** Keep `true_cfg_scale=1.0` and do not pass a negative prompt.- **Keep the LoRA strength at 1.0.**- **Write detailed prompts for text-to-image.** Longer prompts that describethe subject, setting, lighting and style work noticeably better than shortones.## Limitations- This is a first version. Quality is below that of the base model.- The 5-step adapter is faster than the 8-step one, but its images arevisibly worse.- Short or vague text-to-image prompts give weaker results.- The adapters are only intended for the settings above. Other step counts,schedules or CFG values are not supported.## What this is not- Not a standalone model. It needs the `Qwen/Qwen-Image-2.1` base weights.- Not a replacement for the base model when you need its full quality.- Not a finished release. Expect the weights to change in future versions.## LicenseQwen-Image-2.1-P-Turbo is a derivative of Qwen-Image-2.1 and is distributedunder the **Qwen RESEARCH LICENSE AGREEMENT**. Review its use restrictionsbefore using or redistributing the adapters.Qwen is licensed under the Qwen RESEARCH LICENSE AGREEMENT, Copyright (c) 2026Hangzhou Tongyi Laboratory Technology Co., Ltd. All Rights Reserved.## What's next?- **Use P-Turbo to generate and edit images with Qwen-Image-2.1 in a few steps.**- Compress your own models with [Pruna](https://github.com/PrunaAI/pruna) and give us a βοΈ for more efficiency!- Want to use our optimized models right away? Try our[Performance Models](https://dashboard.pruna.ai/login?utm_source=huggingface&utm_medium=model_card&utm_campaign=hf_traffic).
README.md+129-35