REST API for background removal and sticker cutout. Base URL: . No API key required. Uploads are processed in memory and never stored. Interactive docs: Swagger UI · raw spec: openapi.json.
抠图/去背景 REST API。Base URL:。无需 API Key。上传内容只在内存中处理,从不保存。交互文档:Swagger UI · 规范:openapi.json。
⚠️ This API is for testing only. For commercial use or partnership inquiries, contact stormnetwork@163.com (海口龙华区妙妙鱼传媒工作室 / Miaomiaoyu Media Studio, Longhua District, Haikou). Public instance limits per IP: 1 call / 10 s and 5 calls / 60 s (HTTP 429 when exceeded).
| Route | Description |
|---|---|
GET /api/v1/health | Version, loaded models, limits |
GET /api/v1/models | rembg models + currently available free vision models |
POST /api/v1/segment | One subject → transparent PNG (method = rembg | grabcut | ai) |
POST /api/v1/multi | Up to 6 subjects → one PNG each |
POST /api/segment, GET /api/health | Legacy aliases (v1.0/1.1 response shape), kept for compatibility |
| Field | Default | Description |
|---|---|---|
file | — | JPEG / PNG / WebP, ≤ 12 MB |
method | rembg | rembg · grabcut · ai |
rembg_model | u2netp | u2netp · isnet-general-use · u2net · silueta |
complete | true | Smart subject completion (pure vision) |
smooth | 3 | 0–10 |
despeckle | true | Remove small islands, fill holes |
white_border | true | White sticker outline |
points_json | — | grabcut: [{"x":0.5,"y":0.5,"label":1}] (0..1) |
rect_json | — | grabcut: [x,y,w,h] (0..1) |
{ "ok": true, "version": "1.2.1", "method": "rembg", "engine": "rembg_u2netp+smart_complete",
"rembg_model": "u2netp", "width": 960, "height": 1280, "elapsed_ms": 1800,
"image_png_b64": "iVBOR…", "mask_png_b64": "iVBOR…", "detection": null }
{ "ok": false, "error": { "code": "FILE_TOO_LARGE", "message": "File larger than 12 MB" } }
| HTTP | code |
|---|---|
| 400 | EMPTY_FILE · BAD_JSON · UNKNOWN_MODEL |
| 413 | FILE_TOO_LARGE |
| 415 | UNSUPPORTED_IMAGE |
| 422 | VALIDATION_ERROR |
| 500 | SEGMENTATION_FAILED |
Limits: 12 MB per upload; images are downscaled to ≤1280 px for rembg; the public demo runs on a small 4-vCPU box with no GPU — please keep it to a few requests per minute, and self-host for batch jobs. The ai/multi methods only use free OpenRouter models and may be slow (up to ~2 min) or rate-limited, falling back to rembg.
限制:单次上传 ≤ 12 MB;rembg 会把图片缩到长边 ≤1280px;公共演示跑在一台 4 核、无 GPU 的小服务器上,请控制在每分钟几次,批量任务请自行部署。ai/multi 仅使用 OpenRouter 免费模型,可能较慢(最长约 2 分钟)或被限流,失败时回退 rembg。
BASE=
curl -s $BASE/api/v1/health
curl -s -F file=@photo.jpg -F method=rembg $BASE/api/v1/segment \
| python3 -c "import sys,json,base64;d=json.load(sys.stdin);open('sticker.png','wb').write(base64.b64decode(d['image_png_b64']))"
curl -s -F file=@photo.jpg -F method=grabcut -F 'points_json=[{"x":0.5,"y":0.5,"label":1}]' $BASE/api/v1/segment
curl -s -F file=@photo.jpg $BASE/api/v1/multi
Single file, standard library only: sdk/python/segimage.py
单文件、仅依赖标准库:sdk/python/segimage.py
from segimage import SegImage, SegImageError
client = SegImage("")
res = client.segment("photo.jpg", method="rembg", smooth=3)
res.save("sticker.png")
print(res.engine, res.elapsed_ms)
for i, s in enumerate(client.multi("desk.jpg").subjects, 1):
s.save(f"{i}_{s.label}.png")
ESM, uses fetch + FormData; browser and Node ≥ 18; typings included: sdk/js
ESM,基于 fetch + FormData;浏览器与 Node ≥ 18 通用,自带类型:sdk/js
import { SegImage } from "./segimage.js";
const client = new SegImage("");
const res = await client.segment(fileInput.files[0], { method: "rembg" });
document.querySelector("img").src = URL.createObjectURL(res.image);