Skip to main content
Agent skill

Image Inpaint Region

Local circular region inpainting with LaMa (IOPaint). Uses IOPaint default InpaintRequest and mask handling. Use for local region inpaint / local region repair / inpaint when circle center and radius cx,cy,r are known.

Get started

Get the complete skill folder, including its scripts and reference files.

When to use this skill

Use Image Inpaint Region when an AI agent needs a reusable SKILL.md workflow for this job: Local circular region inpainting with LaMa (IOPaint). Uses IOPaint default InpaintRequest and mask handling. Use for local region inpaint / local region repair / inpaint when circle center and radius cx,cy,r are known.

When not to use it

Skip Image Inpaint Region when the task is outside the writing category, or when a more specific skill in this directory already covers the same workflow with clearer triggers.

How to install

Where will you use it?

Install scope
Claude Code folder setup
mkdir -p ~/.claude/skills/image-inpaint-region
# Save SKILL.md to ~/.claude/skills/image-inpaint-region/SKILL.md
  1. Claude Code personal install: place the skill and its bundled files at ~/.claude/skills/image-inpaint-region/SKILL.md. For a shared project, commit the folder at .claude/skills/image-inpaint-region/ instead.
  2. Current Claude Code detects SKILL.md changes in watched directories during the session. If you just created a top-level skills directory, run /reload-skills. Check that the skill is listed before testing its trigger.
  3. For Claude chat or Cowork in the Desktop app, manage uploaded skills in Customize > Skills; copying files into a local Claude Code folder is not a Desktop install. Other agents may use different install locations.

Full install guide for Claude, Cursor, and Codex →

Try a starter prompt

After installing the skill, paste this starter prompt into your agent to verify it triggers on a small task.

Starter prompt
Use the Image Inpaint Region skill for this task: Use Image Inpaint Region when this documented workflow matches the task. Confirm any required inputs or files before making changes.

What supports this recommendation?

70/100 provisional content score. This measures documentation, practical detail and source signals. It is not a measured task success rate or a security certification.

Documentation
77/100
Practical detail
68/100
Source evidence
61/100
Source signals
72/100
Model compatibility evidence
  • claudeuntested

    No model-specific signal or recorded compatibility test was found.

  • chatgptuntested

    No model-specific signal or recorded compatibility test was found.

  • geminiuntested

    No model-specific signal or recorded compatibility test was found.

  • copilotuntested

    No model-specific signal or recorded compatibility test was found.

  • llamauntested

    No model-specific signal or recorded compatibility test was found.

  • perplexityuntested

    No model-specific signal or recorded compatibility test was found.

  • mistraluntested

    No model-specific signal or recorded compatibility test was found.

  • grokuntested

    No model-specific signal or recorded compatibility test was found.

Inferred compatibility is based on content signals. Check the app, its available tools and setup requirements before running a skill.

What this skill does

# Image Inpaint Region (LaMa)

**Local circular region inpainting** with **[IOPaint](https://github.com/Sanster/IOPaint) LaMa**. Builds a circular mask from `--region cx,cy,r`, then runs the same inference path as `iopaint run` / the IOPaint API.

**Both `--image` and `--region cx,cy,r` are required.**

## Rules

When this skill applies, read and follow [skill-dependency-manager](../skill-dependency-manager.md) — run scripts as documented, install missing tools into `.dependency/`.

- Run `inpaint.py` through the **`iopaint` manifest entry** (`.dependency/iopaint/.venv/`). Never use host `python`, `py`, `python3`, or any interpreter outside `.dependency/`. - Do not hand-write equivalent inpaint commands — use the bundled script. - **Single file only.** Pass one image with `--image`; directories are not supported. - **Require region first.** If `--region cx,cy,r` is missing, inspect the image (or ask the user) before running. - **Use IOPaint defaults** for inference config unless the user explicitly asks otherwise — do not invent custom mask blur, compositing, or hd_strategy overrides in the script. - Pass the input path as-is. Output goes to `<image-dir>/image-inpaint-region/` by default — no path rewriting. - **Never overwrite source files.** Output lands in `image-inpaint-region/` or `--output`.

## Setup (first run)

IOPaint needs **Python 3.11** and PyTorch. From project root:

```bash .dependency/python-3.11/python.exe -m venv .dependency/iopaint/.venv .dependency/iopaint/.venv/Scripts/python.exe -m pip install torch torchvision --index-url https://download.pytorch.org/whl/cu118 .dependency/iopaint/.venv/Scripts/python.exe -m pip install iopaint ```

CPU-only: skip the CUDA torch line and `pip install iopaint` (pulls CPU torch). Use `bin/python` on Unix.

Register in `.dependency/manifest.json`:

```json "iopaint": { "populated": true, "bin": ".dependency/iopaint/.venv/Scripts/python.exe" } ```

LaMa weights (`big-lama.pt`) download on first run.

## Quick Start

**Both `--image` and `--region` are required:**

```bash # image/foo.png → image/image-inpaint-region/foo.png # center (148, 248), radius 48 .dependency/iopaint/.venv/Scripts/python.exe .ai/image-inpaint-region/inpaint.py --image image/foo.png --region 148,248,48 ```

GPU inference:

```bash .dependency/iopaint/.venv/Scripts/python.exe .ai/image-inpaint-region/inpaint.py --image image/foo.png --region 148,248,48 --device cuda ```

Custom output path:

```bash .dependency/iopaint/.venv/Scripts/python.exe .ai/image-inpaint-region/inpaint.py --image image/foo.png --region 148,248,48 -o image/foo_inpainted ```

## How it works

1. Open the image as RGB (same as `iopaint` batch processing). 2. Draw a filled circle mask from `--region cx,cy,r`. 3. Binarize mask at **127** (same as `iopaint.batch_processing` / API). 4. Call `ModelManager` with **`InpaintRequest()` defaults**. 5. Write PNG via `pil_to_bytes(..., "png", 100, ...)`.

## IOPaint defaults used

These come from `InpaintRequest()` and `iopaint run` — the script does not override them:

| Setting | Default | Notes | |---------|---------|-------| | `--model` | `lama` | Same as `iopaint run` | | `--device` | `cpu` | Same as `iopaint run` / `start`; use `--device cuda` when GPU is available | | `hd_strategy` | `Crop` | LaMa erase-model preprocessing | | `hd_strategy_crop_trigger_size` | `800` | Crop when long side > 800 px | | `hd_strategy_crop_margin` | `128` | Margin around mask for crop strategy | | Mask threshold | `127` | `>= 127 → 255`, else `0` |

The skill only adds `--region cx,cy,r` so you do not need a separate mask file.

## Options

| Option | Default | Notes | |--------|---------|-------| | `--image` | **Required** | Single supported image file | | `--region` | **Required** | `cx,cy,r` — center x, center y, radius in pixels | | Output | `<image-dir>/image-inpaint-region/<name>.png` | Use `-o` / `--output` for custom file or directory | | `--model` | `lama` | IOPaint model name | | `--device` | `cpu` | `cpu` or `cuda` (falls back via IOPaint `check_device`) |

Supported inputs: `.png`, `.jpg`, `.jpeg`, `.webp`, `.gif`, `.bmp`, `.tif`, `.tiff`, `.avif`, `.ico`.

## Agent Workflow

1. **Confirm source** — user path only; do not copy into `image/` or use chat attachment cache. 2. **Confirm region** — inspect the image and determine circle center `(cx, cy)` and radius `r` before running. 3. **One file per run** — process one image, verify the result, then repeat for additional files if needed. 4. **Inspect** — check the inpainted area; leftover content → larger `r`; nearby art eaten → smaller `r` or move center. 5. **Revert** — delete the output file or `git restore`; sources are never modified.

## Agent Notes

1. Use the bundled script, not hand-written IOPaint CLI with separate mask files unless the user already has a mask image. 2. Missing iopaint venv → populate `.dependency/` per skill-dependency-manager, retry same command. 3. **Do not copy, move, or replace the source with inpainted output** — tell the user where the output file is. 4. For full IOPaint UI / brush mask editing, use the upstream `iopaint start` workflow instead.

## Troubleshooting

| Issue | Fix | |-------|-----| | `iopaint` missing / not populated | Follow **Setup**; update manifest | | Missing `--region` | Inspect image; both `--image` and `--region cx,cy,r` are required | | Invalid `--region` | Must be three numbers: center x, center y, radius (> 0) | | Directory passed to `--image` | Run once per file; this skill accepts image files only | | Output already exists | Delete the existing output or choose a different `-o` path | | CUDA not available | IOPaint falls back to `cpu` via `check_device` | | Target still visible | Increase radius `r` in `--region` | | Nearby art eaten | Decrease radius `r`; adjust center `(cx, cy)` | | Wrong interpreter | Must use `.dependency/iopaint/.venv/Scripts/python.exe` |

## CLI

Copy-paste commands: [cli/image-inpaint-region.md](../../../cli/image-inpaint-region.md)

## Related

- Engine: [Sanster/IOPaint](https://github.com/Sanster/IOPaint) (LaMa) - Upstream batch CLI: `iopaint run --model lama --device cpu --image ... --mask ... --output ...`

Intended uses

  • Use Image Inpaint Region when this documented workflow matches the task.

Implementation notes

  • Review the source instructions and adapt inputs before running the workflow.

Try it, then tell us how it went

A copied prompt does not tell us whether the task worked. Report your result after checking the output. We collect your tool and outcome, never your files or prompt.