image-remove-background
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseImage Remove Background
图片背景移除
Removes the background from an image, leaving only the foreground subject with transparency.
移除图片中的背景,仅保留带透明效果的前景主体。
Command
命令
bash
agent-media image remove-background --in <path> [options]bash
agent-media image remove-background --in <path> [options]Inputs
输入参数
| Option | Required | Description |
|---|---|---|
| Yes | Input file path or URL |
| No | Output path, filename or directory (default: ./) |
| No | Provider to use (local, fal, replicate) |
| 选项 | 是否必填 | 描述 |
|---|---|---|
| 是 | 输入文件路径或URL |
| 否 | 输出路径、文件名或目录(默认值:./) |
| 否 | 使用的服务提供商(local, fal, replicate) |
Output
输出结果
Returns a JSON object with the processed image path:
json
{
"ok": true,
"media_type": "image",
"action": "remove-background",
"provider": "fal",
"output_path": "nobg_123_abc.png",
"mime": "image/png",
"bytes": 34567
}返回包含处理后图片路径的JSON对象:
json
{
"ok": true,
"media_type": "image",
"action": "remove-background",
"provider": "fal",
"output_path": "nobg_123_abc.png",
"mime": "image/png",
"bytes": 34567
}Examples
示例
Remove background from local file:
bash
agent-media image remove-background --in portrait.jpgRemove background using specific provider:
bash
agent-media image remove-background --in portrait.jpg --provider replicate从本地文件移除背景:
bash
agent-media image remove-background --in portrait.jpg使用指定服务提供商移除背景:
bash
agent-media image remove-background --in portrait.jpg --provider replicateProviders
服务提供商
local
local
Runs locally on CPU using Transformers.js, no API key required.
- Uses model
Xenova/modnet - Models downloaded on first use (~25MB)
- You may see a error — ignore it, the output is correct if
mutex lock failed"ok": true
bash
agent-media image remove-background --in portrait.jpg --provider local使用Transformers.js在本地CPU运行,无需API密钥。
- 使用模型
Xenova/modnet - 首次使用时会下载模型(约25MB)
- 可能会出现错误——忽略即可,若返回
mutex lock failed则输出结果正确"ok": true
bash
agent-media image remove-background --in portrait.jpg --provider localfal
fal
- Requires
FAL_API_KEY - Uses model
birefnet/v2
- 需要
FAL_API_KEY - 使用模型
birefnet/v2
replicate
replicate
- Requires
REPLICATE_API_TOKEN - Uses model
birefnet
- 需要
REPLICATE_API_TOKEN - 使用模型
birefnet