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
Add v0.2 adapters
#9
by simlang - opened
- .gitattributes +6 -5
- README.md +223 -50
- assets/{Pruna-Q-Image-2.1.png β P-Q-Image-2.1-i2i-1024-end-to-end.png} +2 -2
- assets/{Pruna-Q-Image-2.1-i2i-1024.png β P-Q-Image-2.1-i2i-1024.png} +0 -0
- assets/{Pruna-Q-Image-2.1-i2i-2048.png β P-Q-Image-2.1-i2i-2048.png} +0 -0
- assets/P-Q-Image-2.1-prompt-upsampling.png +3 -0
- assets/P-Q-Image-2.1-t2i-1024-all.png +3 -0
- assets/P-Q-Image-2.1-t2i-1024-end-to-end.png +3 -0
- assets/{Pruna-Q-Image-2.1-t2i-1024.png β P-Q-Image-2.1-t2i-1024.png} +0 -0
- assets/{Pruna-Q-Image-2.1-t2i-2048.png β P-Q-Image-2.1-t2i-2048.png} +0 -0
- assets/P-Q-Image-2.1-v02-generation.png +3 -0
- assets/P-Q-Image-2.1.png +3 -0
- p_q_image_2.1_5step_v0.1.safetensors β p_q_image_2.1_5_steps_v0.1.safetensors +0 -0
- p_q_image_2.1_6_steps_upsampled_v0.2.safetensors +3 -0
- p_q_image_2.1_6_steps_v0.2.safetensors +3 -0
- p_q_image_2.1_8step_v0.1.safetensors β p_q_image_2.1_8_steps_v0.1.safetensors +0 -0
.gitattributes
CHANGED
|
@@ -36,8 +36,9 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 36 |
assets/latency_t2i_1k_2k.png filter=lfs diff=lfs merge=lfs -text
|
| 37 |
assets/download-1.png filter=lfs diff=lfs merge=lfs -text
|
| 38 |
assets/edit_grid.jpg filter=lfs diff=lfs merge=lfs -text
|
| 39 |
-
assets/
|
| 40 |
-
assets/
|
| 41 |
-
assets/
|
| 42 |
-
assets/
|
| 43 |
-
assets/
|
|
|
|
|
|
| 36 |
assets/latency_t2i_1k_2k.png filter=lfs diff=lfs merge=lfs -text
|
| 37 |
assets/download-1.png filter=lfs diff=lfs merge=lfs -text
|
| 38 |
assets/edit_grid.jpg filter=lfs diff=lfs merge=lfs -text
|
| 39 |
+
assets/P-Q-Image-2.1-i2i-1024.png filter=lfs diff=lfs merge=lfs -text
|
| 40 |
+
assets/P-Q-Image-2.1-i2i-2048.png filter=lfs diff=lfs merge=lfs -text
|
| 41 |
+
assets/P-Q-Image-2.1-t2i-1024.png filter=lfs diff=lfs merge=lfs -text
|
| 42 |
+
assets/P-Q-Image-2.1-t2i-2048.png filter=lfs diff=lfs merge=lfs -text
|
| 43 |
+
assets/P-Q-Image-2.1.png filter=lfs diff=lfs merge=lfs -text
|
| 44 |
+
assets/*.png filter=lfs diff=lfs merge=lfs -text
|
README.md
CHANGED
|
@@ -16,7 +16,7 @@ tags:
|
|
| 16 |
<!-- header start -->
|
| 17 |
<!-- 200823 -->
|
| 18 |
<p align="center">
|
| 19 |
-
<img src="assets/
|
| 20 |
</p>
|
| 21 |
<!-- header end -->
|
| 22 |
|
|
@@ -43,12 +43,12 @@ tags:
|
|
| 43 |
</p>
|
| 44 |
<div align="center">
|
| 45 |
|
| 46 |
-
<h1 style="color: #9334E9;">β‘
|
| 47 |
|
| 48 |
<h2>Few-step LoRA adapters for Qwen-Image-2.1</h2>
|
| 49 |
|
| 50 |
<h3>
|
| 51 |
-
<span style="color: #9334E9;">5 or 8 steps</span>
|
| 52 |
Β·
|
| 53 |
<span style="color: #9334E9;">Up to 6.3x faster</span>
|
| 54 |
Β·
|
|
@@ -59,29 +59,74 @@ tags:
|
|
| 59 |
|
| 60 |
</div>
|
| 61 |
|
| 62 |
-
**
|
| 63 |
[`Qwen/Qwen-Image-2.1`](https://huggingface.co/Qwen/Qwen-Image-2.1) generate
|
| 64 |
-
and edit images in only 5 or 8 steps. The adapters load on top of the base
|
| 65 |
-
model, so the pipeline, text encoder, and VAE stay unchanged.
|
| 66 |
-
on DMD. Improved using Qwen.**
|
| 67 |
|
| 68 |
-
> **v0.
|
| 69 |
-
>
|
| 70 |
-
>
|
|
|
|
|
|
|
| 71 |
|
| 72 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
|
| 74 |
Both adapters are v0.1. Pick one based on whether you need **quality** or **speed**.
|
| 75 |
|
| 76 |
-
| File | Steps | Trade-off |
|
| 77 |
-
|---|:---:|---|
|
| 78 |
-
| `p_q_image_2.
|
| 79 |
-
| `p_q_image_2.
|
| 80 |
|
| 81 |
Each adapter is trained for its own sigma schedule. Load only one at a time.
|
|
|
|
|
|
|
|
|
|
| 82 |
|
| 83 |
## Prompts, editing, and resolution
|
| 84 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 85 |
The adapters were trained at **1K resolution only**, with a mix of simple and
|
| 86 |
upsampled prompts, text-to-image generation, and single- and multi-image editing
|
| 87 |
with **up to 3 reference images**. Prompt upsampling is optional; detailed prompts
|
|
@@ -92,37 +137,6 @@ Higher resolutions (including 2K) and more reference images may work, but are
|
|
| 92 |
outside the training coverage, and quality may vary. The 2K timings below show
|
| 93 |
inference speed, not a guarantee of quality at that resolution.
|
| 94 |
|
| 95 |
-
## Benchmarking
|
| 96 |
-
|
| 97 |
-
Use a table; Hugging Face can otherwise render the `<img>` elements as separate blocks.
|
| 98 |
-
|
| 99 |
-
<table>
|
| 100 |
-
<tr>
|
| 101 |
-
<td width="50%">
|
| 102 |
-
<img src="assets/Pruna-Q-Image-2.1-t2i-1024.png" width="100%">
|
| 103 |
-
</td>
|
| 104 |
-
<td width="50%">
|
| 105 |
-
<img src="assets/Pruna-Q-Image-2.1-t2i-2048.png" width="100%">
|
| 106 |
-
</td>
|
| 107 |
-
</tr>
|
| 108 |
-
<tr>
|
| 109 |
-
<td width="50%">
|
| 110 |
-
<img src="assets/Pruna-Q-Image-2.1-i2i-1024.png" width="100%">
|
| 111 |
-
</td>
|
| 112 |
-
<td width="50%">
|
| 113 |
-
<img src="assets/Pruna-Q-Image-2.1-i2i-2048.png" width="100%">
|
| 114 |
-
</td>
|
| 115 |
-
</tr>
|
| 116 |
-
</table>
|
| 117 |
-
|
| 118 |
-
Text-to-image with the official Qwen model-card example prompt, BF16, batch size 1,
|
| 119 |
-
on one NVIDIA H100 80GB. Median of 3 requests after one warmup per configuration.
|
| 120 |
-
Includes prompt encoding, denoising, and decoding; excludes PNG saving, model
|
| 121 |
-
loading, and warmup. Base: 40 steps with KV cache on; Pruna-Q-Image-2.1: 5 or 8 steps with
|
| 122 |
-
KV cache off, as configured for this benchmark. The examples below enable KV caching for
|
| 123 |
-
Pruna-Q-Image-2.1; the chart has not been remeasured with that setting. LoRAs were unmerged;
|
| 124 |
-
no CFG, compilation, or CPU offload. These timings do not imply equal image quality.
|
| 125 |
-
|
| 126 |
## Quickstart
|
| 127 |
|
| 128 |
Runs text-to-image and image editing with the same pipeline. Needs a **CUDA GPU**.
|
|
@@ -132,6 +146,55 @@ pip install 'torch>=2.4.0' 'transformers>=5.17' accelerate peft pillow
|
|
| 132 |
pip install git+https://github.com/huggingface/diffusers@6256aa7666cedd47443adc8f82da9a10e110b09c
|
| 133 |
```
|
| 134 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 135 |
```python
|
| 136 |
import torch
|
| 137 |
from PIL import Image
|
|
@@ -149,8 +212,8 @@ pipe = QwenImage21Pipeline.from_pretrained(
|
|
| 149 |
"Qwen/Qwen-Image-2.1", torch_dtype=torch.bfloat16
|
| 150 |
).to("cuda")
|
| 151 |
pipe.load_lora_weights(
|
| 152 |
-
"PrunaAI/
|
| 153 |
-
weight_name=f"p_q_image_2.1_{STEPS}
|
| 154 |
)
|
| 155 |
|
| 156 |
# Use the sigmas exactly as given: no extra shifting.
|
|
@@ -162,6 +225,89 @@ pipe.scheduler = FlowMatchEulerDiscreteScheduler.from_config(
|
|
| 162 |
)
|
| 163 |
```
|
| 164 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 165 |
## For Text-to-Image
|
| 166 |
|
| 167 |
Longer, more descriptive prompts give better results.
|
|
@@ -199,6 +345,16 @@ image = pipe(
|
|
| 199 |
|
| 200 |
### Recommended settings
|
| 201 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 202 |
- **Use the sigma schedule that matches your adapter**, and keep the scheduler
|
| 203 |
at `shift=1.0` with dynamic shifting off so the sigmas are not shifted twice.
|
| 204 |
- 8-step: `1 β 14/15 β 6/7 β 10/13 β 2/3 β 6/11 β 0.4 β 2/9 β 0`
|
|
@@ -210,8 +366,23 @@ image = pipe(
|
|
| 210 |
the subject, setting, lighting, and style work noticeably better than short
|
| 211 |
ones.
|
| 212 |
|
|
|
|
|
|
|
| 213 |
## Limitations
|
| 214 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 215 |
- This is a first version. Quality is below that of the base model.
|
| 216 |
- The 5-step adapter is faster than the 8-step one, but its images are
|
| 217 |
visibly worse.
|
|
@@ -219,6 +390,8 @@ image = pipe(
|
|
| 219 |
- The adapters are only intended for the settings above. Other step counts,
|
| 220 |
schedules, or CFG values are not supported.
|
| 221 |
|
|
|
|
|
|
|
| 222 |
## What this is not
|
| 223 |
|
| 224 |
- Not a standalone model. It needs the `Qwen/Qwen-Image-2.1` base weights.
|
|
@@ -229,7 +402,7 @@ image = pipe(
|
|
| 229 |
|
| 230 |
The end distilled model is based on Qwen-Image-2.1.
|
| 231 |
|
| 232 |
-
|
| 233 |
under the **Qwen RESEARCH LICENSE AGREEMENT**. Review its use restrictions
|
| 234 |
before using or redistributing the adapters.
|
| 235 |
|
|
@@ -238,7 +411,7 @@ Hangzhou Tongyi Laboratory Technology Co., Ltd. All Rights Reserved.
|
|
| 238 |
|
| 239 |
## What's next?
|
| 240 |
|
| 241 |
-
- **Use
|
| 242 |
- Compress your own models with [Pruna](https://github.com/PrunaAI/pruna) and give us a βοΈ for more efficiency!
|
| 243 |
- 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).
|
| 244 |
|
|
|
|
| 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 |
|
|
|
|
| 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 |
Β·
|
|
|
|
| 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
|
|
|
|
| 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**.
|
|
|
|
| 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
|
|
|
|
| 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.
|
|
|
|
| 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.
|
|
|
|
| 345 |
|
| 346 |
### Recommended settings
|
| 347 |
|
| 348 |
+
- Use the unshifted six-step sigmas `[1.0, 0.925, 0.85, 0.625, 0.375, 0.125]` with dynamic shifting enabled
|
| 349 |
+
and `shift_terminal=None`, as shown in the v0.2 setup.
|
| 350 |
+
- The scheduler appends terminal zero.
|
| 351 |
+
- Keep `true_cfg_scale=1.0` and LoRA strength 1.0.
|
| 352 |
+
|
| 353 |
+
<details>
|
| 354 |
+
<summary><b>Recommended 5β8 step settings (v0.1)</b></summary>
|
| 355 |
+
|
| 356 |
+
### v0.1 settings
|
| 357 |
+
|
| 358 |
- **Use the sigma schedule that matches your adapter**, and keep the scheduler
|
| 359 |
at `shift=1.0` with dynamic shifting off so the sigmas are not shifted twice.
|
| 360 |
- 8-step: `1 β 14/15 β 6/7 β 10/13 β 2/3 β 6/11 β 0.4 β 2/9 β 0`
|
|
|
|
| 366 |
the subject, setting, lighting, and style work noticeably better than short
|
| 367 |
ones.
|
| 368 |
|
| 369 |
+
</details>
|
| 370 |
+
|
| 371 |
## Limitations
|
| 372 |
|
| 373 |
+
- The `6-steps-upsampled` adapter can improve visual quality without a separate
|
| 374 |
+
prompt-upsampling call, but may not exactly reproduce the output of the actual
|
| 375 |
+
prompt upsampler.
|
| 376 |
+
- `6-steps` is intended to preserve the base model's behavior in fewer steps;
|
| 377 |
+
distillation does not guarantee identical outputs.
|
| 378 |
+
- Use the step count and sigma schedule that match your v0.2 adapter. Other step
|
| 379 |
+
counts, schedules, or CFG values are not supported.
|
| 380 |
+
|
| 381 |
+
<details>
|
| 382 |
+
<summary><b>Known limits of the 5β8 step adapters (v0.1)</b></summary>
|
| 383 |
+
|
| 384 |
+
### v0.1
|
| 385 |
+
|
| 386 |
- This is a first version. Quality is below that of the base model.
|
| 387 |
- The 5-step adapter is faster than the 8-step one, but its images are
|
| 388 |
visibly worse.
|
|
|
|
| 390 |
- The adapters are only intended for the settings above. Other step counts,
|
| 391 |
schedules, or CFG values are not supported.
|
| 392 |
|
| 393 |
+
</details>
|
| 394 |
+
|
| 395 |
## What this is not
|
| 396 |
|
| 397 |
- Not a standalone model. It needs the `Qwen/Qwen-Image-2.1` base weights.
|
|
|
|
| 402 |
|
| 403 |
The end distilled model is based on Qwen-Image-2.1.
|
| 404 |
|
| 405 |
+
P-Q-Image-2.1 is a derivative of Qwen-Image-2.1 and is distributed
|
| 406 |
under the **Qwen RESEARCH LICENSE AGREEMENT**. Review its use restrictions
|
| 407 |
before using or redistributing the adapters.
|
| 408 |
|
|
|
|
| 411 |
|
| 412 |
## What's next?
|
| 413 |
|
| 414 |
+
- **Use P-Q-Image-2.1 to generate and edit images with Qwen-Image-2.1 in a few steps.**
|
| 415 |
- Compress your own models with [Pruna](https://github.com/PrunaAI/pruna) and give us a βοΈ for more efficiency!
|
| 416 |
- 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).
|
| 417 |
|
assets/{Pruna-Q-Image-2.1.png β P-Q-Image-2.1-i2i-1024-end-to-end.png}
RENAMED
|
File without changes
|
assets/{Pruna-Q-Image-2.1-i2i-1024.png β P-Q-Image-2.1-i2i-1024.png}
RENAMED
|
File without changes
|
assets/{Pruna-Q-Image-2.1-i2i-2048.png β P-Q-Image-2.1-i2i-2048.png}
RENAMED
|
File without changes
|
assets/P-Q-Image-2.1-prompt-upsampling.png
ADDED
|
Git LFS Details
|
assets/P-Q-Image-2.1-t2i-1024-all.png
ADDED
|
Git LFS Details
|
assets/P-Q-Image-2.1-t2i-1024-end-to-end.png
ADDED
|
Git LFS Details
|
assets/{Pruna-Q-Image-2.1-t2i-1024.png β P-Q-Image-2.1-t2i-1024.png}
RENAMED
|
File without changes
|
assets/{Pruna-Q-Image-2.1-t2i-2048.png β P-Q-Image-2.1-t2i-2048.png}
RENAMED
|
File without changes
|
assets/P-Q-Image-2.1-v02-generation.png
ADDED
|
Git LFS Details
|
assets/P-Q-Image-2.1.png
ADDED
|
Git LFS Details
|
p_q_image_2.1_5step_v0.1.safetensors β p_q_image_2.1_5_steps_v0.1.safetensors
RENAMED
|
File without changes
|
p_q_image_2.1_6_steps_upsampled_v0.2.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:3c86e69c1242625923d1454ba01ea6cef900f80ee891c5fa245173ed4abac9c2
|
| 3 |
+
size 688027008
|
p_q_image_2.1_6_steps_v0.2.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d10a0ab365df3829d460be9196f6a8a7d0e8f5498f5a3f25d924b8f9ee8c94bb
|
| 3 |
+
size 688027008
|
p_q_image_2.1_8step_v0.1.safetensors β p_q_image_2.1_8_steps_v0.1.safetensors
RENAMED
|
File without changes
|