DEV Community

Cover image for Agents Can Remove Image Backgrounds Locally — No Cloud API Required

Agents Can Remove Image Backgrounds Locally — No Cloud API Required

Are you building an agent, or are you the agent that should remove image backgrounds — product shots, portraits, uploads from chat — without wiring a separate cloud API or hoping the model “edits” pixels in prose?

Skillware has a registry skill for that: creative/bg_remover. Load it once, call execute() from any agent loop. Same skill, zero adapter rewrites across Gemini, Claude, OpenAI, DeepSeek, or Ollama.

Shipped in Skillware v0.4.5. Authored by @AyushSrivastava1818.


Skillware in a nutshell

Skillware is an open registry of installable agent capabilities — deterministic Python skills any compatible runtime can load.

Each skill is a bundle:

  • skill.pyexecute() returns JSON; no LLM inside the handler
  • instructions.md — when the model should call the tool
  • manifest.yaml — schema, constitution, issuer, requirements
  • Tests and catalog docs — shipped in the wheel

You SkillLoader.load_skill("category/skill_name"), adapt for your provider, pass instructions as system context, wire tool calls to execute(). The model decides when; the skill decides how, predictably, every time.

Docs: skillware.site/documentation · agent loops


creative/bg_remover: what it does

Registry ID: creative/bg_remover

Catalog: bg_remover.md

Site: skillware.site/skills/bg-remover

Local background removal via rembg. Pass Base64 image data or a local file path; get a transparent PNG back with width, height, and model_used metadata.

Input Purpose
image Base64 still image (chat / upload handoff)
input_path Path to a local file
output_path Optional — write PNG to disk
model isnet-general-use (default), u2net_human_seg for people, others
alpha_matting Finer edges (hair, fur) — slower when enabled

No cloud credentials for the skill itself. Processing stays on your machine. Constitution is explicit: still images only, local-first, no storing image bytes, structured errors on bad input.

First run: rembg downloads an ONNX model (~176 MB for isnet-general-use) to the local cache. Later runs reuse it and are much faster. Provider API keys are only for the LLM loop around the skill — not for removal.


Agent vs skill

Agent (LLM + your loop) Skill
Parses “remove the background from this product photo” Runs rembg on bytes or a file path
Chooses Base64 vs path, model, output location Returns image_base64 or writes output_path
Shows the result to the user Same input → same deterministic output

The model does not paint transparency. The skill does.


Try it: install and direct execute

pip install "skillware[creative_bg_remover]"
Enter fullscreen mode Exit fullscreen mode
from skillware.core.loader import SkillLoader

bundle = SkillLoader.load_skill("creative/bg_remover")
skill = bundle["class"]()

result = skill.execute({
    "input_path": "product.png",
    "output_path": "product_no_bg.png",
})
print(result["success"], result.get("width"), result.get("height"))
Enter fullscreen mode Exit fullscreen mode

For chat handoff, omit output_path and use result["image_base64"] from the JSON.


Try it: any agent loop

Same pattern as wallet screening, token limiting, or UK Companies House — load the bundle, expose the tool schema to your provider, call skill.execute(tool_input) on tool use:

from skillware.core.loader import SkillLoader

bundle = SkillLoader.load_skill("creative/bg_remover")
skill = bundle["class"]()
tool = SkillLoader.to_gemini_tool(bundle)  # or to_claude_tool, to_openai_tool, ...

# User: "Remove the background from product.png and save product_no_bg.png"
# On tool_call: skill.execute(tool_input)
Enter fullscreen mode Exit fullscreen mode

Per-provider snippets live on the skill page and in docs/skills/bg_remover.md.

CLI smoke test after install:

skillware test creative/bg_remover
Enter fullscreen mode Exit fullscreen mode

Why local matters for agents

Cloud cutout APIs add keys, latency, and data leaving your process. For ecommerce pipelines, internal tools, or agents that already handle files and Base64, offline rembg behind a fixed schema is easier to audit: one execute() contract, testable in CI, chainable with other skills in the same loop.

Pair it with monitoring/token_limiter if the agent is doing multi-step image batches — cap spend in the outer loop while the remover stays deterministic inside.


Links

If your agent touches images, load the skill before the model improvises a workflow. One line to install, one registry ID, any host.

Top comments (0)