README.md
| 1 | --- |
| 2 | license: other |
| 3 | license_name: qwen-research |
| 4 | base_model: Qwen/Qwen-Image-2.1 |
| 5 | library_name: diffusers |
| 6 | pipeline_tag: text-to-image |
| 7 | tags: |
| 8 | - qwen |
| 9 | - image-generation |
| 10 | - image-editing |
| 11 | - rgba |
| 12 | - lora |
| 13 | - distilled |
| 14 | - few-step |
| 15 | --- |
| 16 | <!-- header start --> |
| 17 | <!-- 200823 --> |
| 18 | <p align="center"> |
| 19 | <img src="assets/P-Q-Image-2.1.png" width="800"> |
| 20 | </p> |
| 21 | <!-- header end --> |
| 22 | |
| 23 | <p align="center"> |
| 24 | <a href="https://github.com/PrunaAI/pruna"> |
| 25 | <img src="https://img.shields.io/badge/GitHub-PrunaAI-9334E9?style=plastic&logo=github&logoColor=white" alt="GitHub"> |
| 26 | </a> |
| 27 | |
| 28 | <a href="https://twitter.com/PrunaAI"> |
| 29 | <img src="https://img.shields.io/badge/Twitter%2FX-@PrunaAI-9334E9?style=plastic&logo=x&logoColor=white" alt="Twitter/X"> |
| 30 | </a> |
| 31 | |
| 32 | <a href="https://www.linkedin.com/company/pruna-ai"> |
| 33 | <img src="https://img.shields.io/badge/LinkedIn-PrunaAI-9334E9?style=plastic&logo=linkedin&logoColor=white" alt="LinkedIn"> |
| 34 | </a> |
| 35 | |
| 36 | <a href="https://discord.com/invite/JFQmtFKCjd"> |
| 37 | <img src="https://img.shields.io/badge/Discord-Join%20us-9334E9?style=plastic&logo=discord&logoColor=white" alt="Discord"> |
| 38 | </a> |
| 39 | |
| 40 | <a href="https://dashboard.pruna.ai/login?utm_source=huggingface&utm_medium=org_card&utm_campaign=hf_traffic"> |
| 41 | <img src="https://img.shields.io/badge/Performance%20Models-Try%20them%20now-9334E9?style=plastic&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI0MTEiIGhlaWdodD0iNDc3IiBmaWxsPSJub25lIj48cGF0aC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HRoPSI5LjIwMyIvPjxwYXRoIGZpbGw9IiNmZmYiIGQ9Ik0yNzYuODM0IDI0Mi4wOTJjMTUuNjcyIDAgMjguMzc2IDEzLjk2MyAyOC4zNzYgMzEuMTg4cy0xMi43MDQgMzEuMTg5LTI4LjM3NiAzMS4xODktMjguMzc3LTEzLjk2NC0yOC4zNzctMzEuMTg5YzAtMi42MjUuMjk3LTUuMTc0Ljg1My03LjYxIDEuNjA2IDMuNzI3IDUuMzEyIDYuMzM4IDkuNjI4IDYuMzM4IDUuNzg5IDAgMTAuNDgyLTQuNjkzIDEwLjQ4Mi0xMC40ODJzLTQuNjkzLTEwLjQ4MS0xMC40ODItMTAuNDgxYy0uNzYxIDAtMS41MDQuMDgzLTIuMjE5LjIzNyA1LjEzOS01LjY3NiAxMi4yNTQtOS4xOSAyMC4xMTUtOS4xOSIvPjxwYXRoIHN0cm9rZT0iI2ZmZiIgc3Ryb2tlLXdpZHRoPSI5LjIwMyIgZD0iTTE3Ny4xMzUgMzQ1LjMyOGMuODk5LS4yNCAyLjgwMS0uMTk3IDYuMzA0LjQ2NCA2LjMxMSAxLjE5IDE2LjU4NSA0LjIyMSAyNi4xMjIgNC4yMjEgOS40NTIgMCAxNy4xMTgtMS45MjYgMjEuMzgzLTIuNjAzLjc3LS4xMjMgMS4zODUtLjE5OSAxLjg3OC0uMjM3LS4zNCAxMy44NDMtMTIuODkzIDI3LjcxLTI3Ljg2OCAyNy43MS0xNS4xNzIgMC0yNy44NzYtMTMuODM1LTI3Ljg3Ni0yOC44MTEgMC0uMzU3LjAyOS0uNTk2LjA1Ny0uNzQ0WiIvPjwvc3ZnPg==" alt="Performance Models"> |
| 42 | </a> |
| 43 | </p> |
| 44 | <div align="center"> |
| 45 | |
| 46 | <h1 style="color: #9334E9;">⚡ P-Q-Image-2.1</h1> |
| 47 | |
| 48 | <h2>Few-step LoRA adapters for Qwen-Image-2.1</h2> |
| 49 | |
| 50 | <h3> |
| 51 | <span style="color: #9334E9;">6 steps (v0.2), 5 or 8 steps (v0.1)</span> |
| 52 | · |
| 53 | <span style="color: #9334E9;">Up to 6.3x faster</span> |
| 54 | · |
| 55 | <span style="color: #9334E9;">No CFG</span> |
| 56 | · |
| 57 | Text-to-image and image editing |
| 58 | </h3> |
| 59 | |
| 60 | </div> |
| 61 | |
| 62 | **P-Q-Image-2.1** is a set of LoRA adapters that let |
| 63 | [`Qwen/Qwen-Image-2.1`](https://huggingface.co/Qwen/Qwen-Image-2.1) generate |
| 64 | and edit images in only 6 steps (v0.2), or 5 or 8 steps (v0.1). The adapters load on top of the base |
| 65 | model, so the pipeline, text encoder, and VAE stay unchanged. |
| 66 | |
| 67 | > **v0.2: two new 6-step adapters.** |
| 68 | > |
| 69 | > - An advanced distillation for more faithful generation and editing. |
| 70 | > - The first distillation removing need for prompt upsampling into the LoRA, thus significantly reducing end-to-end generation. |
| 71 | > The v0.1 adapters remain available. |
| 72 | |
| 73 | <table> |
| 74 | <tr> |
| 75 | <td width="50%"> |
| 76 | <img src="assets/P-Q-Image-2.1-t2i-1024-end-to-end.png" alt="Estimated end-to-end text-to-image latency at 1024 × 1024" width="100%"> |
| 77 | </td> |
| 78 | <td width="50%"> |
| 79 | <img src="assets/P-Q-Image-2.1-i2i-1024-end-to-end.png" alt="Estimated end-to-end editing latency at 1024 × 1024 with one input image" width="100%"> |
| 80 | </td> |
| 81 | </tr> |
| 82 | </table> |
| 83 | |
| 84 | ## 6-step variants |
| 85 | |
| 86 | Pick **6-steps** for faithful base-model behavior, or **6-steps-upsampled** for |
| 87 | improved visual quality from a short prompt, without a separate prompt-upsampling call. |
| 88 | |
| 89 | | Variant | File | Steps | Trade-off | |
| 90 | |---|---|:---:|---| |
| 91 | | `6-steps` | `p_q_image_2.1_6_steps_v0.2.safetensors` | 6 | **Advanced distillation.** Recommended for preserving inputs when editing. | |
| 92 | | `6-steps-upsampled` | `p_q_image_2.1_6_steps_upsampled_v0.2.safetensors` | 6 | **Improved visual quality, shorter end-to-end generation.** The first distillation that removes the need for a separate prompt-upsampling step. | |
| 93 | |
| 94 | **6-steps** is an advanced 6-step distillation of the base model. It is intended |
| 95 | as a drop-in replacement for the base model in existing generation and editing |
| 96 | workflows, using the adapter's step count and sigma schedule. It improves on the |
| 97 | v0.1 adapters in almost all categories and is particularly good at editing tasks |
| 98 | where preserving the input matters. |
| 99 | |
| 100 | **6-steps-upsampled** distills the prompt upsampler recommended for |
| 101 | Qwen-Image-2.1 into a 6-step LoRA. It improves visual quality without a separate |
| 102 | prompt-upsampling call, which significantly reduces end-to-end generation time. |
| 103 | It may not reproduce exactly what the actual prompt upsampler would do, and we |
| 104 | will continue improving it. |
| 105 | |
| 106 | <details> |
| 107 | <summary><b>See the 5-step vs 8-step adapters (v0.1)</b></summary> |
| 108 | |
| 109 | ### v0.1 |
| 110 | |
| 111 | Both adapters are v0.1. Pick one based on whether you need **quality** or **speed**. |
| 112 | |
| 113 | | Variant | File | Steps | Trade-off | |
| 114 | |---|---|:---:|---| |
| 115 | | `8-steps` | `p_q_image_2.1_8_steps_v0.1.safetensors` | 8 | **Higher quality.** Recommended as the default. | |
| 116 | | `5-steps` | `p_q_image_2.1_5_steps_v0.1.safetensors` | 5 | **Higher speed**, with noticeably lower visual quality. | |
| 117 | |
| 118 | Each adapter is trained for its own sigma schedule. Load only one at a time. |
| 119 | For the v0.2 adapters, do not reuse the v0.1 schedules. |
| 120 | |
| 121 | </details> |
| 122 | |
| 123 | ## Prompts, editing, and resolution |
| 124 | |
| 125 | For **6-steps**, use the same prompts and reference images you would use with the |
| 126 | base model. For **6-steps-upsampled**, start with your original prompt; the adapter |
| 127 | is intended to capture the benefit of prompt upsampling during generation. |
| 128 | Detailed prompts still let you specify the subject, setting, lighting, and style. |
| 129 | |
| 130 | The adapters were trained at **1K resolution only**, with a mix of simple and |
| 131 | upsampled prompts, text-to-image generation, and single- and multi-image editing |
| 132 | with **up to 3 reference images**. Prompt upsampling is optional; detailed prompts |
| 133 | usually give better results. |
| 134 | |
| 135 | Start at **1024 × 1024** and use at most **3 reference images** for editing. |
| 136 | Higher resolutions (including 2K) and more reference images may work, but are |
| 137 | outside the training coverage, and quality may vary. The 2K timings below show |
| 138 | inference speed, not a guarantee of quality at that resolution. |
| 139 | |
| 140 | ## Quickstart |
| 141 | |
| 142 | Runs text-to-image and image editing with the same pipeline. Needs a **CUDA GPU**. |
| 143 | |
| 144 | ```bash |
| 145 | pip install 'torch>=2.4.0' 'transformers>=5.17' accelerate peft pillow |
| 146 | pip install git+https://github.com/huggingface/diffusers@6256aa7666cedd47443adc8f82da9a10e110b09c |
| 147 | ``` |
| 148 | |
| 149 | Use this setup for either v0.2 adapter. |
| 150 | |
| 151 | ```python |
| 152 | import torch |
| 153 | from PIL import Image |
| 154 | from diffusers import FlowMatchEulerDiscreteScheduler, QwenImage21Pipeline |
| 155 | |
| 156 | # Both v0.2 adapters use this unshifted six-step schedule. |
| 157 | # The scheduler applies the resolution-dependent shift and appends sigma 0. |
| 158 | STEPS = 6 |
| 159 | VARIANT = "6-steps" # "6-steps" or "6-steps-upsampled" |
| 160 | WEIGHT_NAME = { |
| 161 | "6-steps": "p_q_image_2.1_6_steps_v0.2.safetensors", |
| 162 | "6-steps-upsampled": "p_q_image_2.1_6_steps_upsampled_v0.2.safetensors", |
| 163 | }[VARIANT] |
| 164 | SIGMAS = [1.0, 0.925, 0.85, 0.625, 0.375, 0.125] |
| 165 | |
| 166 | pipe = QwenImage21Pipeline.from_pretrained( |
| 167 | "Qwen/Qwen-Image-2.1", torch_dtype=torch.bfloat16 |
| 168 | ).to("cuda") |
| 169 | pipe.load_lora_weights( |
| 170 | "PrunaAI/P-Q-Image-2.1", |
| 171 | weight_name=WEIGHT_NAME, |
| 172 | ) |
| 173 | |
| 174 | # Shift the raw sigmas using the base model's resolution-dependent settings. |
| 175 | pipe.scheduler = FlowMatchEulerDiscreteScheduler.from_config( |
| 176 | pipe.scheduler.config, |
| 177 | use_dynamic_shifting=True, |
| 178 | shift_terminal=None, |
| 179 | ) |
| 180 | ``` |
| 181 | |
| 182 | Both variants load on **`Qwen/Qwen-Image-2.1`** using **`QwenImage21Pipeline`**. |
| 183 | Choose one LoRA with `VARIANT`; the `6-steps-upsampled` variant runs directly on your |
| 184 | original prompt without a separate prompt-enhancer model. For a local export, |
| 185 | replace `"PrunaAI/P-Q-Image-2.1"` with the folder containing the chosen |
| 186 | safetensors file and keep `weight_name=WEIGHT_NAME`. |
| 187 | |
| 188 | Both files have **rank 64** across **232 linear targets**, including `proj_out`. |
| 189 | Training used alpha 128; the exported B matrices include the `128 / 64 = 2` |
| 190 | scale. Load at **LoRA strength 1.0** with the standard pipeline loader. |
| 191 | |
| 192 | |
| 193 | <details> |
| 194 | <summary><b>Check more info for the 5–8 step setup (v0.1)</b></summary> |
| 195 | |
| 196 | ### v0.1 |
| 197 | |
| 198 | ```python |
| 199 | import torch |
| 200 | from PIL import Image |
| 201 | from diffusers import FlowMatchEulerDiscreteScheduler, QwenImage21Pipeline |
| 202 | |
| 203 | STEPS = 8 # 8 for higher quality, 5 for higher speed |
| 204 | |
| 205 | # The terminal sigma 0 is appended by the scheduler. |
| 206 | SIGMAS = { |
| 207 | 5: [1.0, 0.94, 6 / 7, 2 / 3, 0.4], |
| 208 | 8: [1.0, 14 / 15, 6 / 7, 10 / 13, 2 / 3, 6 / 11, 0.4, 2 / 9], |
| 209 | }[STEPS] |
| 210 | |
| 211 | pipe = QwenImage21Pipeline.from_pretrained( |
| 212 | "Qwen/Qwen-Image-2.1", torch_dtype=torch.bfloat16 |
| 213 | ).to("cuda") |
| 214 | pipe.load_lora_weights( |
| 215 | "PrunaAI/P-Q-Image-2.1", |
| 216 | weight_name=f"p_q_image_2.1_{STEPS}_steps_v0.1.safetensors", |
| 217 | ) |
| 218 | |
| 219 | # Use the sigmas exactly as given: no extra shifting. |
| 220 | pipe.scheduler = FlowMatchEulerDiscreteScheduler.from_config( |
| 221 | pipe.scheduler.config, |
| 222 | use_dynamic_shifting=False, |
| 223 | shift=1.0, |
| 224 | shift_terminal=None, |
| 225 | ) |
| 226 | ``` |
| 227 | |
| 228 | </details> |
| 229 | |
| 230 | ## Benchmarking |
| 231 | |
| 232 | |
| 233 | <table> |
| 234 | <tr> |
| 235 | <td> |
| 236 | <img src="assets/P-Q-Image-2.1-v02-generation.png" alt="Six-step generation latency at 1024 and 2048 pixels" width="100%"> |
| 237 | </td> |
| 238 | </tr> |
| 239 | <tr> |
| 240 | <td> |
| 241 | <img src="assets/P-Q-Image-2.1-prompt-upsampling.png" alt="Prompt-upsampling latency for text and one to three reference images" width="100%"> |
| 242 | </td> |
| 243 | </tr> |
| 244 | </table> |
| 245 | |
| 246 | One NVIDIA H100 80GB, BF16, batch size 1. v0.2 generation timings |
| 247 | report the median of six measured requests pooled across both adapters (three |
| 248 | per adapter), excluding one warmup per adapter and case. |
| 249 | Generation includes prompt encoding, reference-image processing, denoising, and |
| 250 | VAE decode. It excludes loading, warmup, fixture prep, saving, and network. |
| 251 | No CFG, compilation, or CPU offload. **Diffusion KV caching is enabled**, except |
| 252 | for the case marked with an asterisk below. |
| 253 | |
| 254 | \* **2048 × 2048 editing with 3 input images:** KV caching was disabled due to |
| 255 | memory constraints on the H100 80GB. The 2048 multi-image cases use expandable |
| 256 | CUDA memory segments (`PYTORCH_ALLOC_CONF=expandable_segments:True`). |
| 257 | |
| 258 | Prompt upsampling is timed separately with |
| 259 | [`Qwen-Image-2.1-PE-T2I`](https://huggingface.co/Qwen/Qwen-Image-2.1-PE-T2I) |
| 260 | and [`Qwen-Image-2.1-PE-I2I`](https://huggingface.co/Qwen/Qwen-Image-2.1-PE-I2I). |
| 261 | It covers request prep through parsed text, not image generation. vLLM runs |
| 262 | eager, without prefix or image-processor caching, and with a fresh image ID so |
| 263 | vision encoding is always counted. Autoregressive KV cache stays on. |
| 264 | |
| 265 | Text-to-image uses a fixed neon-sign prompt. Editing uses a fixed |
| 266 | prompt and 1–3 reference images, square-cropped and resized. These cases are |
| 267 | not matched to the v0.1 charts, and adding the two medians is not an |
| 268 | end-to-end time. |
| 269 | |
| 270 | Generation: PyTorch 2.11.0, CUDA 12.8, Transformers 5.20.1, PEFT 0.21.2, |
| 271 | Diffusers `6256aa7666cedd47443adc8f82da9a10e110b09c`. Upsampling: vLLM 0.19.1, |
| 272 | PyTorch 2.10.0, Transformers 5.19.0. The v0.1 charts were not rerun here. |
| 273 | Both enhancers use thinking with |
| 274 | `temperature=1.0`, `top_p=0.95`, `top_k=20`, `min_p=0.0`. Text-to-image: |
| 275 | `presence_penalty=1.5`, 16,256-token cap. Editing: `presence_penalty=0.0`, |
| 276 | 24,000-token cap. Reported only if all three rewrites complete and parse. |
| 277 | |
| 278 | <details> |
| 279 | <summary><b>Check more info for the 5–8 step benchmarks (v0.1)</b></summary> |
| 280 | |
| 281 | ### v0.1 |
| 282 | |
| 283 | <table> |
| 284 | <tr> |
| 285 | <td width="50%"> |
| 286 | <img src="assets/P-Q-Image-2.1-t2i-1024.png" width="100%"> |
| 287 | </td> |
| 288 | <td width="50%"> |
| 289 | <img src="assets/P-Q-Image-2.1-t2i-2048.png" width="100%"> |
| 290 | </td> |
| 291 | </tr> |
| 292 | <tr> |
| 293 | <td width="50%"> |
| 294 | <img src="assets/P-Q-Image-2.1-i2i-1024.png" width="100%"> |
| 295 | </td> |
| 296 | <td width="50%"> |
| 297 | <img src="assets/P-Q-Image-2.1-i2i-2048.png" width="100%"> |
| 298 | </td> |
| 299 | </tr> |
| 300 | </table> |
| 301 | |
| 302 | Text-to-image with the official Qwen model-card example prompt, BF16, batch size 1, |
| 303 | on one NVIDIA H100 80GB. Median of 3 requests after one warmup per configuration. |
| 304 | Includes prompt encoding, denoising, and decoding; excludes PNG saving, model |
| 305 | loading, and warmup. Base: 40 steps with KV cache on; P-Q-Image-2.1: 5 or 8 steps with |
| 306 | KV cache off, as configured for this benchmark. The examples below enable KV caching for |
| 307 | P-Q-Image-2.1; the chart has not been remeasured with that setting. LoRAs were unmerged; |
| 308 | no CFG, compilation, or CPU offload. These timings do not imply equal image quality. |
| 309 | |
| 310 | |
| 311 | ## For Text-to-Image |
| 312 | |
| 313 | Longer, more descriptive prompts give better results. |
| 314 | |
| 315 | ```python |
| 316 | image = pipe( |
| 317 | prompt=( |
| 318 | 'A glowing neon shop sign that reads "QWEN IMAGE 2.1", mounted on a brick wall ' |
| 319 | "in a narrow city alley at night. Heavy rain, wet pavement reflecting pink and " |
| 320 | "blue light, shallow depth of field, cinematic photograph." |
| 321 | ), |
| 322 | width=1024, |
| 323 | height=1024, |
| 324 | generator=torch.Generator("cuda").manual_seed(42), |
| 325 | num_inference_steps=STEPS, |
| 326 | sigmas=SIGMAS, |
| 327 | true_cfg_scale=1.0, |
| 328 | use_kv_cache=True, |
| 329 | ).images[0] |
| 330 | ``` |
| 331 | |
| 332 | ### For Image Editing |
| 333 | |
| 334 | ```python |
| 335 | image = pipe( |
| 336 | prompt="Change the background to a sunset beach", |
| 337 | image=Image.open("input.png").convert("RGB"), |
| 338 | generator=torch.Generator("cuda").manual_seed(42), |
| 339 | num_inference_steps=STEPS, |
| 340 | sigmas=SIGMAS, |
| 341 | true_cfg_scale=1.0, |
| 342 | use_kv_cache=True, |
| 343 | ).images[0] |
| 344 | ``` |
| 345 | |
| 346 | </details> |
| 347 | |
| 348 | ### Recommended settings |
| 349 | |
| 350 | - Use the unshifted six-step sigmas `[1.0, 0.925, 0.85, 0.625, 0.375, 0.125]` with dynamic shifting enabled |
| 351 | and `shift_terminal=None`, as shown in the v0.2 setup. |
| 352 | - The scheduler appends terminal zero. |
| 353 | - Keep `true_cfg_scale=1.0` and LoRA strength 1.0. |
| 354 | |
| 355 | <details> |
| 356 | <summary><b>Recommended 5–8 step settings (v0.1)</b></summary> |
| 357 | |
| 358 | ### v0.1 settings |
| 359 | |
| 360 | - **Use the sigma schedule that matches your adapter**, and keep the scheduler |
| 361 | at `shift=1.0` with dynamic shifting off so the sigmas are not shifted twice. |
| 362 | - 8-step: `1 → 14/15 → 6/7 → 10/13 → 2/3 → 6/11 → 0.4 → 2/9 → 0` |
| 363 | (shift 2, computed as `σ = 2t / (1 + t)` on evenly spaced `t`) |
| 364 | - 5-step: `1 → 0.94 → 6/7 → 2/3 → 0.4 → 0` |
| 365 | - **No CFG.** Keep `true_cfg_scale=1.0` and do not pass a negative prompt. |
| 366 | - **Keep the LoRA strength at 1.0.** |
| 367 | - **Write detailed prompts for text-to-image.** Longer prompts that describe |
| 368 | the subject, setting, lighting, and style work noticeably better than short |
| 369 | ones. |
| 370 | |
| 371 | </details> |
| 372 | |
| 373 | ## Limitations |
| 374 | |
| 375 | - The `6-steps-upsampled` adapter can improve visual quality without a separate |
| 376 | prompt-upsampling call, but may not exactly reproduce the output of the actual |
| 377 | prompt upsampler. |
| 378 | - `6-steps` is intended to preserve the base model's behavior in fewer steps; |
| 379 | distillation does not guarantee identical outputs. |
| 380 | - Use the step count and sigma schedule that match your v0.2 adapter. Other step |
| 381 | counts, schedules, or CFG values are not supported. |
| 382 | |
| 383 | <details> |
| 384 | <summary><b>Known limits of the 5–8 step adapters (v0.1)</b></summary> |
| 385 | |
| 386 | ### v0.1 |
| 387 | |
| 388 | - This is a first version. Quality is below that of the base model. |
| 389 | - The 5-step adapter is faster than the 8-step one, but its images are |
| 390 | visibly worse. |
| 391 | - Short or vague text-to-image prompts give weaker results. |
| 392 | - The adapters are only intended for the settings above. Other step counts, |
| 393 | schedules, or CFG values are not supported. |
| 394 | |
| 395 | </details> |
| 396 | |
| 397 | ## What this is not |
| 398 | |
| 399 | - Not a standalone model. It needs the `Qwen/Qwen-Image-2.1` base weights. |
| 400 | - Not a replacement for the base model when you need its full quality. |
| 401 | - Not a finished release. Expect the weights to change in future versions. |
| 402 | |
| 403 | ## License |
| 404 | |
| 405 | The end distilled model is based on Qwen-Image-2.1. |
| 406 | |
| 407 | P-Q-Image-2.1 is a derivative of Qwen-Image-2.1 and is distributed |
| 408 | under the **Qwen RESEARCH LICENSE AGREEMENT**. Review its use restrictions |
| 409 | before using or redistributing the adapters. |
| 410 | |
| 411 | Qwen is licensed under the Qwen RESEARCH LICENSE AGREEMENT, Copyright (c) 2026 |
| 412 | Hangzhou Tongyi Laboratory Technology Co., Ltd. All Rights Reserved. |
| 413 | |
| 414 | ## What's next? |
| 415 | |
| 416 | - **Use P-Q-Image-2.1 to generate and edit images with Qwen-Image-2.1 in a few steps.** |
| 417 | - Compress your own models with [Pruna](https://github.com/PrunaAI/pruna) and give us a ⭐️ for more efficiency! |
| 418 | - Want to use our optimized image models right away? Check [P-Image-Ideogram](https://www.pruna.ai/p-image-ideogram) and [P-Image-Edit](https://www.pruna.ai/p-image-edit). |
| 419 | |
| 420 | <style> |
| 421 | .model-button { |
| 422 | display: inline-flex; |
| 423 | flex-direction: row; |
| 424 | justify-content: center; |
| 425 | align-items: center; |
| 426 | gap: 8px; |
| 427 | |
| 428 | padding: 8px 20px; |
| 429 | border: none; |
| 430 | border-radius: 8px; |
| 431 | |
| 432 | background: #9334e9; |
| 433 | color: #ffffff; |
| 434 | |
| 435 | font-size: 14px; |
| 436 | font-weight: 400; |
| 437 | line-height: 1; |
| 438 | text-decoration: none; |
| 439 | white-space: nowrap; |
| 440 | cursor: pointer; |
| 441 | |
| 442 | box-sizing: border-box; |
| 443 | overflow: visible; |
| 444 | opacity: 1; |
| 445 | } |
| 446 | </style> |
| 447 | |
| 448 | <a href="https://dashboard.pruna.ai/login?utm_source=huggingface&utm_medium=model_card&utm_campaign=hf_traffic" class="model-button">Try our models</a> |