linoyts's picture
linoyts HF Staff
Text-guided removal: auto-generate the mask with SAM 3
83ed814 verified
|
Raw History Blame
3.41 kB
metadata
title: P-Q-Image-2.1-Remove-Object
emoji: 🧽
colorFrom: indigo
colorTo: indigo
sdk: gradio
sdk_version: 6.30.0
python_version: '3.12'
app_file: app.py
pinned: false
hf_oauth: true
hf_oauth_scopes:
  - inference-api
  - write-repos
short_description: Remove the object you point at, and nothing else
models:
  - PrunaAI/P-Q-Image-2.1-Remove-Object
  - PrunaAI/P-Q-Image-2.1-Remove-Object-Comfy
  - PrunaAI/P-Q-Image-2.1
  - Qwen/Qwen-Image-2.1
license: other
license_name: qwen-research
license_link: https://huggingface.co/Qwen/Qwen-Image-2.1/blob/main/LICENSE

P-Q-Image-2.1-Remove-Object

A LoRA for Qwen/Qwen-Image-2.1 that removes the object you point at and leaves the rest of the photo as it was. Paint a rough mask over the object, say what it is, and it is replaced with what would be behind it, its shadow or reflection included.

  • / — Studio (gr.Server API + custom UI, Pruna design, dark and light themes): paint the mask with a brush and eraser, or let SAM 3 find it from the instruction, write the instruction, pick a variant; the card's 18 examples load photo, mask and instruction in one click; before/after split view and run history.
  • /workflow — Workflow canvas (gr.Workflow): photo + mask + instruction into a removal node, chained into a second removal. To change the starter graph, edit workflow.json.
Variant Runs on Steps Strength Working size
6-step (default) PrunaAI/P-Q-Image-2.1 6-step v0.2 6 0.7 photo's area, up to ~2 MP
8-step PrunaAI/P-Q-Image-2.1 8-step v0.1 8 0.7 photo's area, up to ~2 MP
base the base model alone 40 1.0 photo's area, up to ~1 MP

The mask is drawn as the red outline the model expects (draw_outline.py, from the model repo), and the matching sentence is added to the instruction. With no mask, the instruction alone says what to remove. No CFG.

Text-guided masks. Instead of painting, write the instruction and press Auto-generate mask from instruction: SAM 3 masks every object the instruction names (text_mask.py; "the phone on the right" picks one), and the mask lands on the canvas to touch up. A run with nothing painted does this by itself, in the same GPU call as the removal, and falls back to the instruction alone if SAM 3 finds nothing. facebook/sam3 is gated: the Space needs an HF_TOKEN secret with access, and without one it runs with painted masks only.

The remove API endpoint takes source and mask (uploaded file paths; mask white = remove, may be empty), instruction, variant, seed, randomize and auto_mask (with no mask, find it from the instruction with SAM 3; the mask found comes back as mask_data). The find_mask endpoint takes source and text and returns the SAM 3 mask as mask_data.

Example photos are from Unsplash (credits on the model card); the masks are the card's own, except c9's, rebuilt from its outlined input.