How to use from the
Use from the
Diffusers library
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]

GitHub   Twitter/X   LinkedIn   Discord   Performance Models

⚡ P-Q-Image-2.1-Remove-Object

Object removal LoRAs for Qwen-Image-2.1 that leave the rest of the image untouched

6 or 8 steps  ·  No CFG  ·  Rough masks  ·  Shadows and reflections go too

P-Q-Image-2.1-Remove-Object is a set of LoRA adapters for 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, in 6 or 8 steps without CFG. A base-model variant runs at the usual 40 steps.

Photo Input (outline) Result

"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.

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 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.

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.

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).
  • 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 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, 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.
See all 18 examples, with the outlined inputs
Photo Input (outline) Result
Remove the person with the umbrella walking across the plaza.
Photo: Hooman R., Unsplash
Remove the person with the umbrella walking on the sidewalk.
Photo: Sohan Shingade, Unsplash
Remove the three construction cranes.
Photo: Cool Photos, Unsplash
Remove the blue tent.
Photo: Hameen Reynolds, Unsplash
Remove the woman in the pink dress.
Photo: The Now Time, Unsplash
Remove the woman walking on the path.
Photo: Krists Luhaers, Unsplash
Remove the person standing in the wheat field.
Photo: rashid khreiss, Unsplash
Remove the wooden chapel.
Photo: Christopher Politano, Unsplash
Remove the white cottage.
Photo: Abby Shirey, Unsplash
Remove the boathouse and the red canoes on the shore.
Photo: Sam Dawson, Unsplash
Remove the wooden ladder, the white stool and the potted plant.
Photo: Andrew Neel, Unsplash
Remove the phone.
Photo: micheile henderson, Unsplash
Remove the phone and the raised arm holding it.
Photo: Aliaksei Antropau, Unsplash
Remove the phone held up on the right.
Photo: Юлия Журавлева, Unsplash
Remove the woman with her hands on her head in the middle of the crowd.
Photo: Lukas Bato, Unsplash
Remove the two light stands, with the LED light and the boom arm.
Photo: KOBU Agency, Unsplash
Remove the two umbrella lights on their stands.
Photo: Arif DALKIRAN, Unsplash
Remove the studio light in the foreground on the left and the softbox on the right.
Photo: Olga Serjantu, Unsplash

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.
  • 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. 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), 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: 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, 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 and give us a ⭐️ for more efficiency!
  • Want to use our optimized image models right away? Check P-Image-Ideogram and P-Image-Edit.

Try our models

Downloads last month
48
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for PrunaAI/P-Q-Image-2.1-Remove-Object

Adapter
(167)
this model
Adapters
1 model

Space using PrunaAI/P-Q-Image-2.1-Remove-Object 1

Collection including PrunaAI/P-Q-Image-2.1-Remove-Object