agentleFS
nc9nc9/skills/remove-background/SKILL.md

remove-background

Skill4 starsChanged 54 days agoMITView on GitHub

Remove image backgrounds locally with the BiRefNet segmentation model, writing a transparent PNG. Use when asked to remove or cut out a background, isolate a subject, or make a transparent version of a photo. No API key.

4 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

1 rule. 0 are common, 0 are distinctive, and 1 is very specific to this project.

  • 0

    Common

    Most of the 4 edited versions we read keep these.

  • 0

    Distinctive

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    No API key. First run is expensive: uv builds a ~790 MB environment (torch, torchvision, transformers, timm, kornia) and downloads ~445 MB …

    line 13

“Common” is measured: kept by at least 6 in 10 of the 4 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Remove Background

Local BiRefNet segmentation (ZhengPeng7/BiRefNet) on CUDA, MPS or CPU. Output is always RGBA PNG.

Requirements

No API key. First run is expensive: uv builds a ~790 MB environment (torch, torchvision, transformers, timm, kornia) and downloads ~445 MB of model weights to ~/.cache/huggingface. Both are cached; later runs start in seconds.

Command

./scripts/remove_background <input_image> [options]   # single command, no subcommand

Options

OptionDescription
-o, --outputOutput path (default {name}_nobg.png)
-d, --deviceForce cuda | mps | cpu (default auto: CUDA > MPS > CPU)
-c, --cropCrop to the foreground bounding box
-p, --paddingPadding around the crop, px (default 0)
-f, --formatjson (default) or table

Output

JSON: input, output, device, original_size, output_size, cropped, model, plus crop_box when a box was found.

Gotchas

  • The saved file is always PNG whatever extension -o gets; -f is the stdout report format, not the image format.
  • Inference resizes to 1024x1024 and scales the mask back up, so large images lose edge detail.
  • cropped echoes the -c flag, not whether a crop happened. A fully opaque image yields no bbox: crop_box is absent and nothing is cropped.
  • MPS falls back to CPU for unsupported ops (PYTORCH_ENABLE_MPS_FALLBACK=1 is set); use -d cpu if MPS misbehaves.

Examples

./scripts/remove_background photo.jpg
./scripts/remove_background photo.jpg -c -p 20 -o cutout.png
./scripts/remove_background photo.jpg -d cpu -f table

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.