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
Commit ·
fa5b4fe
0
Parent(s):
P-Q-Image-2.1-Remove-Object v0.1: LoRAs, model card, examples
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- .gitattributes +87 -0
- LICENSE +55 -0
- NOTICE +3 -0
- README.md +450 -0
- assets/P-Q-Image-2.1-Remove-Object.png +3 -0
- draw_outline.py +56 -0
- examples/A3_outlined.jpg +3 -0
- examples/A3_photo.jpg +3 -0
- examples/A3_result.jpg +3 -0
- examples/A8_outlined.jpg +3 -0
- examples/A8_photo.jpg +3 -0
- examples/A8_result.jpg +3 -0
- examples/C3_outlined.jpg +3 -0
- examples/C3_photo.jpg +3 -0
- examples/C3_result.jpg +3 -0
- examples/E1_outlined.jpg +3 -0
- examples/E1_photo.jpg +0 -0
- examples/E1_result.jpg +0 -0
- examples/F4_outlined.jpg +3 -0
- examples/F4_photo.jpg +3 -0
- examples/F4_result.jpg +3 -0
- examples/H1_outlined.jpg +3 -0
- examples/H1_photo.jpg +3 -0
- examples/H1_result.jpg +3 -0
- examples/L8_outlined.jpg +3 -0
- examples/L8_photo.jpg +3 -0
- examples/L8_result.jpg +3 -0
- examples/R1_outlined.jpg +3 -0
- examples/R1_photo.jpg +3 -0
- examples/R1_result.jpg +3 -0
- examples/R3_outlined.jpg +3 -0
- examples/R3_photo.jpg +3 -0
- examples/R3_result.jpg +3 -0
- examples/TL_outlined.jpg +3 -0
- examples/TL_photo.jpg +3 -0
- examples/TL_result.jpg +3 -0
- examples/W7_outlined.jpg +3 -0
- examples/W7_photo.jpg +3 -0
- examples/W7_result.jpg +3 -0
- examples/Y4_outlined.jpg +3 -0
- examples/Y4_photo.jpg +0 -0
- examples/Y4_result.jpg +0 -0
- examples/c7_outlined.jpg +3 -0
- examples/c7_photo.jpg +3 -0
- examples/c7_result.jpg +3 -0
- examples/c9_outlined.jpg +3 -0
- examples/c9_photo.jpg +3 -0
- examples/c9_result.jpg +3 -0
- examples/f3_outlined.jpg +3 -0
- examples/f3_photo.jpg +3 -0
.gitattributes
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
| 2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
| 3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
| 4 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
| 5 |
+
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
| 6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
| 7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
| 8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
| 9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
| 10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
| 11 |
+
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
| 12 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
| 13 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
| 14 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
| 15 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
| 16 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
| 17 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
| 18 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
| 19 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
| 20 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
| 21 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
| 22 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
| 23 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
| 24 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
| 25 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
| 26 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
| 27 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
| 28 |
+
*.tar filter=lfs diff=lfs merge=lfs -text
|
| 29 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
| 30 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
| 31 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
| 32 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
| 33 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
assets/P-Q-Image-2.1-Remove-Object.png filter=lfs diff=lfs merge=lfs -text
|
| 37 |
+
examples/A3_outlined.jpg filter=lfs diff=lfs merge=lfs -text
|
| 38 |
+
examples/A3_photo.jpg filter=lfs diff=lfs merge=lfs -text
|
| 39 |
+
examples/A3_result.jpg filter=lfs diff=lfs merge=lfs -text
|
| 40 |
+
examples/A8_outlined.jpg filter=lfs diff=lfs merge=lfs -text
|
| 41 |
+
examples/A8_photo.jpg filter=lfs diff=lfs merge=lfs -text
|
| 42 |
+
examples/A8_result.jpg filter=lfs diff=lfs merge=lfs -text
|
| 43 |
+
examples/C3_outlined.jpg filter=lfs diff=lfs merge=lfs -text
|
| 44 |
+
examples/C3_photo.jpg filter=lfs diff=lfs merge=lfs -text
|
| 45 |
+
examples/C3_result.jpg filter=lfs diff=lfs merge=lfs -text
|
| 46 |
+
examples/E1_outlined.jpg filter=lfs diff=lfs merge=lfs -text
|
| 47 |
+
examples/F4_outlined.jpg filter=lfs diff=lfs merge=lfs -text
|
| 48 |
+
examples/F4_photo.jpg filter=lfs diff=lfs merge=lfs -text
|
| 49 |
+
examples/F4_result.jpg filter=lfs diff=lfs merge=lfs -text
|
| 50 |
+
examples/H1_outlined.jpg filter=lfs diff=lfs merge=lfs -text
|
| 51 |
+
examples/H1_photo.jpg filter=lfs diff=lfs merge=lfs -text
|
| 52 |
+
examples/H1_result.jpg filter=lfs diff=lfs merge=lfs -text
|
| 53 |
+
examples/L8_outlined.jpg filter=lfs diff=lfs merge=lfs -text
|
| 54 |
+
examples/L8_photo.jpg filter=lfs diff=lfs merge=lfs -text
|
| 55 |
+
examples/L8_result.jpg filter=lfs diff=lfs merge=lfs -text
|
| 56 |
+
examples/R1_outlined.jpg filter=lfs diff=lfs merge=lfs -text
|
| 57 |
+
examples/R1_photo.jpg filter=lfs diff=lfs merge=lfs -text
|
| 58 |
+
examples/R1_result.jpg filter=lfs diff=lfs merge=lfs -text
|
| 59 |
+
examples/R3_outlined.jpg filter=lfs diff=lfs merge=lfs -text
|
| 60 |
+
examples/R3_photo.jpg filter=lfs diff=lfs merge=lfs -text
|
| 61 |
+
examples/R3_result.jpg filter=lfs diff=lfs merge=lfs -text
|
| 62 |
+
examples/TL_outlined.jpg filter=lfs diff=lfs merge=lfs -text
|
| 63 |
+
examples/TL_photo.jpg filter=lfs diff=lfs merge=lfs -text
|
| 64 |
+
examples/TL_result.jpg filter=lfs diff=lfs merge=lfs -text
|
| 65 |
+
examples/W7_outlined.jpg filter=lfs diff=lfs merge=lfs -text
|
| 66 |
+
examples/W7_photo.jpg filter=lfs diff=lfs merge=lfs -text
|
| 67 |
+
examples/W7_result.jpg filter=lfs diff=lfs merge=lfs -text
|
| 68 |
+
examples/Y4_outlined.jpg filter=lfs diff=lfs merge=lfs -text
|
| 69 |
+
examples/c2_outlined.jpg filter=lfs diff=lfs merge=lfs -text
|
| 70 |
+
examples/c2_photo.jpg filter=lfs diff=lfs merge=lfs -text
|
| 71 |
+
examples/c2_result.jpg filter=lfs diff=lfs merge=lfs -text
|
| 72 |
+
examples/c7_outlined.jpg filter=lfs diff=lfs merge=lfs -text
|
| 73 |
+
examples/c7_photo.jpg filter=lfs diff=lfs merge=lfs -text
|
| 74 |
+
examples/c7_result.jpg filter=lfs diff=lfs merge=lfs -text
|
| 75 |
+
examples/f3_outlined.jpg filter=lfs diff=lfs merge=lfs -text
|
| 76 |
+
examples/f3_photo.jpg filter=lfs diff=lfs merge=lfs -text
|
| 77 |
+
examples/f3_result.jpg filter=lfs diff=lfs merge=lfs -text
|
| 78 |
+
examples/t5_outlined.jpg filter=lfs diff=lfs merge=lfs -text
|
| 79 |
+
examples/t5_photo.jpg filter=lfs diff=lfs merge=lfs -text
|
| 80 |
+
examples/t5_result.jpg filter=lfs diff=lfs merge=lfs -text
|
| 81 |
+
examples/t6_outlined.jpg filter=lfs diff=lfs merge=lfs -text
|
| 82 |
+
examples/t6_photo.jpg filter=lfs diff=lfs merge=lfs -text
|
| 83 |
+
examples/t6_result.jpg filter=lfs diff=lfs merge=lfs -text
|
| 84 |
+
examples/t8_outlined.jpg filter=lfs diff=lfs merge=lfs -text
|
| 85 |
+
examples/c9_photo.jpg filter=lfs diff=lfs merge=lfs -text
|
| 86 |
+
examples/c9_outlined.jpg filter=lfs diff=lfs merge=lfs -text
|
| 87 |
+
examples/c9_result.jpg filter=lfs diff=lfs merge=lfs -text
|
LICENSE
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Qwen RESEARCH LICENSE AGREEMENT
|
| 2 |
+
|
| 3 |
+
Qwen RESEARCH LICENSE AGREEMENT Release Date: September 20, 2026
|
| 4 |
+
|
| 5 |
+
By clicking to agree or by using or distributing any portion or element of the Qwen Materials, you will be deemed to have recognized and accepted the content of this Agreement, which is effective immediately.
|
| 6 |
+
|
| 7 |
+
1. Definitions
|
| 8 |
+
a. This Qwen RESEARCH LICENSE AGREEMENT (this "Agreement") shall mean the terms and conditions for use, reproduction, distribution and modification of the Materials as defined by this Agreement.
|
| 9 |
+
b. "We" (or "Us") shall mean Hangzhou Tongyi Laboratory Technology Co., Ltd.
|
| 10 |
+
c. "You" (or "Your") shall mean a natural person or legal entity exercising the rights granted by this Agreement and/or using the Materials for any purpose and in any field of use.
|
| 11 |
+
d. "Third Parties" shall mean individuals or legal entities that are not under common control with us or you.
|
| 12 |
+
e. "Qwen" shall mean the large language models, diffusion models, and software and algorithms, consisting of trained model weights, parameters (including optimizer states), machine-learning model code, inference-enabling code, training-enabling code, fine-tuning enabling code and other elements of the foregoing distributed by us.
|
| 13 |
+
f. "Materials" shall mean, collectively, our proprietary Qwen and Documentation (and any portion thereof) made available under this Agreement.
|
| 14 |
+
g. "Source" form shall mean the preferred form for making modifications, including but not limited to model source code, documentation source, and configuration files.
|
| 15 |
+
h. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
|
| 16 |
+
i. "Non-Commercial" shall mean for research or evaluation purposes only.
|
| 17 |
+
|
| 18 |
+
2. Grant of Rights
|
| 19 |
+
a. You are granted a non-exclusive, worldwide, non-transferable and royalty-free limited license under our intellectual property or other rights owned by us embodied in the Materials to use, reproduce, distribute, copy, create derivative works of, and make modifications to the Materials FOR NON-COMMERCIAL PURPOSES ONLY.
|
| 20 |
+
b. You shall not use the Materials for any commercial purpose without obtaining a separate commercial license from us. If you wish to use the Materials commercially, you shall request a license from us at model-business@notice.qwencloud.com.
|
| 21 |
+
|
| 22 |
+
3. Redistribution
|
| 23 |
+
Subject to Section 2 (Grant of Rights), you may distribute copies or make the Materials, or derivative works thereof, available as part of a product or service that contains any of them, with or without modifications, and in Source or Object form, provided that you meet the following conditions:
|
| 24 |
+
a. You shall give any other recipients of the Materials or derivative works a copy of this Agreement;
|
| 25 |
+
b. You shall cause any modified files to carry prominent notices stating that you changed the files;
|
| 26 |
+
c. You shall retain in all copies of the Materials that you distribute the following attribution notices within a "Notice" text file distributed as a part of such copies: "Qwen is licensed under the Qwen RESEARCH LICENSE AGREEMENT, Copyright (c) 2026 Hangzhou Tongyi Laboratory Technology Co., Ltd. All Rights Reserved."; and
|
| 27 |
+
d. You may add your own copyright statement to your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of your modifications, or for any such derivative works as a whole, provided your use, reproduction, and distribution of the work otherwise complies with the terms and conditions of this Agreement.
|
| 28 |
+
|
| 29 |
+
4. Rules of use
|
| 30 |
+
a. The Materials may be subject to export controls or restrictions in China, the United States or other countries or regions. You shall comply with applicable laws and regulations in your use of the Materials.
|
| 31 |
+
b. If you use the Materials or any outputs or results therefrom to create, train, fine-tune, or improve an AI model that is distributed or made available, you shall prominently display “Built with Qwen” or “Improved using Qwen” in the related product documentation.
|
| 32 |
+
c. You shall not use "Qwen" as the primary name or identifier of any derivative works or products; reasonable descriptive use (e.g., "fine-tuned from Qwen Image") is permitted.
|
| 33 |
+
|
| 34 |
+
5. Intellectual Property
|
| 35 |
+
a. We retain ownership of all intellectual property rights in and to the Materials and derivatives made by or for us. Conditioned upon compliance with the terms and conditions of this Agreement, with respect to any derivative works and modifications of the Materials that are made by you, you are and will be the owner of such derivative works and modifications.
|
| 36 |
+
b. No trademark license is granted to use the trade names, trademarks, service marks, or product names of us, except as required to fulfill notice requirements under this Agreement or as required for reasonable and customary use in describing and redistributing the Materials.
|
| 37 |
+
c. If you commence a lawsuit or other proceedings (including a cross-claim or counterclaim in a lawsuit) against us or any entity alleging that the Materials or any output therefrom, or any part of the foregoing, infringe any intellectual property or other right owned or licensable by you, then all licenses granted to you under this Agreement shall terminate as of the date such lawsuit or other proceeding is commenced or brought.
|
| 38 |
+
|
| 39 |
+
6. Disclaimer of Warranty and Limitation of Liability
|
| 40 |
+
a. We are not obligated to support, update, provide training for, or develop any further version of the Qwen Materials or to grant any license thereto.
|
| 41 |
+
b. THE MATERIALS ARE PROVIDED "AS IS" WITHOUT ANY EXPRESS OR IMPLIED WARRANTY OF ANY KIND INCLUDING WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT, OR FITNESS FOR A PARTICULAR PURPOSE. WE MAKE NO WARRANTY AND ASSUME NO RESPONSIBILITY FOR THE SAFETY OR STABILITY OF THE MATERIALS AND ANY OUTPUT THEREFROM.
|
| 42 |
+
c. IN NO EVENT SHALL WE BE LIABLE TO YOU FOR ANY DAMAGES, INCLUDING, BUT NOT LIMITED TO ANY DIRECT, OR INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING FROM YOUR USE OR INABILITY TO USE THE MATERIALS OR ANY OUTPUT OF IT, NO MATTER HOW IT’S CAUSED.
|
| 43 |
+
d. You will defend, indemnify and hold harmless us from and against any claim by any third party arising out of or related to your use or distribution of the Materials.
|
| 44 |
+
|
| 45 |
+
7. Survival and Termination.
|
| 46 |
+
a. The term of this Agreement shall commence upon your acceptance of this Agreement or access to the Materials and will continue in full force and effect until terminated in accordance with the terms and conditions herein.
|
| 47 |
+
b. We may terminate this Agreement if you breach any of the terms or conditions of this Agreement. Upon termination of this Agreement, you must delete and cease use of the Materials. Sections 6 and 8 shall survive the termination of this Agreement.
|
| 48 |
+
|
| 49 |
+
8. Governing Law and Jurisdiction.
|
| 50 |
+
a. This Agreement and any dispute arising out of or relating to it will be governed by the laws of China, without regard to conflict of law principles, and the UN Convention on Contracts for the International Sale of Goods does not apply to this Agreement.
|
| 51 |
+
b. The People's Courts in Hangzhou City shall have exclusive jurisdiction over any dispute arising out of this Agreement.
|
| 52 |
+
|
| 53 |
+
9. Other Terms and Conditions.
|
| 54 |
+
a. Any arrangements, understandings, or agreements regarding the Material not stated herein are separate from and independent of the terms and conditions of this Agreement. You shall request a separate license from us, if you use the Materials in ways not expressly agreed to in this Agreement.
|
| 55 |
+
b. We shall not be bound by any additional or different terms or conditions communicated by you unless expressly agreed.
|
NOTICE
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Qwen is licensed under the Qwen RESEARCH LICENSE AGREEMENT, Copyright (c) 2026 Hangzhou Tongyi Laboratory Technology Co., Ltd. All Rights Reserved.
|
| 2 |
+
|
| 3 |
+
The adapter weights are a modification of Qwen Image 2.1.
|
README.md
ADDED
|
@@ -0,0 +1,450 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: other
|
| 3 |
+
license_name: qwen-research
|
| 4 |
+
license_link: https://huggingface.co/Qwen/Qwen-Image-2.1/blob/main/LICENSE
|
| 5 |
+
base_model: Qwen/Qwen-Image-2.1
|
| 6 |
+
library_name: diffusers
|
| 7 |
+
pipeline_tag: image-to-image
|
| 8 |
+
tags:
|
| 9 |
+
- qwen
|
| 10 |
+
- qwen-image
|
| 11 |
+
- image-editing
|
| 12 |
+
- object-removal
|
| 13 |
+
- inpainting
|
| 14 |
+
- lora
|
| 15 |
+
- distilled
|
| 16 |
+
- few-step
|
| 17 |
+
- pruna-ai
|
| 18 |
+
---
|
| 19 |
+
<!-- header start -->
|
| 20 |
+
<p align="center">
|
| 21 |
+
<img src="assets/P-Q-Image-2.1-Remove-Object.png" width="800">
|
| 22 |
+
</p>
|
| 23 |
+
<!-- header end -->
|
| 24 |
+
|
| 25 |
+
<p align="center">
|
| 26 |
+
<a href="https://github.com/PrunaAI/pruna">
|
| 27 |
+
<img src="https://img.shields.io/badge/GitHub-PrunaAI-9334E9?style=plastic&logo=github&logoColor=white" alt="GitHub">
|
| 28 |
+
</a>
|
| 29 |
+
|
| 30 |
+
<a href="https://twitter.com/PrunaAI">
|
| 31 |
+
<img src="https://img.shields.io/badge/Twitter%2FX-@PrunaAI-9334E9?style=plastic&logo=x&logoColor=white" alt="Twitter/X">
|
| 32 |
+
</a>
|
| 33 |
+
|
| 34 |
+
<a href="https://www.linkedin.com/company/pruna-ai">
|
| 35 |
+
<img src="https://img.shields.io/badge/LinkedIn-PrunaAI-9334E9?style=plastic&logo=linkedin&logoColor=white" alt="LinkedIn">
|
| 36 |
+
</a>
|
| 37 |
+
|
| 38 |
+
<a href="https://discord.com/invite/JFQmtFKCjd">
|
| 39 |
+
<img src="https://img.shields.io/badge/Discord-Join%20us-9334E9?style=plastic&logo=discord&logoColor=white" alt="Discord">
|
| 40 |
+
</a>
|
| 41 |
+
|
| 42 |
+
<a href="https://dashboard.pruna.ai/login?utm_source=huggingface&utm_medium=org_card&utm_campaign=hf_traffic">
|
| 43 |
+
<img src="https://img.shields.io/badge/Performance%20Models-Try%20them%20now-9334E9?style=plastic&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI0MTEiIGhlaWdodD0iNDc3IiBmaWxsPSJub25lIj48cGF0aCBmaWxsPSIjZmZmIiBkPSJNMjMuNzAzIDMwMC41MzJjLTEuODQyLS42NzQtNC4xNDItMS4wNTctNS43MDMtMi4wMjktMTIuNTU4LTcuODQ2LTguODM3LTI1LjE3MiA1LjI1NS0yOC4zNjFhLjY2LjY2IDAgMCAwIC4zNDgtLjIwMS42LjYgMCAwIDAgLjE1Ni0uMzZxNi40OS04MS45ODYgNjguNTc3LTEzNC42MjlhLjM0LjM0IDAgMCAwIC4wOTItLjEyNS4zMy4zMyAwIDAgMC0uMDI2LS4zLjMzLjMzIDAgMCAwLS4xMTItLjEwOGMtNC4xMTUtMi40OTctOC42NC00Ljc1LTEyLjM1My03LjQ0M2ExOTAgMTkwIDAgMCAxLTE4Ljc5NC0xNS41MjJjLTIuOTM2LTIuNzY4LTMuNzAzLTUuODkxLjU4LTcuNzdhLjUuNSAwIDAgMCAuMjgtLjYwOEM1MyA3NS45NSA0OC40MTcgNDguNTk5IDQ1LjUxOCAxOS42NXEtLjM5My0zLjg1Mi0uMjcxLTYuMzJhLjc1Ljc1IDAgMCAxIC4xMzQtLjQuNy43IDAgMCAxIC4zMjQtLjI1NXEyLjEwNC0uODQyIDUuODQ0LTEuNDMxYzU4LjExNC05LjEzNiAxMjcuMDA5IDguNDI1IDE0NC4zMDcgNzIuNjQ1cS4xMDMuMzY0LjE3OCAwIDUuMDk2LTI0LjA5NyA0LjYzOC00OC4xOTMtLjA0Ny0yLjc4NyAxLjg3OS00Ljc4O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IgMC0yNy44NzYtMTMuODM1LTI3Ljg3Ni0yOC44MTEgMC0uMzU3LjAyOS0uNTk2LjA1Ny0uNzQ0WiIvPjwvc3ZnPg==" alt="Performance Models">
|
| 44 |
+
</a>
|
| 45 |
+
</p>
|
| 46 |
+
<div align="center">
|
| 47 |
+
|
| 48 |
+
<h1 style="color: #9334E9;">⚡ P-Q-Image-2.1-Remove-Object</h1>
|
| 49 |
+
|
| 50 |
+
<h2>Object removal LoRAs for Qwen-Image-2.1 that leave the rest of the image untouched</h2>
|
| 51 |
+
|
| 52 |
+
<h3>
|
| 53 |
+
<span style="color: #9334E9;">6 or 8 steps</span>
|
| 54 |
+
·
|
| 55 |
+
<span style="color: #9334E9;">No CFG</span>
|
| 56 |
+
·
|
| 57 |
+
<span style="color: #9334E9;">Rough masks</span>
|
| 58 |
+
·
|
| 59 |
+
Shadows and reflections go too
|
| 60 |
+
</h3>
|
| 61 |
+
|
| 62 |
+
</div>
|
| 63 |
+
|
| 64 |
+
**P-Q-Image-2.1-Remove-Object** is a set of LoRA adapters for
|
| 65 |
+
[`Qwen/Qwen-Image-2.1`](https://huggingface.co/Qwen/Qwen-Image-2.1) that **remove the object you point
|
| 66 |
+
at, and change nothing else**. Mark the object with a rough mask, drawn as a red outline on the photo,
|
| 67 |
+
and the LoRA replaces it with what would be behind it, along with its shadow or reflection. The rest of
|
| 68 |
+
the image stays as it was and lines up with the input, so the result can be used as is.
|
| 69 |
+
|
| 70 |
+
The few-step variants run on top of PrunaAI's distillation LoRA,
|
| 71 |
+
[PrunaAI/P-Q-Image-2.1](https://huggingface.co/PrunaAI/P-Q-Image-2.1), in 6 or 8 steps without CFG.
|
| 72 |
+
A base-model variant runs at the usual 40 steps.
|
| 73 |
+
|
| 74 |
+
<table>
|
| 75 |
+
<tr>
|
| 76 |
+
<th>Photo</th>
|
| 77 |
+
<th>Input (outline)</th>
|
| 78 |
+
<th>Result</th>
|
| 79 |
+
</tr>
|
| 80 |
+
<tr>
|
| 81 |
+
<td width="33%"><img src="examples/R1_photo.jpg" width="100%"></td>
|
| 82 |
+
<td width="33%"><img src="examples/R1_outlined.jpg" width="100%"></td>
|
| 83 |
+
<td width="33%"><img src="examples/R1_result.jpg" width="100%"></td>
|
| 84 |
+
</tr>
|
| 85 |
+
</table>
|
| 86 |
+
|
| 87 |
+
*"Remove the person with the umbrella walking across the plaza."* The outline covers only the person;
|
| 88 |
+
their long reflection on the wet plaza, outside it, goes too, and the paving carries on through the gap.
|
| 89 |
+
6-step variant, ~2 MP. Photo: Hooman R.,
|
| 90 |
+
[Unsplash](https://unsplash.com/photos/a-person-walking-in-the-rain-with-an-umbrella-OzRnoE7qF7A).
|
| 91 |
+
|
| 92 |
+
| | |
|
| 93 |
+
|---|---|
|
| 94 |
+
| **Task** | Object removal from a single photo |
|
| 95 |
+
| **Input** | Photo + instruction, with the object marked by a red outline (recommended) or by the instruction alone |
|
| 96 |
+
| **Sampling** | 6 or 8 steps on PrunaAI/P-Q-Image-2.1, or 40 steps on the base model; no CFG |
|
| 97 |
+
| **Resolution** | Generates at the photo's own area; examples shown at ~2 MP |
|
| 98 |
+
| **Weights** | LoRA rank 32, three files, one per variant |
|
| 99 |
+
| **Base model** | [Qwen/Qwen-Image-2.1](https://huggingface.co/Qwen/Qwen-Image-2.1) with `QwenImage21Pipeline` |
|
| 100 |
+
|
| 101 |
+
## Variants
|
| 102 |
+
|
| 103 |
+
Pick **6-step** as the default (recommended), or **base** to avoid the few-step model's drift.
|
| 104 |
+
|
| 105 |
+
| Variant | File | Runs on | Distillation LoRA (PrunaAI/P-Q-Image-2.1) | Steps | Sigmas | Strength |
|
| 106 |
+
|---|---|---|---|:---:|---|:---:|
|
| 107 |
+
| `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** |
|
| 108 |
+
| `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** |
|
| 109 |
+
| `base` | `p_q_image_2.1_remove_object_base_v0.1.safetensors` | base model | none | 40 | the pipeline's default | 1.0 |
|
| 110 |
+
|
| 111 |
+
"Strength" is the adapter weight of this LoRA. The distillation LoRA always runs at 1.0.
|
| 112 |
+
|
| 113 |
+
- **6-step** and **8-step** do in 6 or 8 steps what the base-model variant does in 40. Both run at a
|
| 114 |
+
reduced strength of 0.7.
|
| 115 |
+
- **base** runs on the base model alone. Slower, but without the few-step model's drift.
|
| 116 |
+
|
| 117 |
+
The few-step variants are made to run on top of the matching distillation LoRA. Use each with its own
|
| 118 |
+
distillation LoRA, step count and sigma schedule. They are not meant for the base model's 40-step
|
| 119 |
+
sampling.
|
| 120 |
+
|
| 121 |
+
## Quickstart
|
| 122 |
+
|
| 123 |
+
Needs a **CUDA GPU**.
|
| 124 |
+
|
| 125 |
+
```bash
|
| 126 |
+
pip install 'torch>=2.4.0' 'transformers>=5.17' accelerate peft pillow numpy opencv-python-headless
|
| 127 |
+
pip install git+https://github.com/huggingface/diffusers@6256aa7666cedd47443adc8f82da9a10e110b09c
|
| 128 |
+
```
|
| 129 |
+
|
| 130 |
+
`draw_outline.py` (in this repo) draws the outline exactly as expected by the model.
|
| 131 |
+
|
| 132 |
+
```python
|
| 133 |
+
import torch
|
| 134 |
+
from PIL import Image
|
| 135 |
+
from diffusers import FlowMatchEulerDiscreteScheduler, QwenImage21Pipeline
|
| 136 |
+
from draw_outline import draw_outline, outline_prompt
|
| 137 |
+
|
| 138 |
+
VARIANT = "6-step" # "6-step", "8-step" or "base"
|
| 139 |
+
DISTILL, LORA, SIGMAS, DYNAMIC_SHIFT, STRENGTH = {
|
| 140 |
+
# Unshifted sigmas: the scheduler shifts them by image size.
|
| 141 |
+
"6-step": ("p_q_image_2.1_6_steps_v0.2.safetensors", "p_q_image_2.1_remove_object_6_steps_v0.1.safetensors",
|
| 142 |
+
[1.0, 0.925, 0.85, 0.625, 0.375, 0.125], True, 0.7),
|
| 143 |
+
# Sigmas used exactly as given.
|
| 144 |
+
"8-step": ("p_q_image_2.1_8_steps_v0.1.safetensors", "p_q_image_2.1_remove_object_8_steps_v0.1.safetensors",
|
| 145 |
+
[1.0, 14 / 15, 6 / 7, 10 / 13, 2 / 3, 6 / 11, 0.4, 2 / 9], False, 0.7),
|
| 146 |
+
# Base model alone: 40 steps, the pipeline's own scheduler.
|
| 147 |
+
"base": (None, "p_q_image_2.1_remove_object_base_v0.1.safetensors", None, None, 1.0),
|
| 148 |
+
}[VARIANT]
|
| 149 |
+
|
| 150 |
+
pipe = QwenImage21Pipeline.from_pretrained("Qwen/Qwen-Image-2.1", torch_dtype=torch.bfloat16).to("cuda")
|
| 151 |
+
pipe.load_lora_weights("PrunaAI/P-Q-Image-2.1-Remove-Object", weight_name=LORA, adapter_name="removal")
|
| 152 |
+
if DISTILL:
|
| 153 |
+
# PrunaAI's distillation LoRA at 1.0 under this one, at its own strength.
|
| 154 |
+
pipe.load_lora_weights("PrunaAI/P-Q-Image-2.1", weight_name=DISTILL, adapter_name="distill")
|
| 155 |
+
pipe.set_adapters(["distill", "removal"], adapter_weights=[1.0, STRENGTH])
|
| 156 |
+
pipe.scheduler = FlowMatchEulerDiscreteScheduler.from_config(
|
| 157 |
+
pipe.scheduler.config, use_dynamic_shifting=DYNAMIC_SHIFT, shift=1.0, shift_terminal=None)
|
| 158 |
+
else:
|
| 159 |
+
pipe.set_adapters(["removal"], adapter_weights=[STRENGTH])
|
| 160 |
+
|
| 161 |
+
photo = Image.open("photo.jpg").convert("RGB")
|
| 162 |
+
mask = Image.open("mask.png") # white = the object to remove
|
| 163 |
+
|
| 164 |
+
edited = pipe(
|
| 165 |
+
prompt=outline_prompt("Remove the red car on the left."),
|
| 166 |
+
image=[draw_outline(photo, mask)],
|
| 167 |
+
sigmas=SIGMAS,
|
| 168 |
+
num_inference_steps=len(SIGMAS) if SIGMAS else 40,
|
| 169 |
+
true_cfg_scale=1.0,
|
| 170 |
+
# Generate at the photo's own area (the pipeline rounds the size to multiples of 32).
|
| 171 |
+
output_resolution=round((photo.width * photo.height) ** 0.5),
|
| 172 |
+
generator=torch.Generator("cuda").manual_seed(0),
|
| 173 |
+
).images[0].resize(photo.size, Image.LANCZOS)
|
| 174 |
+
edited.save("edited.png")
|
| 175 |
+
```
|
| 176 |
+
|
| 177 |
+
The pipeline needs sides that are multiples of 32, so the photo is generated at the nearest such size
|
| 178 |
+
with the same area and resized back. This does not shift or stretch the result measurably.
|
| 179 |
+
|
| 180 |
+
## Marking the object
|
| 181 |
+
|
| 182 |
+
The LoRA accepts two kinds of input.
|
| 183 |
+
|
| 184 |
+
| Input | Example | Supported |
|
| 185 |
+
|---|---|---|
|
| 186 |
+
| A rough mask, drawn as an outline | an outline around the goat; the model infers that its shadow goes too | **yes, recommended** |
|
| 187 |
+
| The instruction only | "remove the middle goat" | yes |
|
| 188 |
+
|
| 189 |
+
**Drawing the outline.** Use `draw_outline.py` (in this repo): `draw_outline` draws the outline exactly as
|
| 190 |
+
expected by the model, and `outline_prompt` adds the sentence that goes with it. In plain words: a pure
|
| 191 |
+
red ring, `#FF0000` (255, 0, 0), that starts 2 px outside the mask and is 3 px wide (4 px when the
|
| 192 |
+
photo's short side is over 900 px), drawn on the photo at its own size, and the sentence *"The area to
|
| 193 |
+
edit is outlined in red. Remove the red outline as well."* after the instruction. Keep the outlined
|
| 194 |
+
image lossless (PNG), since JPEG shifts the red.
|
| 195 |
+
|
| 196 |
+
### Recommended settings
|
| 197 |
+
|
| 198 |
+
- **Outline and prompt go together.** With an outlined photo, end the instruction with the outline
|
| 199 |
+
sentence (`outline_prompt` adds it).
|
| 200 |
+
- **The mask does not need to be exact.** It works with rough, generous outlines. Include
|
| 201 |
+
the object's shadow or reflection in the mask if they should go too, but keep it off anything that
|
| 202 |
+
should stay (see [Limitations](#limitations)).
|
| 203 |
+
- **Name the object as it appears**, and say which one when there are several similar ones (*"the man
|
| 204 |
+
on the right"*, *"the second cup from the left"*).
|
| 205 |
+
- **Without a mask**, pass the plain photo and the instruction alone. The outline remains the
|
| 206 |
+
recommended way, since it says exactly which object to remove, but if the outline makes the model
|
| 207 |
+
remove too much, the prompt alone can do better.
|
| 208 |
+
- **Keep the strength given in the [Variants](#variants) table**, `true_cfg_scale=1.0` and the
|
| 209 |
+
distillation LoRA at 1.0. Lower strengths reduce texture artifacts and changes outside the mask, but at
|
| 210 |
+
0.5 some removals fail (the object stays, recolored). Above ~1.25 the model also removes neighboring
|
| 211 |
+
objects.
|
| 212 |
+
|
| 213 |
+
## Why this LoRA
|
| 214 |
+
|
| 215 |
+
An object removal edit has two jobs:
|
| 216 |
+
|
| 217 |
+
1. **A good edit where the object was.** The object goes, along with what it causes (its shadow, its
|
| 218 |
+
reflection), and the gap is filled with a believable background.
|
| 219 |
+
2. **No change anywhere else.** The rest of the image stays exactly as it was, unless the removal
|
| 220 |
+
affects it.
|
| 221 |
+
|
| 222 |
+
Models are usually trained for the first, and the second is often lacking. Qwen-Image-2.1 in particular
|
| 223 |
+
changes the rest of the image noticeably, and can even shift it so that the output no longer lines up
|
| 224 |
+
with the input. Both get worse with the few-step distilled model. This LoRA does both jobs: the object
|
| 225 |
+
and its effects go, and the rest of the image stays as it was, lined up with the input.
|
| 226 |
+
|
| 227 |
+
## Examples
|
| 228 |
+
|
| 229 |
+
18 photos from [Unsplash](https://unsplash.com), edited with the **6-step variant** at **~2 MP** in
|
| 230 |
+
outline mode.
|
| 231 |
+
|
| 232 |
+
### Highlights
|
| 233 |
+
|
| 234 |
+
| | Photo | Result |
|
| 235 |
+
|---|---|---|
|
| 236 |
+
| *Remove the person with the umbrella walking across the plaza.* |  |  |
|
| 237 |
+
| *Remove the boathouse and the red canoes on the shore.* |  |  |
|
| 238 |
+
| *Remove the woman in the pink dress.* |  |  |
|
| 239 |
+
| *Remove the phone and the raised arm holding it.* |  |  |
|
| 240 |
+
|
| 241 |
+
<details>
|
| 242 |
+
<summary><b>See all 18 examples, with the outlined inputs</b></summary>
|
| 243 |
+
|
| 244 |
+
<table>
|
| 245 |
+
<tr>
|
| 246 |
+
<th width="25%"></th>
|
| 247 |
+
<th width="25%">Photo</th>
|
| 248 |
+
<th width="25%">Input (outline)</th>
|
| 249 |
+
<th width="25%">Result</th>
|
| 250 |
+
</tr>
|
| 251 |
+
<tr>
|
| 252 |
+
<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>
|
| 253 |
+
<td width="25%"><img src="examples/R1_photo.jpg" width="100%"></td>
|
| 254 |
+
<td width="25%"><img src="examples/R1_outlined.jpg" width="100%"></td>
|
| 255 |
+
<td width="25%"><img src="examples/R1_result.jpg" width="100%"></td>
|
| 256 |
+
</tr>
|
| 257 |
+
<tr>
|
| 258 |
+
<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>
|
| 259 |
+
<td width="25%"><img src="examples/R3_photo.jpg" width="100%"></td>
|
| 260 |
+
<td width="25%"><img src="examples/R3_outlined.jpg" width="100%"></td>
|
| 261 |
+
<td width="25%"><img src="examples/R3_result.jpg" width="100%"></td>
|
| 262 |
+
</tr>
|
| 263 |
+
<tr>
|
| 264 |
+
<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>
|
| 265 |
+
<td width="25%"><img src="examples/Y4_photo.jpg" width="100%"></td>
|
| 266 |
+
<td width="25%"><img src="examples/Y4_outlined.jpg" width="100%"></td>
|
| 267 |
+
<td width="25%"><img src="examples/Y4_result.jpg" width="100%"></td>
|
| 268 |
+
</tr>
|
| 269 |
+
<tr>
|
| 270 |
+
<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>
|
| 271 |
+
<td width="25%"><img src="examples/A8_photo.jpg" width="100%"></td>
|
| 272 |
+
<td width="25%"><img src="examples/A8_outlined.jpg" width="100%"></td>
|
| 273 |
+
<td width="25%"><img src="examples/A8_result.jpg" width="100%"></td>
|
| 274 |
+
</tr>
|
| 275 |
+
<tr>
|
| 276 |
+
<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>
|
| 277 |
+
<td width="25%"><img src="examples/TL_photo.jpg" width="100%"></td>
|
| 278 |
+
<td width="25%"><img src="examples/TL_outlined.jpg" width="100%"></td>
|
| 279 |
+
<td width="25%"><img src="examples/TL_result.jpg" width="100%"></td>
|
| 280 |
+
</tr>
|
| 281 |
+
<tr>
|
| 282 |
+
<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>
|
| 283 |
+
<td width="25%"><img src="examples/A3_photo.jpg" width="100%"></td>
|
| 284 |
+
<td width="25%"><img src="examples/A3_outlined.jpg" width="100%"></td>
|
| 285 |
+
<td width="25%"><img src="examples/A3_result.jpg" width="100%"></td>
|
| 286 |
+
</tr>
|
| 287 |
+
<tr>
|
| 288 |
+
<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>
|
| 289 |
+
<td width="25%"><img src="examples/W7_photo.jpg" width="100%"></td>
|
| 290 |
+
<td width="25%"><img src="examples/W7_outlined.jpg" width="100%"></td>
|
| 291 |
+
<td width="25%"><img src="examples/W7_result.jpg" width="100%"></td>
|
| 292 |
+
</tr>
|
| 293 |
+
<tr>
|
| 294 |
+
<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>
|
| 295 |
+
<td width="25%"><img src="examples/C3_photo.jpg" width="100%"></td>
|
| 296 |
+
<td width="25%"><img src="examples/C3_outlined.jpg" width="100%"></td>
|
| 297 |
+
<td width="25%"><img src="examples/C3_result.jpg" width="100%"></td>
|
| 298 |
+
</tr>
|
| 299 |
+
<tr>
|
| 300 |
+
<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>
|
| 301 |
+
<td width="25%"><img src="examples/H1_photo.jpg" width="100%"></td>
|
| 302 |
+
<td width="25%"><img src="examples/H1_outlined.jpg" width="100%"></td>
|
| 303 |
+
<td width="25%"><img src="examples/H1_result.jpg" width="100%"></td>
|
| 304 |
+
</tr>
|
| 305 |
+
<tr>
|
| 306 |
+
<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>
|
| 307 |
+
<td width="25%"><img src="examples/L8_photo.jpg" width="100%"></td>
|
| 308 |
+
<td width="25%"><img src="examples/L8_outlined.jpg" width="100%"></td>
|
| 309 |
+
<td width="25%"><img src="examples/L8_result.jpg" width="100%"></td>
|
| 310 |
+
</tr>
|
| 311 |
+
<tr>
|
| 312 |
+
<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>
|
| 313 |
+
<td width="25%"><img src="examples/E1_photo.jpg" width="100%"></td>
|
| 314 |
+
<td width="25%"><img src="examples/E1_outlined.jpg" width="100%"></td>
|
| 315 |
+
<td width="25%"><img src="examples/E1_result.jpg" width="100%"></td>
|
| 316 |
+
</tr>
|
| 317 |
+
<tr>
|
| 318 |
+
<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>
|
| 319 |
+
<td width="25%"><img src="examples/F4_photo.jpg" width="100%"></td>
|
| 320 |
+
<td width="25%"><img src="examples/F4_outlined.jpg" width="100%"></td>
|
| 321 |
+
<td width="25%"><img src="examples/F4_result.jpg" width="100%"></td>
|
| 322 |
+
</tr>
|
| 323 |
+
<tr>
|
| 324 |
+
<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>
|
| 325 |
+
<td width="25%"><img src="examples/c9_photo.jpg" width="100%"></td>
|
| 326 |
+
<td width="25%"><img src="examples/c9_outlined.jpg" width="100%"></td>
|
| 327 |
+
<td width="25%"><img src="examples/c9_result.jpg" width="100%"></td>
|
| 328 |
+
</tr>
|
| 329 |
+
<tr>
|
| 330 |
+
<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>
|
| 331 |
+
<td width="25%"><img src="examples/f3_photo.jpg" width="100%"></td>
|
| 332 |
+
<td width="25%"><img src="examples/f3_outlined.jpg" width="100%"></td>
|
| 333 |
+
<td width="25%"><img src="examples/f3_result.jpg" width="100%"></td>
|
| 334 |
+
</tr>
|
| 335 |
+
<tr>
|
| 336 |
+
<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>
|
| 337 |
+
<td width="25%"><img src="examples/c7_photo.jpg" width="100%"></td>
|
| 338 |
+
<td width="25%"><img src="examples/c7_outlined.jpg" width="100%"></td>
|
| 339 |
+
<td width="25%"><img src="examples/c7_result.jpg" width="100%"></td>
|
| 340 |
+
</tr>
|
| 341 |
+
<tr>
|
| 342 |
+
<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>
|
| 343 |
+
<td width="25%"><img src="examples/t5_photo.jpg" width="100%"></td>
|
| 344 |
+
<td width="25%"><img src="examples/t5_outlined.jpg" width="100%"></td>
|
| 345 |
+
<td width="25%"><img src="examples/t5_result.jpg" width="100%"></td>
|
| 346 |
+
</tr>
|
| 347 |
+
<tr>
|
| 348 |
+
<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>
|
| 349 |
+
<td width="25%"><img src="examples/t8_photo.jpg" width="100%"></td>
|
| 350 |
+
<td width="25%"><img src="examples/t8_outlined.jpg" width="100%"></td>
|
| 351 |
+
<td width="25%"><img src="examples/t8_result.jpg" width="100%"></td>
|
| 352 |
+
</tr>
|
| 353 |
+
<tr>
|
| 354 |
+
<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>
|
| 355 |
+
<td width="25%"><img src="examples/t6_photo.jpg" width="100%"></td>
|
| 356 |
+
<td width="25%"><img src="examples/t6_outlined.jpg" width="100%"></td>
|
| 357 |
+
<td width="25%"><img src="examples/t6_result.jpg" width="100%"></td>
|
| 358 |
+
</tr>
|
| 359 |
+
</table>
|
| 360 |
+
|
| 361 |
+
</details>
|
| 362 |
+
|
| 363 |
+
## Limitations
|
| 364 |
+
|
| 365 |
+
- **It can remove more than the outlined object.** Not always, but it happens: the outline weighs more
|
| 366 |
+
than the instruction, so
|
| 367 |
+
when the mask also covers part of something that should stay, that can go too. With two people where
|
| 368 |
+
one partly hides the other, a mask around one sometimes removes both, while the prompt alone removes
|
| 369 |
+
only the right one. Keep the mask tight where other things overlap the object. Lowering the strength
|
| 370 |
+
does not fix this.
|
| 371 |
+
- **Textures in the filled area can look off.** The fill can come out smoother and blurrier than its
|
| 372 |
+
surroundings, miss the photo's grain, or show a regular grid pattern. It stands out more than one
|
| 373 |
+
might expect, and can read as inconsistent focus. The few-step variants' reduced default
|
| 374 |
+
strength (0.7) lessens it without removing it. The strength is a trade-off you can
|
| 375 |
+
tune for your own images: lower gives cleaner textures but weaker removals (at 0.5 some fail, keeping
|
| 376 |
+
or recoloring the object), higher gives firmer removals with more texture artifacts.
|
| 377 |
+
- **Only for removing objects.** Other edits (adding or replacing an object, changing colors or style)
|
| 378 |
+
were never trained and are not expected to work better than with the base model alone.
|
| 379 |
+
- **Plausible, not accurate.** It fills in what should be behind the object, so heavily occluded or
|
| 380 |
+
ambiguous backgrounds can come out plausible rather than accurate.
|
| 381 |
+
|
| 382 |
+
## What this is not
|
| 383 |
+
|
| 384 |
+
- Not a standalone model. It needs the `Qwen/Qwen-Image-2.1` base weights, and the few-step variants
|
| 385 |
+
also need [PrunaAI/P-Q-Image-2.1](https://huggingface.co/PrunaAI/P-Q-Image-2.1).
|
| 386 |
+
- Not a general image editor. It is trained for object removal only.
|
| 387 |
+
- Not a finished release. Expect the weights to change in future versions.
|
| 388 |
+
|
| 389 |
+
## License
|
| 390 |
+
|
| 391 |
+
P-Q-Image-2.1-Remove-Object is a derivative of Qwen-Image-2.1 and follows the
|
| 392 |
+
[Qwen RESEARCH LICENSE AGREEMENT](https://huggingface.co/Qwen/Qwen-Image-2.1/blob/main/LICENSE). Review
|
| 393 |
+
its use restrictions before using or redistributing the adapters. The few-step variants also need
|
| 394 |
+
PrunaAI's distillation LoRA ([PrunaAI/P-Q-Image-2.1](https://huggingface.co/PrunaAI/P-Q-Image-2.1)),
|
| 395 |
+
whose own terms apply.
|
| 396 |
+
|
| 397 |
+
Qwen is licensed under the Qwen RESEARCH LICENSE AGREEMENT, Copyright (c) 2026 Hangzhou Tongyi
|
| 398 |
+
Laboratory Technology Co., Ltd. All Rights Reserved.
|
| 399 |
+
|
| 400 |
+
The example photos are from Unsplash, under the [Unsplash License](https://unsplash.com/license): free
|
| 401 |
+
to copy, modify and use, commercial use included, without asking or crediting the photographer (credits
|
| 402 |
+
are given anyway). Not allowed: selling a photo without significant modification, or compiling Unsplash
|
| 403 |
+
photos into a similar or competing service. Each photo's page was checked on 2026-11-04 and read "Free
|
| 404 |
+
to use under the Unsplash License", and again on 2026-11-10 for the final set.
|
| 405 |
+
|
| 406 |
+
> **The Unsplash License does not cover people or brands in a photo.** Per the
|
| 407 |
+
> [Unsplash Terms](https://unsplash.com/terms), trademarks, logos and brands, and recognizable people,
|
| 408 |
+
> may need the permission of their owner or of the person, depending on the use. People appear in
|
| 409 |
+
> several examples, from behind or as silhouettes, without a readable face. The night plaza photo shows
|
| 410 |
+
> a small lit shop sign ("NAILS & RESORT") in the background, an incidental business name. The chapel,
|
| 411 |
+
> cottage and boathouse photos show buildings that are likely identifiable (a Swiss chapel, a Glen Coe
|
| 412 |
+
> cottage, the Lake Louise boathouse), shot from public land and removed in the result. No other example
|
| 413 |
+
> shows a readable brand.
|
| 414 |
+
> This is a record of what the licenses say, not legal advice.
|
| 415 |
+
|
| 416 |
+
## What's next?
|
| 417 |
+
|
| 418 |
+
- **Use P-Q-Image-2.1-Remove-Object to remove objects from photos with Qwen-Image-2.1 in a few steps.**
|
| 419 |
+
- Compress your own models with [Pruna](https://github.com/PrunaAI/pruna) and give us a ⭐️ for more efficiency!
|
| 420 |
+
- 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).
|
| 421 |
+
|
| 422 |
+
<style>
|
| 423 |
+
.model-button {
|
| 424 |
+
display: inline-flex;
|
| 425 |
+
flex-direction: row;
|
| 426 |
+
justify-content: center;
|
| 427 |
+
align-items: center;
|
| 428 |
+
gap: 8px;
|
| 429 |
+
|
| 430 |
+
padding: 8px 20px;
|
| 431 |
+
border: none;
|
| 432 |
+
border-radius: 8px;
|
| 433 |
+
|
| 434 |
+
background: #9334e9;
|
| 435 |
+
color: #ffffff;
|
| 436 |
+
|
| 437 |
+
font-size: 14px;
|
| 438 |
+
font-weight: 400;
|
| 439 |
+
line-height: 1;
|
| 440 |
+
text-decoration: none;
|
| 441 |
+
white-space: nowrap;
|
| 442 |
+
cursor: pointer;
|
| 443 |
+
|
| 444 |
+
box-sizing: border-box;
|
| 445 |
+
overflow: visible;
|
| 446 |
+
opacity: 1;
|
| 447 |
+
}
|
| 448 |
+
</style>
|
| 449 |
+
|
| 450 |
+
<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>
|
assets/P-Q-Image-2.1-Remove-Object.png
ADDED
|
Git LFS Details
|
draw_outline.py
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Draw the red outline the LoRA expects around the object to remove.
|
| 2 |
+
|
| 3 |
+
python draw_outline.py photo.jpg mask.png photo_outlined.png
|
| 4 |
+
|
| 5 |
+
The mask is white (> 127) on the object, at any size (it is resized to the photo with nearest
|
| 6 |
+
neighbour). The outline is a pure red ring (255, 0, 0) starting 2 px outside the mask, 3 px wide,
|
| 7 |
+
or 4 px when the photo's short side is over 900 px: the style the model expects. Save the
|
| 8 |
+
result losslessly (png) if you keep it, so the red stays pure.
|
| 9 |
+
|
| 10 |
+
Needs numpy, opencv-python(-headless) and pillow.
|
| 11 |
+
"""
|
| 12 |
+
|
| 13 |
+
from __future__ import annotations
|
| 14 |
+
|
| 15 |
+
import sys
|
| 16 |
+
|
| 17 |
+
import cv2
|
| 18 |
+
import numpy as np
|
| 19 |
+
from PIL import Image
|
| 20 |
+
|
| 21 |
+
RED = (255, 0, 0)
|
| 22 |
+
OUTLINE_SUFFIX = "The area to edit is outlined in red. Remove the red outline as well."
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
def _within(mask: np.ndarray, r: float) -> np.ndarray:
|
| 26 |
+
"""Pixels within distance r of the mask (Euclidean distance transform)."""
|
| 27 |
+
dist = cv2.distanceTransform((~mask).astype(np.uint8), cv2.DIST_L2, 5)
|
| 28 |
+
return dist <= r
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
def outline_ring(mask: np.ndarray, width: int | None = None, gap: int = 2) -> np.ndarray:
|
| 32 |
+
"""Boolean ring from `gap` to `gap + width` px outside the boolean mask."""
|
| 33 |
+
h, w = mask.shape
|
| 34 |
+
width = width or (3 if min(h, w) <= 900 else 4)
|
| 35 |
+
return _within(mask, gap + width) & ~_within(mask, gap)
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
def draw_outline(photo: Image.Image, mask: Image.Image) -> Image.Image:
|
| 39 |
+
"""The photo with the mask's outline drawn in pure red. An empty mask returns the photo."""
|
| 40 |
+
photo = photo.convert("RGB")
|
| 41 |
+
m = np.array(mask.convert("L").resize(photo.size, Image.NEAREST)) > 127
|
| 42 |
+
out = np.array(photo)
|
| 43 |
+
if m.any():
|
| 44 |
+
out[outline_ring(m)] = RED
|
| 45 |
+
return Image.fromarray(out)
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
def outline_prompt(instruction: str) -> str:
|
| 49 |
+
"""The instruction followed by the sentence the model expects with outlined images."""
|
| 50 |
+
return f"{instruction.rstrip()} {OUTLINE_SUFFIX}"
|
| 51 |
+
|
| 52 |
+
|
| 53 |
+
if __name__ == "__main__":
|
| 54 |
+
if len(sys.argv) != 4:
|
| 55 |
+
sys.exit(__doc__)
|
| 56 |
+
draw_outline(Image.open(sys.argv[1]), Image.open(sys.argv[2])).save(sys.argv[3])
|
examples/A3_outlined.jpg
ADDED
|
Git LFS Details
|
examples/A3_photo.jpg
ADDED
|
Git LFS Details
|
examples/A3_result.jpg
ADDED
|
Git LFS Details
|
examples/A8_outlined.jpg
ADDED
|
Git LFS Details
|
examples/A8_photo.jpg
ADDED
|
Git LFS Details
|
examples/A8_result.jpg
ADDED
|
Git LFS Details
|
examples/C3_outlined.jpg
ADDED
|
Git LFS Details
|
examples/C3_photo.jpg
ADDED
|
Git LFS Details
|
examples/C3_result.jpg
ADDED
|
Git LFS Details
|
examples/E1_outlined.jpg
ADDED
|
Git LFS Details
|
examples/E1_photo.jpg
ADDED
|
examples/E1_result.jpg
ADDED
|
examples/F4_outlined.jpg
ADDED
|
Git LFS Details
|
examples/F4_photo.jpg
ADDED
|
Git LFS Details
|
examples/F4_result.jpg
ADDED
|
Git LFS Details
|
examples/H1_outlined.jpg
ADDED
|
Git LFS Details
|
examples/H1_photo.jpg
ADDED
|
Git LFS Details
|
examples/H1_result.jpg
ADDED
|
Git LFS Details
|
examples/L8_outlined.jpg
ADDED
|
Git LFS Details
|
examples/L8_photo.jpg
ADDED
|
Git LFS Details
|
examples/L8_result.jpg
ADDED
|
Git LFS Details
|
examples/R1_outlined.jpg
ADDED
|
Git LFS Details
|
examples/R1_photo.jpg
ADDED
|
Git LFS Details
|
examples/R1_result.jpg
ADDED
|
Git LFS Details
|
examples/R3_outlined.jpg
ADDED
|
Git LFS Details
|
examples/R3_photo.jpg
ADDED
|
Git LFS Details
|
examples/R3_result.jpg
ADDED
|
Git LFS Details
|
examples/TL_outlined.jpg
ADDED
|
Git LFS Details
|
examples/TL_photo.jpg
ADDED
|
Git LFS Details
|
examples/TL_result.jpg
ADDED
|
Git LFS Details
|
examples/W7_outlined.jpg
ADDED
|
Git LFS Details
|
examples/W7_photo.jpg
ADDED
|
Git LFS Details
|
examples/W7_result.jpg
ADDED
|
Git LFS Details
|
examples/Y4_outlined.jpg
ADDED
|
Git LFS Details
|
examples/Y4_photo.jpg
ADDED
|
examples/Y4_result.jpg
ADDED
|
examples/c7_outlined.jpg
ADDED
|
Git LFS Details
|
examples/c7_photo.jpg
ADDED
|
Git LFS Details
|
examples/c7_result.jpg
ADDED
|
Git LFS Details
|
examples/c9_outlined.jpg
ADDED
|
Git LFS Details
|
examples/c9_photo.jpg
ADDED
|
Git LFS Details
|
examples/c9_result.jpg
ADDED
|
Git LFS Details
|
examples/f3_outlined.jpg
ADDED
|
Git LFS Details
|
examples/f3_photo.jpg
ADDED
|
Git LFS Details
|