Image-to-Image
Diffusers
Pruna AI
qwen
qwen-image
image-editing
object-removal
inpainting
lora
distilled
few-step
Instructions to use PrunaAI/P-Q-Image-2.1-Remove-Object 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-Remove-Object with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline from diffusers.utils import load_image # 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-Remove-Object") prompt = "Turn this cat into a dog" input_image = load_image("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/cat.png") image = pipe(image=input_image, prompt=prompt).images[0] - Pruna AI
How to use PrunaAI/P-Q-Image-2.1-Remove-Object with Pruna AI:
from pruna import PrunaModel pip install -U diffusers transformers accelerate
from pruna import PrunaModel import torch from diffusers.utils import load_image # switch to "mps" for apple devices pipe = PrunaModel.from_pretrained("Qwen/Qwen-Image-2.1", dtype=torch.bfloat16, device_map="cuda") pipe.load_lora_weights("PrunaAI/P-Q-Image-2.1-Remove-Object") prompt = "Turn this cat into a dog" input_image = load_image("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/cat.png") image = pipe(image=input_image, prompt=prompt).images[0] - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- Draw Things
File size: 29,404 Bytes
fa5b4fe | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 | ---
license: other
license_name: qwen-research
license_link: https://huggingface.co/Qwen/Qwen-Image-2.1/blob/main/LICENSE
base_model: Qwen/Qwen-Image-2.1
library_name: diffusers
pipeline_tag: image-to-image
tags:
- qwen
- qwen-image
- image-editing
- object-removal
- inpainting
- lora
- distilled
- few-step
- pruna-ai
---
<!-- header start -->
<p align="center">
<img src="assets/P-Q-Image-2.1-Remove-Object.png" width="800">
</p>
<!-- header end -->
<p align="center">
<a href="https://github.com/PrunaAI/pruna">
<img src="https://img.shields.io/badge/GitHub-PrunaAI-9334E9?style=plastic&logo=github&logoColor=white" alt="GitHub">
</a>
<a href="https://twitter.com/PrunaAI">
<img src="https://img.shields.io/badge/Twitter%2FX-@PrunaAI-9334E9?style=plastic&logo=x&logoColor=white" alt="Twitter/X">
</a>
<a href="https://www.linkedin.com/company/pruna-ai">
<img src="https://img.shields.io/badge/LinkedIn-PrunaAI-9334E9?style=plastic&logo=linkedin&logoColor=white" alt="LinkedIn">
</a>
<a href="https://discord.com/invite/JFQmtFKCjd">
<img src="https://img.shields.io/badge/Discord-Join%20us-9334E9?style=plastic&logo=discord&logoColor=white" alt="Discord">
</a>
<a href="https://dashboard.pruna.ai/login?utm_source=huggingface&utm_medium=org_card&utm_campaign=hf_traffic">
<img src="https://img.shields.io/badge/Performance%20Models-Try%20them%20now-9334E9?style=plastic&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI0MTEiIGhlaWdodD0iNDc3IiBmaWxsPSJub25lIj48cGF0aCBmaWxsPSIjZmZmIiBkPSJNMjMuNzAzIDMwMC41MzJjLTEuODQyLS42NzQtNC4xNDItMS4wNTctNS43MDMtMi4wMjktMTIuNTU4LTcuODQ2LTguODM3LTI1LjE3MiA1LjI1NS0yOC4zNjFhLjY2LjY2IDAgMCAwIC4zNDgtLjIwMS42LjYgMCAwIDAgLjE1Ni0uMzZxNi40OS04MS45ODYgNjguNTc3LTEzNC42MjlhLjM0LjM0IDAgMCAwIC4wOTItLjEyNS4zMy4zMyAwIDAgMC0uMDI2LS4zLjMzLjMzIDAgMCAwLS4xMTItLjEwOGMtNC4xMTUtMi40OTctOC42NC00Ljc1LTEyLjM1My03LjQ0M2ExOTAgMTkwIDAgMCAxLTE4Ljc5NC0xNS41MjJjLTIuOTM2LTIuNzY4LTMuNzAzLTUuODkxLjU4LTcuNzdhLjUuNSAwIDAgMCAuMjgtLjYwOEM1MyA3NS45NSA0OC40MTcgNDguNTk5IDQ1LjUxOCAxOS42NXEtLjM5My0zLjg1Mi0uMjcxLTYuMzJhLjc1Ljc1IDAgMCAxIC4xMzQtLjQuNy43IDAgMCAxIC4zMjQtLjI1NXEyLjEwNC0u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yMSAyNi4xMjIgNC4yMjEgOS40NTIgMCAxNy4xMTgtMS45MjYgMjEuMzgzLTIuNjAzLjc3LS4xMjMgMS4zODUtLjE5OSAxLjg3OC0uMjM3LS4zNCAxMy44NDMtMTIuODkzIDI3LjcxLTI3Ljg2OCAyNy43MS0xNS4xNzIgMC0yNy44NzYtMTMuODM1LTI3Ljg3Ni0yOC44MTEgMC0uMzU3LjAyOS0uNTk2LjA1Ny0uNzQ0WiIvPjwvc3ZnPg==" alt="Performance Models">
</a>
</p>
<div align="center">
<h1 style="color: #9334E9;">⚡ P-Q-Image-2.1-Remove-Object</h1>
<h2>Object removal LoRAs for Qwen-Image-2.1 that leave the rest of the image untouched</h2>
<h3>
<span style="color: #9334E9;">6 or 8 steps</span>
·
<span style="color: #9334E9;">No CFG</span>
·
<span style="color: #9334E9;">Rough masks</span>
·
Shadows and reflections go too
</h3>
</div>
**P-Q-Image-2.1-Remove-Object** is a set of LoRA adapters for
[`Qwen/Qwen-Image-2.1`](https://huggingface.co/Qwen/Qwen-Image-2.1) that **remove the object you point
at, and change nothing else**. Mark the object with a rough mask, drawn as a red outline on the photo,
and the LoRA replaces it with what would be behind it, along with its shadow or reflection. The rest of
the image stays as it was and lines up with the input, so the result can be used as is.
The few-step variants run on top of PrunaAI's distillation LoRA,
[PrunaAI/P-Q-Image-2.1](https://huggingface.co/PrunaAI/P-Q-Image-2.1), in 6 or 8 steps without CFG.
A base-model variant runs at the usual 40 steps.
<table>
<tr>
<th>Photo</th>
<th>Input (outline)</th>
<th>Result</th>
</tr>
<tr>
<td width="33%"><img src="examples/R1_photo.jpg" width="100%"></td>
<td width="33%"><img src="examples/R1_outlined.jpg" width="100%"></td>
<td width="33%"><img src="examples/R1_result.jpg" width="100%"></td>
</tr>
</table>
*"Remove the person with the umbrella walking across the plaza."* The outline covers only the person;
their long reflection on the wet plaza, outside it, goes too, and the paving carries on through the gap.
6-step variant, ~2 MP. Photo: Hooman R.,
[Unsplash](https://unsplash.com/photos/a-person-walking-in-the-rain-with-an-umbrella-OzRnoE7qF7A).
| | |
|---|---|
| **Task** | Object removal from a single photo |
| **Input** | Photo + instruction, with the object marked by a red outline (recommended) or by the instruction alone |
| **Sampling** | 6 or 8 steps on PrunaAI/P-Q-Image-2.1, or 40 steps on the base model; no CFG |
| **Resolution** | Generates at the photo's own area; examples shown at ~2 MP |
| **Weights** | LoRA rank 32, three files, one per variant |
| **Base model** | [Qwen/Qwen-Image-2.1](https://huggingface.co/Qwen/Qwen-Image-2.1) with `QwenImage21Pipeline` |
## Variants
Pick **6-step** as the default (recommended), or **base** to avoid the few-step model's drift.
| Variant | File | Runs on | Distillation LoRA (PrunaAI/P-Q-Image-2.1) | Steps | Sigmas | Strength |
|---|---|---|---|:---:|---|:---:|
| `6-step` | `p_q_image_2.1_remove_object_6_steps_v0.1.safetensors` | distilled model | `p_q_image_2.1_6_steps_v0.2.safetensors` | 6 | shifted by image size | **0.7** |
| `8-step` | `p_q_image_2.1_remove_object_8_steps_v0.1.safetensors` | distilled model | `p_q_image_2.1_8_steps_v0.1.safetensors` | 8 | used as given | **0.7** |
| `base` | `p_q_image_2.1_remove_object_base_v0.1.safetensors` | base model | none | 40 | the pipeline's default | 1.0 |
"Strength" is the adapter weight of this LoRA. The distillation LoRA always runs at 1.0.
- **6-step** and **8-step** do in 6 or 8 steps what the base-model variant does in 40. Both run at a
reduced strength of 0.7.
- **base** runs on the base model alone. Slower, but without the few-step model's drift.
The few-step variants are made to run on top of the matching distillation LoRA. Use each with its own
distillation LoRA, step count and sigma schedule. They are not meant for the base model's 40-step
sampling.
## Quickstart
Needs a **CUDA GPU**.
```bash
pip install 'torch>=2.4.0' 'transformers>=5.17' accelerate peft pillow numpy opencv-python-headless
pip install git+https://github.com/huggingface/diffusers@6256aa7666cedd47443adc8f82da9a10e110b09c
```
`draw_outline.py` (in this repo) draws the outline exactly as expected by the model.
```python
import torch
from PIL import Image
from diffusers import FlowMatchEulerDiscreteScheduler, QwenImage21Pipeline
from draw_outline import draw_outline, outline_prompt
VARIANT = "6-step" # "6-step", "8-step" or "base"
DISTILL, LORA, SIGMAS, DYNAMIC_SHIFT, STRENGTH = {
# Unshifted sigmas: the scheduler shifts them by image size.
"6-step": ("p_q_image_2.1_6_steps_v0.2.safetensors", "p_q_image_2.1_remove_object_6_steps_v0.1.safetensors",
[1.0, 0.925, 0.85, 0.625, 0.375, 0.125], True, 0.7),
# Sigmas used exactly as given.
"8-step": ("p_q_image_2.1_8_steps_v0.1.safetensors", "p_q_image_2.1_remove_object_8_steps_v0.1.safetensors",
[1.0, 14 / 15, 6 / 7, 10 / 13, 2 / 3, 6 / 11, 0.4, 2 / 9], False, 0.7),
# Base model alone: 40 steps, the pipeline's own scheduler.
"base": (None, "p_q_image_2.1_remove_object_base_v0.1.safetensors", None, None, 1.0),
}[VARIANT]
pipe = QwenImage21Pipeline.from_pretrained("Qwen/Qwen-Image-2.1", torch_dtype=torch.bfloat16).to("cuda")
pipe.load_lora_weights("PrunaAI/P-Q-Image-2.1-Remove-Object", weight_name=LORA, adapter_name="removal")
if DISTILL:
# PrunaAI's distillation LoRA at 1.0 under this one, at its own strength.
pipe.load_lora_weights("PrunaAI/P-Q-Image-2.1", weight_name=DISTILL, adapter_name="distill")
pipe.set_adapters(["distill", "removal"], adapter_weights=[1.0, STRENGTH])
pipe.scheduler = FlowMatchEulerDiscreteScheduler.from_config(
pipe.scheduler.config, use_dynamic_shifting=DYNAMIC_SHIFT, shift=1.0, shift_terminal=None)
else:
pipe.set_adapters(["removal"], adapter_weights=[STRENGTH])
photo = Image.open("photo.jpg").convert("RGB")
mask = Image.open("mask.png") # white = the object to remove
edited = pipe(
prompt=outline_prompt("Remove the red car on the left."),
image=[draw_outline(photo, mask)],
sigmas=SIGMAS,
num_inference_steps=len(SIGMAS) if SIGMAS else 40,
true_cfg_scale=1.0,
# Generate at the photo's own area (the pipeline rounds the size to multiples of 32).
output_resolution=round((photo.width * photo.height) ** 0.5),
generator=torch.Generator("cuda").manual_seed(0),
).images[0].resize(photo.size, Image.LANCZOS)
edited.save("edited.png")
```
The pipeline needs sides that are multiples of 32, so the photo is generated at the nearest such size
with the same area and resized back. This does not shift or stretch the result measurably.
## Marking the object
The LoRA accepts two kinds of input.
| Input | Example | Supported |
|---|---|---|
| A rough mask, drawn as an outline | an outline around the goat; the model infers that its shadow goes too | **yes, recommended** |
| The instruction only | "remove the middle goat" | yes |
**Drawing the outline.** Use `draw_outline.py` (in this repo): `draw_outline` draws the outline exactly as
expected by the model, and `outline_prompt` adds the sentence that goes with it. In plain words: a pure
red ring, `#FF0000` (255, 0, 0), that starts 2 px outside the mask and is 3 px wide (4 px when the
photo's short side is over 900 px), drawn on the photo at its own size, and the sentence *"The area to
edit is outlined in red. Remove the red outline as well."* after the instruction. Keep the outlined
image lossless (PNG), since JPEG shifts the red.
### Recommended settings
- **Outline and prompt go together.** With an outlined photo, end the instruction with the outline
sentence (`outline_prompt` adds it).
- **The mask does not need to be exact.** It works with rough, generous outlines. Include
the object's shadow or reflection in the mask if they should go too, but keep it off anything that
should stay (see [Limitations](#limitations)).
- **Name the object as it appears**, and say which one when there are several similar ones (*"the man
on the right"*, *"the second cup from the left"*).
- **Without a mask**, pass the plain photo and the instruction alone. The outline remains the
recommended way, since it says exactly which object to remove, but if the outline makes the model
remove too much, the prompt alone can do better.
- **Keep the strength given in the [Variants](#variants) table**, `true_cfg_scale=1.0` and the
distillation LoRA at 1.0. Lower strengths reduce texture artifacts and changes outside the mask, but at
0.5 some removals fail (the object stays, recolored). Above ~1.25 the model also removes neighboring
objects.
## Why this LoRA
An object removal edit has two jobs:
1. **A good edit where the object was.** The object goes, along with what it causes (its shadow, its
reflection), and the gap is filled with a believable background.
2. **No change anywhere else.** The rest of the image stays exactly as it was, unless the removal
affects it.
Models are usually trained for the first, and the second is often lacking. Qwen-Image-2.1 in particular
changes the rest of the image noticeably, and can even shift it so that the output no longer lines up
with the input. Both get worse with the few-step distilled model. This LoRA does both jobs: the object
and its effects go, and the rest of the image stays as it was, lined up with the input.
## Examples
18 photos from [Unsplash](https://unsplash.com), edited with the **6-step variant** at **~2 MP** in
outline mode.
### Highlights
| | Photo | Result |
|---|---|---|
| *Remove the person with the umbrella walking across the plaza.* |  |  |
| *Remove the boathouse and the red canoes on the shore.* |  |  |
| *Remove the woman in the pink dress.* |  |  |
| *Remove the phone and the raised arm holding it.* |  |  |
<details>
<summary><b>See all 18 examples, with the outlined inputs</b></summary>
<table>
<tr>
<th width="25%"></th>
<th width="25%">Photo</th>
<th width="25%">Input (outline)</th>
<th width="25%">Result</th>
</tr>
<tr>
<td width="25%"><em>Remove the person with the umbrella walking across the plaza.</em><br>Photo: Hooman R., <a href="https://unsplash.com/photos/a-person-walking-in-the-rain-with-an-umbrella-OzRnoE7qF7A">Unsplash</a></td>
<td width="25%"><img src="examples/R1_photo.jpg" width="100%"></td>
<td width="25%"><img src="examples/R1_outlined.jpg" width="100%"></td>
<td width="25%"><img src="examples/R1_result.jpg" width="100%"></td>
</tr>
<tr>
<td width="25%"><em>Remove the person with the umbrella walking on the sidewalk.</em><br>Photo: Sohan Shingade, <a href="https://unsplash.com/photos/a-person-walking-in-the-rain-with-an-umbrella-WWfiTIjy780">Unsplash</a></td>
<td width="25%"><img src="examples/R3_photo.jpg" width="100%"></td>
<td width="25%"><img src="examples/R3_outlined.jpg" width="100%"></td>
<td width="25%"><img src="examples/R3_result.jpg" width="100%"></td>
</tr>
<tr>
<td width="25%"><em>Remove the three construction cranes.</em><br>Photo: Cool Photos, <a href="https://unsplash.com/photos/city-skyline-and-construction-cranes-silhouetted-against-a-fiery-sunset-GGdgJepTFu8">Unsplash</a></td>
<td width="25%"><img src="examples/Y4_photo.jpg" width="100%"></td>
<td width="25%"><img src="examples/Y4_outlined.jpg" width="100%"></td>
<td width="25%"><img src="examples/Y4_result.jpg" width="100%"></td>
</tr>
<tr>
<td width="25%"><em>Remove the blue tent.</em><br>Photo: Hameen Reynolds, <a href="https://unsplash.com/photos/person-fishing-on-sandy-beach-0mawt19VQTU">Unsplash</a></td>
<td width="25%"><img src="examples/A8_photo.jpg" width="100%"></td>
<td width="25%"><img src="examples/A8_outlined.jpg" width="100%"></td>
<td width="25%"><img src="examples/A8_result.jpg" width="100%"></td>
</tr>
<tr>
<td width="25%"><em>Remove the woman in the pink dress.</em><br>Photo: The Now Time, <a href="https://unsplash.com/photos/a-woman-in-a-pink-dress-and-hat-standing-in-a-field-of-flowers--GXYzjeBiw8">Unsplash</a></td>
<td width="25%"><img src="examples/TL_photo.jpg" width="100%"></td>
<td width="25%"><img src="examples/TL_outlined.jpg" width="100%"></td>
<td width="25%"><img src="examples/TL_result.jpg" width="100%"></td>
</tr>
<tr>
<td width="25%"><em>Remove the woman walking on the path.</em><br>Photo: Krists Luhaers, <a href="https://unsplash.com/photos/women-walking-on-pathway-surrounded-by-dried-leaves-u5NqIxG41jU">Unsplash</a></td>
<td width="25%"><img src="examples/A3_photo.jpg" width="100%"></td>
<td width="25%"><img src="examples/A3_outlined.jpg" width="100%"></td>
<td width="25%"><img src="examples/A3_result.jpg" width="100%"></td>
</tr>
<tr>
<td width="25%"><em>Remove the person standing in the wheat field.</em><br>Photo: rashid khreiss, <a href="https://unsplash.com/photos/woman-standing-on-dried-whey-4NMRdyAjcAk">Unsplash</a></td>
<td width="25%"><img src="examples/W7_photo.jpg" width="100%"></td>
<td width="25%"><img src="examples/W7_outlined.jpg" width="100%"></td>
<td width="25%"><img src="examples/W7_result.jpg" width="100%"></td>
</tr>
<tr>
<td width="25%"><em>Remove the wooden chapel.</em><br>Photo: Christopher Politano, <a href="https://unsplash.com/photos/wooden-chapel-on-mountain-hill-nYH4jVuOiBE">Unsplash</a></td>
<td width="25%"><img src="examples/C3_photo.jpg" width="100%"></td>
<td width="25%"><img src="examples/C3_outlined.jpg" width="100%"></td>
<td width="25%"><img src="examples/C3_result.jpg" width="100%"></td>
</tr>
<tr>
<td width="25%"><em>Remove the white cottage.</em><br>Photo: Abby Shirey, <a href="https://unsplash.com/photos/remote-cottage-nestled-in-a-vast-mountainous-landscape-gusSvbighUM">Unsplash</a></td>
<td width="25%"><img src="examples/H1_photo.jpg" width="100%"></td>
<td width="25%"><img src="examples/H1_outlined.jpg" width="100%"></td>
<td width="25%"><img src="examples/H1_result.jpg" width="100%"></td>
</tr>
<tr>
<td width="25%"><em>Remove the boathouse and the red canoes on the shore.</em><br>Photo: Sam Dawson, <a href="https://unsplash.com/photos/black-mountain-covered-with-snow-7t5c1iDrApU">Unsplash</a></td>
<td width="25%"><img src="examples/L8_photo.jpg" width="100%"></td>
<td width="25%"><img src="examples/L8_outlined.jpg" width="100%"></td>
<td width="25%"><img src="examples/L8_result.jpg" width="100%"></td>
</tr>
<tr>
<td width="25%"><em>Remove the wooden ladder, the white stool and the potted plant.</em><br>Photo: Andrew Neel, <a href="https://unsplash.com/photos/ladder-stool-and-snake-plant-DLD5LvnFblU">Unsplash</a></td>
<td width="25%"><img src="examples/E1_photo.jpg" width="100%"></td>
<td width="25%"><img src="examples/E1_outlined.jpg" width="100%"></td>
<td width="25%"><img src="examples/E1_result.jpg" width="100%"></td>
</tr>
<tr>
<td width="25%"><em>Remove the phone.</em><br>Photo: micheile henderson, <a href="https://unsplash.com/photos/black-and-red-iphone-5-c-beside-white-ceramic-mug-with-red-and-white-liquid-KQlbxeWY1pQ">Unsplash</a></td>
<td width="25%"><img src="examples/F4_photo.jpg" width="100%"></td>
<td width="25%"><img src="examples/F4_outlined.jpg" width="100%"></td>
<td width="25%"><img src="examples/F4_result.jpg" width="100%"></td>
</tr>
<tr>
<td width="25%"><em>Remove the phone and the raised arm holding it.</em><br>Photo: Aliaksei Antropau, <a href="https://unsplash.com/photos/person-recording-concert-under-red-lights-n24LASzjRgs">Unsplash</a></td>
<td width="25%"><img src="examples/c9_photo.jpg" width="100%"></td>
<td width="25%"><img src="examples/c9_outlined.jpg" width="100%"></td>
<td width="25%"><img src="examples/c9_result.jpg" width="100%"></td>
</tr>
<tr>
<td width="25%"><em>Remove the phone held up on the right.</em><br>Photo: Юлия Журавлева, <a href="https://unsplash.com/photos/fireworks-explode-in-the-night-sky-for-a-crowd-tLAe7MUTggM">Unsplash</a></td>
<td width="25%"><img src="examples/f3_photo.jpg" width="100%"></td>
<td width="25%"><img src="examples/f3_outlined.jpg" width="100%"></td>
<td width="25%"><img src="examples/f3_result.jpg" width="100%"></td>
</tr>
<tr>
<td width="25%"><em>Remove the woman with her hands on her head in the middle of the crowd.</em><br>Photo: Lukas Bato, <a href="https://unsplash.com/photos/people-standing-in-front-of-stage-with-lights-C6ni9uAva5I">Unsplash</a></td>
<td width="25%"><img src="examples/c7_photo.jpg" width="100%"></td>
<td width="25%"><img src="examples/c7_outlined.jpg" width="100%"></td>
<td width="25%"><img src="examples/c7_result.jpg" width="100%"></td>
</tr>
<tr>
<td width="25%"><em>Remove the two light stands, with the LED light and the boom arm.</em><br>Photo: KOBU Agency, <a href="https://unsplash.com/photos/a-chair-sitting-in-front-of-a-pink-backdrop-uKKNmPBsaiI">Unsplash</a></td>
<td width="25%"><img src="examples/t5_photo.jpg" width="100%"></td>
<td width="25%"><img src="examples/t5_outlined.jpg" width="100%"></td>
<td width="25%"><img src="examples/t5_result.jpg" width="100%"></td>
</tr>
<tr>
<td width="25%"><em>Remove the two umbrella lights on their stands.</em><br>Photo: Arif DALKIRAN, <a href="https://unsplash.com/photos/a-lamp-is-set-up-for-a-studio-photoshoot-LYcuJG5LyU8">Unsplash</a></td>
<td width="25%"><img src="examples/t8_photo.jpg" width="100%"></td>
<td width="25%"><img src="examples/t8_outlined.jpg" width="100%"></td>
<td width="25%"><img src="examples/t8_result.jpg" width="100%"></td>
</tr>
<tr>
<td width="25%"><em>Remove the studio light in the foreground on the left and the softbox on the right.</em><br>Photo: Olga Serjantu, <a href="https://unsplash.com/photos/a-table-with-a-bunch-of-fruit-and-vegetables-on-it-qu2JENeCaE4">Unsplash</a></td>
<td width="25%"><img src="examples/t6_photo.jpg" width="100%"></td>
<td width="25%"><img src="examples/t6_outlined.jpg" width="100%"></td>
<td width="25%"><img src="examples/t6_result.jpg" width="100%"></td>
</tr>
</table>
</details>
## Limitations
- **It can remove more than the outlined object.** Not always, but it happens: the outline weighs more
than the instruction, so
when the mask also covers part of something that should stay, that can go too. With two people where
one partly hides the other, a mask around one sometimes removes both, while the prompt alone removes
only the right one. Keep the mask tight where other things overlap the object. Lowering the strength
does not fix this.
- **Textures in the filled area can look off.** The fill can come out smoother and blurrier than its
surroundings, miss the photo's grain, or show a regular grid pattern. It stands out more than one
might expect, and can read as inconsistent focus. The few-step variants' reduced default
strength (0.7) lessens it without removing it. The strength is a trade-off you can
tune for your own images: lower gives cleaner textures but weaker removals (at 0.5 some fail, keeping
or recoloring the object), higher gives firmer removals with more texture artifacts.
- **Only for removing objects.** Other edits (adding or replacing an object, changing colors or style)
were never trained and are not expected to work better than with the base model alone.
- **Plausible, not accurate.** It fills in what should be behind the object, so heavily occluded or
ambiguous backgrounds can come out plausible rather than accurate.
## What this is not
- Not a standalone model. It needs the `Qwen/Qwen-Image-2.1` base weights, and the few-step variants
also need [PrunaAI/P-Q-Image-2.1](https://huggingface.co/PrunaAI/P-Q-Image-2.1).
- Not a general image editor. It is trained for object removal only.
- Not a finished release. Expect the weights to change in future versions.
## License
P-Q-Image-2.1-Remove-Object is a derivative of Qwen-Image-2.1 and follows the
[Qwen RESEARCH LICENSE AGREEMENT](https://huggingface.co/Qwen/Qwen-Image-2.1/blob/main/LICENSE). Review
its use restrictions before using or redistributing the adapters. The few-step variants also need
PrunaAI's distillation LoRA ([PrunaAI/P-Q-Image-2.1](https://huggingface.co/PrunaAI/P-Q-Image-2.1)),
whose own terms apply.
Qwen is licensed under the Qwen RESEARCH LICENSE AGREEMENT, Copyright (c) 2026 Hangzhou Tongyi
Laboratory Technology Co., Ltd. All Rights Reserved.
The example photos are from Unsplash, under the [Unsplash License](https://unsplash.com/license): free
to copy, modify and use, commercial use included, without asking or crediting the photographer (credits
are given anyway). Not allowed: selling a photo without significant modification, or compiling Unsplash
photos into a similar or competing service. Each photo's page was checked on 2026-11-04 and read "Free
to use under the Unsplash License", and again on 2026-11-10 for the final set.
> **The Unsplash License does not cover people or brands in a photo.** Per the
> [Unsplash Terms](https://unsplash.com/terms), trademarks, logos and brands, and recognizable people,
> may need the permission of their owner or of the person, depending on the use. People appear in
> several examples, from behind or as silhouettes, without a readable face. The night plaza photo shows
> a small lit shop sign ("NAILS & RESORT") in the background, an incidental business name. The chapel,
> cottage and boathouse photos show buildings that are likely identifiable (a Swiss chapel, a Glen Coe
> cottage, the Lake Louise boathouse), shot from public land and removed in the result. No other example
> shows a readable brand.
> This is a record of what the licenses say, not legal advice.
## What's next?
- **Use P-Q-Image-2.1-Remove-Object to remove objects from photos 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 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).
<style>
.model-button {
display: inline-flex;
flex-direction: row;
justify-content: center;
align-items: center;
gap: 8px;
padding: 8px 20px;
border: none;
border-radius: 8px;
background: #9334e9;
color: #ffffff;
font-size: 14px;
font-weight: 400;
line-height: 1;
text-decoration: none;
white-space: nowrap;
cursor: pointer;
box-sizing: border-box;
overflow: visible;
opacity: 1;
}
</style>
<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>
|