CommunityImagemgithub.com

remove-people

Removes foreground and background people (and their cast shadows/belongings) from photographs while preserving maximum native resolution, sharpness, framing, color grading, metadata (EXIF/ICC), and untouched pixels using localized multi-patch inpainting, sub-pixel alignment, color-gain matching, and tight feathered compositing.

O que é remove-people?

remove-people is a Claude Code agent skill that removes foreground and background people (and their cast shadows/belongings) from photographs while preserving maximum native resolution, sharpness, framing, color grading, metadata (EXIF/ICC), and untouched pixels using localized multi-patch inpainting, sub-pixel alignment, color-gain matching, and tight feathered compositing.

Funciona com~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/0xDAFE/agent-skills/tree/HEAD/remove-people

Installed? Explore more Imagem skills: steipete/songsee, affaan-m/frontend-design, mattpocock/improve-codebase-architecture · View all 6 →

Perguntar na sua IA favorita

Abre um novo chat com esta habilidade de agente já pré-carregada.

Documentação

High-Resolution People Removal (remove-people)

Use this skill whenever a user asks to remove people (or similar unwanted subjects) from a photograph without altering anything else, especially when preserving high/native resolution (e.g., 12–60+ MP camera exports), original framing, color grading, and pixel-level fidelity outside the edited regions.

Core principle: Never run a full high-resolution photograph directly through a ~1 MP image generator and return that output. Full-frame generation degrades resolution, shifts structural geometry (horizons, curbs, lines), and alters global color/grain. Instead, extract native-resolution localized patches around the people, inpaint each patch at ≥1× native pixel density, sub-pixel align and color-match each patch, and composite only the tight feathered people + shadow masks back onto the untouched original.

Bundled Helper Script

Retrieve scripts/patch_toolkit.py using get_skill_resources (or run it directly from the skill directory). It depends only on Pillow (PIL) and provides five subcommands:

  • inspect <image> — checks dimensions, megapixels, EXIF orientation, and metadata, and flags likely uploader downscaling (<= 1024 px).
  • grid <image> <out.png> [--box x0,y0,x1,y1] [--step 100] [--scale 1.0] — renders a labeled coordinate grid for accurate patch and mask coordinates.
  • crop <image> <out.png> --box x0,y0,x1,y1 — extracts a native-resolution, EXIF-oriented patch crop.
  • align <orig_crop> <gen_crop> <out_aligned.png> [--ref x0,y0,x1,y1 ...] [--color-ref x0,y0,x1,y1 ...] [--diff out_diff.png] — finds optimal (dw, dh, dx, dy) alignment on unoccluded reference regions, applies subtle per-channel color-gain matching, and outputs an amplified 4× diff map.
  • composite <orig_image> <out_image> --config composite.json [--diff out_diff.png] — composites tight feathered masks (with optional hard-edge foreground occluder protection) onto the untouched original, preserves EXIF/ICC/DPI, and prints the exact-zero-change pixel percentage.

Step-by-Step Workflow

Step 1: Inspect the Source File & Catch Uploader Downscaling

  1. View the image with view_file and run:
    python3 patch_toolkit.py inspect <input_image>
    
  2. Check for attachment downscaling: Chat uploaders frequently downscale raw image attachments to <= 1024 px on the long edge and strip EXIF.
    • If the user expects high-resolution output (e.g. 12–20+ MP) and the staged file is <= 1024 px, tell them immediately and ask them to upload the original inside a .zip archive (which bypasses image upload resizing).
    • If the input is a .zip, extract it, clean up macOS __MACOSX artifacts if present, and verify the extracted dimensions.
  3. Always normalize orientation consistently via ImageOps.exif_transpose (handled automatically by patch_toolkit.py) before measuring coordinates.

Step 2: Map Every Person, Shadow, and Occluder on a Coordinate Grid

  1. Generate a labeled coordinate grid over the affected area (or full image if people are scattered):
    python3 patch_toolkit.py grid <input_image> scratch/grid.png --box x0,y0,x1,y1 --step 100 --scale 0.5
    
  2. View scratch/grid.png and inventory:
    • Every foreground person and background person (including tiny distant figures and partial limbs/clothing peeking between objects).
    • Cast shadows on the ground/tiles/walls belonging to those people, plus personal belongings they are holding or sitting on.
    • Hard foreground occluders adjacent to people (iron gates, sign edges, pillars, railings, window frames) that must stay razor-sharp and untouched.
    • Clean unoccluded gaps between groups of people where separate patches can terminate without ever overlapping masked content.

Step 3: Plan Native-Resolution, Non-Splitting Patches

Design one or more rectangular crop boxes around the people following these rules:

  1. Match native pixel density (>= 1.0× oversampling):
    • generate_image typically outputs ~1024–1264 px on the long edge (1200×896 for 4:3, 1264×848 for 3:2, 1024×1024 for 1:1).
    • Size each crop box to ~800–1000 px on the long edge (in native photo pixels) matching a supported generate_image AspectRatio (1:1, 4:3, 3:2, 3:4, 2:3).
    • This guarantees the inpainted pixels are 1.1×–1.3× oversampled relative to the native image—zero blur or resolution drop at 100% zoom.
    • For low-resolution inputs (< 1000 px wide), a single localized crop around the people band is sufficient.
  2. Never split a foreground person across two patches: Every person (or tightly overlapping crowd cluster) should sit comfortably inside a single patch.
  3. Include strong geometric anchors on all sides: Leave >= 10–20% unoccluded margin above, below, and beside the people (tile seams, curbs, horizons, foliage, brickwork, frames) so the generator preserves exact perspective and alignment has crisp reference zones.
  4. Extract crops:
    python3 patch_toolkit.py crop <input_image> scratch/patch1_orig.png --box x0,y0,x1,y1
    

Step 4: Inpaint Each Patch with Strict Fidelity Constraints

Invoke generate_image (in parallel across patches) passing ImagePaths: [".../scratch/patchN_orig.png"] and the exact matching AspectRatio.

Craft each prompt with these explicit requirements:

  • Enumerate the specific people, background figures, and cast shadows present in that patch.
  • Specify exactly what natural background should replace them (e.g., continuing exact perspective tile joints, curb height, fallen leaves, tree trunks, brickwork).
  • Explicitly forbid moving, shifting, cropping, recoloring, relighting, softening, or adding new objects (no invented pillars, signs, benches, etc.).
  • Instruct the model to keep lighting, contrast, sharpness, and photographic grain identical to the original crop.

Step 5: Sub-Pixel Alignment, Diff Verification & Color-Gain Matching

Generative outputs often have slight aspect rounding (e.g., 1200×896 vs exact 4:3 1200×900, causing a ~4 px height/offset shift) and tiny ~0.5–1.5% brightness drift.

  1. Run align on each patch using unoccluded --ref boxes (e.g., clean pavement below and clean foliage/sky above the people) and an unoccluded --color-ref box (typically smooth neutral ground/pavement/wall where seams would be most visible):
    python3 patch_toolkit.py align scratch/patch1_orig.png <gen_patch1.jpg> scratch/patch1_aligned.png \
      --ref x0,y0,x1,y1 --ref x0,y0,x1,y1 \
      --color-ref x0,y0,x1,y1 \
      --diff scratch/patch1_diff.png
    
  2. Inspect the 4× diff map (scratch/patchN_diff.png) via view_file:
    • Pass criterion: Structural lines (tile seams, curbs, horizons, branches, frames) outside the people are nearly black (mean abs diff typically <= 6–8 on smooth surfaces), and only the people + their cast shadows light up brightly.
    • Fail criterion: If structural lines shifted significantly or the generator hallucinated unwanted objects, regenerate that patch with tighter anchor instructions before proceeding. Never composite a geometrically shifted patch.

Step 6: Build Tight Feathered Masks & Composite onto the Untouched Original

  1. Create a scratch/composite.json config defining each patch's global box, aligned_path, tight shapes (in global image coordinates covering only the people + cast shadows), feather radius (typically ~3–5 px for ~1K images, ~8–12 px for 15–30 MP images), and optional protect_polygons + protect_feather (1–3 px) to keep adjacent hard foreground occluders (gates, signs, poles) 100% untouched:
    {
      "patches": [
        {
          "box": [540, 3720, 1500, 4440],
          "aligned_path": "/abs/path/scratch/patch1_aligned.png",
          "feather": 10,
          "protect_feather": 2.5,
          "shapes": [
            {"type": "rounded_rect", "box": [648, 3835, 845, 4345], "radius": 24},
            {"type": "rounded_rect", "box": [815, 3955, 1115, 4195], "radius": 20}
          ],
          "protect_polygons": [
            [[540, 3720], [663, 3720], [652, 4440], [540, 4440]]
          ]
        }
      ]
    }
    
    Supported shape types: rounded_rect, rect, ellipse, polygon.
  2. Whenever possible, keep each patch's masked islands separated across clean unoccluded gaps so adjacent patches never fight over conflicting hallucinated backgrounds. If two patches must share a masked region, cross-fade smoothly in an overlap zone where both patches match.
  3. Run the composite:
    python3 patch_toolkit.py composite <input_image> <output_image> \
      --config scratch/composite.json --quality 96 \
      --diff scratch/final_diff.png
    
    • Preserves original resolution, EXIF, DPI, and ICC color profile (subsampling=0 for JPEG).

Step 7: 1:1 Native Zoom & Diff QA Before Delivery

Always visually inspect before delivering to the user:

  1. Crop 1:1 native-resolution views of every edited region (around 600–900 px wide) and inspect them with view_file for:
    • Any missed background person, shoe, limb, or ghost cast shadow.
    • Any visible brightness/color transition seam across flat tiles, walls, or sky.
    • Any misalignment or kink in straight lines (tile joints, curbs, railings).
    • Any bleed or halo over adjacent protected foreground edges.
  2. Inspect scratch/final_diff.png (8× amplified) and verify the reported Exact-zero-change pixels percentage (typically >85–95% for street/architecture photos) confirms literally nothing outside the people + shadows changed.
  3. If any minor defect appears (e.g., a stray cast shadow outside the mask or a slightly tight mask edge), adjust composite.json and re-run composite in seconds—no need to re-run generate_image.

Step 8: Deliver Clearly

  • Save the final full-resolution image in the workspace alongside the original (e.g., <stem>_no_people.<ext>).
  • Copy the final image (and optionally a zoomed comparison strip of the edited zone) into the conversation artifact directory and present it in a clean user-facing markdown artifact so the user can inspect the true composited result directly (rather than only intermediate generate_image patches).
  • State the exact output resolution, preserved metadata, and untouched-pixel percentage concisely.

Habilidades Relacionadas