关于 background-removal
background-removal 是基于 each::sense 的图像背景处理技能,可抠出主体并导出透明图,或替换为新背景。它适用于产品和人像处理,并提供保留头发、毛发等细节边缘的指导。
主要功能
- 01导出透明 PNG 抠图
- 02替换为纯色背景
- 03替换为场景背景
- 04处理头发和复杂边缘
- 05批量处理图像
- 06适用于产品和人像处理
适用场景
- 01制作网店商品抠图
- 02为人像生成干净背景
- 03将主体合成到新场景
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ eachlabs/ skills --skill background-removal安装后在 Claude Code 中输入/background-removal确认已加载。
附带文件references/SSE-EVENTS.md
详细介绍
背景移除
使用 each::sense 移除图像背景。此技能可创建透明背景的专业抠图、将背景替换为纯色或场景,并精准处理头发和毛发等复杂边缘。
功能
- 透明 PNG 导出:带 Alpha 通道透明效果的干净抠图
- 纯色替换:将背景替换为任意纯色
- 场景替换:将主体置于新环境中
- 保留头发细节:使用先进的边缘检测处理精细细节
- 复杂边缘处理:精准抠出边缘复杂的主体
- 批量处理:移除多张图像的背景
- 适用于电商:针对在线商店优化的商品抠图
- 人像优化:专业头像和个人资料照片
快速开始
curl -X POST https://eachsense-agent.core.eachlabs.run/v1/chat/completions \
-H "Content-Type: application/json" \
-H "X-API-Key: $EACHLABS_API_KEY" \
-H "Accept: text/event-stream" \
-d '{
"messages": [{"role": "user", "content": "Remove the background from this image and export as transparent PNG"}],
"model": "eachsense/beta",
"stream": true,
"image_urls": ["https://example.com/my-photo.jpg"],
"mode": "max"
}'
用例示例
1. 商品背景移除
为电商商品列表创建干净的抠图。
curl -X POST https://eachsense-agent.core.eachlabs.run/v1/chat/completions \
-H "Content-Type: application/json" \
-H "X-API-Key: $EACHLABS_API_KEY" \
-H "Accept: text/event-stream" \
-d '{
"messages": [{"role": "user", "content": "Remove the background from this product photo. Create a clean cutout with transparent background, preserving all product details and shadows. Output as PNG."}],
"model": "eachsense/beta",
"stream": true,
"image_urls": ["https://example.com/product-shoe.jpg"],
"mode": "max"
}'
2. 人像背景移除
为商务或个人用途创建专业头像抠图。
curl -X POST https://eachsense-agent.core.eachlabs.run/v1/chat/completions \
-H "Content-Type: application/json" \
-H "X-API-Key: $EACHLABS_API_KEY" \
-H "Accept: text/event-stream" \
-d '{
"messages": [{"role": "user", "content": "Remove the background from this portrait photo. Preserve all hair details and create clean edges around the person. Export as transparent PNG for professional use."}],
"model": "eachsense/beta",
"stream": true,
"image_urls": ["https://example.com/headshot.jpg"],
"mode": "max"
}'
3. 透明 PNG 导出
导出带 Alpha 通道的图像,以便在设计软件中使用。
curl -X POST https://eachsense-agent.core.eachlabs.run/v1/chat/completions \
-H "Content-Type: application/json" \
-H "X-API-Key: $EACHLABS_API_KEY" \
-H "Accept: text/event-stream" \
-d '{
"messages": [{"role": "user", "content": "Remove the background from this image and export as a high-quality transparent PNG. Ensure clean alpha channel edges suitable for compositing in Photoshop or Figma."}],
"model": "eachsense/beta",
"stream": true,
"image_urls": ["https://example.com/object.jpg"],
"mode": "max"
}'
4. 将背景替换为纯色
将背景替换为指定的纯色。
curl -X POST https://eachsense-agent.core.eachlabs.run/v1/chat/completions \
-H "Content-Type: application/json" \
-H "X-API-Key: $EACHLABS_API_KEY" \
-H "Accept: text/event-stream" \
-d '{
"messages": [{"role": "user", "content": "Remove the background from this product image and replace it with a pure white background (#FFFFFF). Keep the product shadows for a natural look."}],
"model": "eachsense/beta",
"stream": true,
"image_urls": ["https://example.com/product.jpg"],
"mode": "max"
}'
5. 将背景替换为场景
将主体置于全新的环境中。
curl -X POST https://eachsense-agent.core.eachlabs.run/v1/chat/completions \
-H "Content-Type: application/json" \
-H "X-API-Key: $EACHLABS_API_KEY" \
-H "Accept: text/event-stream" \
-d '{
"messages": [{"role": "user", "content": "Remove the background from this person photo and place them in a modern office environment with soft natural lighting from large windows. Make it look natural and professional."}],
"model": "eachsense/beta",
"stream": true,
"image_urls": ["https://example.com/person.jpg"],
"mode": "max"
}'
6. 保留头发细节
精准处理复杂的头发边缘。
curl -X POST https://eachsense-agent.core.eachlabs.run/v1/chat/completions \
-H "Content-Type: application/json" \
-H "X-API-Key: $EACHLABS_API_KEY" \
-H "Accept: text/event-stream" \
-d '{
"messages": [{"role": "user", "content": "Remove the background from this portrait. Pay special attention to preserving fine hair details, flyaway strands, and wispy edges. The subject has curly hair that needs careful edge handling. Export as transparent PNG."}],
"model": "eachsense/beta",
"stream": true,
"image_urls": ["https://example.com/curly-hair-portrait.jpg"],
"mode": "max"
}'
7. 复杂边缘处理
处理毛皮、羽毛或半透明物体等边缘复杂的主体。
curl -X POST https://eachsense-agent.core.eachlabs.run/v1/chat/completions \
-H "Content-Type: application/json" \
-H "X-API-Key: $EACHLABS_API_KEY" \
-H "Accept: text/event-stream" \
-d '{
"messages": [{"role": "user", "content": "Remove the background from this image of a fluffy cat. Preserve all the fur details including the soft edges and individual hair strands. The cat has white fur which is challenging - maintain clean edges without halos."}],
"model": "eachsense/beta",
"stream": true,
"image_urls": ["https://example.com/fluffy-cat.jpg"],
"mode": "max"
}'
8. 批量移除背景
以一致的效果处理多张商品图像。
# First image in batch
curl -X POST https://eachsense-agent.core.eachlabs.run/v1/chat/completions \
-H "Content-Type: application/json" \
-H "X-API-Key: $EACHLABS_API_KEY" \
-H "Accept: text/event-stream" \
-d '{
"messages": [{"role": "user", "content": "Remove the background from this product image. Export as transparent PNG with consistent edge quality."}],
"model": "eachsense/beta",
"stream": true,
"image_urls": ["https://example.com/product-1.jpg"],
"session_id": "batch-background-removal-001",
"mode": "eco"
}'
# Second image (same session for consistency)
curl -X POST https://eachsense-agent.core.eachlabs.run/v1/chat/completions \
-H "Content-Type: application/json" \
-H "X-API-Key: $EACHLABS_API_KEY" \
-H "Accept: text/event-stream" \
-d '{
"messages": [{"role": "user", "content": "Remove the background from this product image with the same settings as before."}],
"model": "eachsense/beta",
"stream": true,
"image_urls": ["https://example.com/product-2.jpg"],
"session_id": "batch-background-removal-001",
"mode": "eco"
}'
# Third image
curl -X POST https://eachsense-agent.core.eachlabs.run/v1/chat/completions \
-H "Content-Type: application/json" \
-H "X-API-Key: $EACHLABS_API_KEY" \
-H "Accept: text/event-stream" \
-d '{
"messages": [{"role": "user", "content": "Remove the background from this product image, same approach."}],
"model": "eachsense/beta",
"stream": true,
"image_urls": ["https://example.com/product-3.jpg"],
"session_id": "batch-background-removal-001",
"mode": "eco"
}'
9. 电商商品抠图
创建适用于 Amazon/Shopify 的白底商品图像。
curl -X POST https://eachsense-agent.core.eachlabs.run/v1/chat/completions \
-H "Content-Type: application/json" \
-H "X-API-Key: $EACHLABS_API_KEY" \
-H "Accept: text/event-stream" \
-d '{
"messages": [{"role": "user", "content": "Create an e-commerce ready product cutout from this image. Remove the background and replace with pure white. The product should be centered with clean edges. This is for Amazon/Shopify listing - must meet marketplace image requirements."}],
"model": "eachsense/beta",
"stream": true,
"image_urls": ["https://example.com/product-handbag.jpg"],
"mode": "max"
}'
10. 社交媒体头像
创建背景干净的专业头像。
curl -X POST https://eachsense-agent.core.eachlabs.run/v1/chat/completions \
-H "Content-Type: application/json" \
-H "X-API-Key: $EACHLABS_API_KEY" \
-H "Accept: text/event-stream" \
-d '{
"messages": [{"role": "user", "content": "Remove the background from this selfie and replace with a professional gradient background (dark blue to light blue). Preserve all hair details. This is for a LinkedIn profile photo - make it look polished and professional."}],
"model": "eachsense/beta",
"stream": true,
"image_urls": ["https://example.com/selfie.jpg"],
"mode": "max"
}'
多轮创意迭代
使用 session_id 优化背景移除效果:
# Initial removal
curl -X POST https://eachsense-agent.core.eachlabs.run/v1/chat/completions \
-H "Content-Type: application/json" \
-H "X-API-Key: $EACHLABS_API_KEY" \
-H "Accept: text/event-stream" \
-d '{
"messages": [{"role": "user", "content": "Remove the background from this portrait photo"}],
"model": "eachsense/beta",
"stream": true,
"image_urls": ["https://example.com/portrait.jpg"],
"session_id": "portrait-project-001"
}'
# Refine the result
curl -X POST https://eachsense-agent.core.eachlabs.run/v1/chat/completions \
-H "Content-Type: application/json" \
-H "X-API-Key: $EACHLABS_API_KEY" \
-H "Accept: text/event-stream" \
-d '{
"messages": [{"role": "user", "content": "The hair edges look a bit rough. Can you refine them to be smoother and more natural?"}],
"model": "eachsense/beta",
"stream": true,
"session_id": "portrait-project-001"
}'
# Change background
curl -X POST https://eachsense-agent.core.eachlabs.run/v1/chat/completions \
-H "Content-Type: application/json" \
-H "X-API-Key: $EACHLABS_API_KEY" \
-H "Accept: text/event-stream" \
-d '{
"messages": [{"role": "user", "content": "Now place this cutout on a beach sunset background"}],
"model": "eachsense/beta",
"stream": true,
"session_id": "portrait-project-001"
}'
模式选择
生成前询问用户:
“您想要快速且低成本,还是高质量?”
| 模式 | 最适合 | 速度 | 质量 |
|---|---|---|---|
max | 最终成品图像、复杂边缘、头发细节 | 较慢 | 最高 |
eco | 快速预览、批量处理、简单物体 | 较快 | 良好 |
最佳实践
商品
- 光照:原始图像应光照均匀,以获得最佳效果
- 对比度:商品与背景的对比度越高,处理越准确
- 阴影:要求保留阴影,以获得自然效果
- 分辨率:输入分辨率越高,边缘质量越好
人像
- 头发:在提示词中说明发型,以获得更好的边缘检测效果
- 服装:如果服装边缘与背景融合,请描述这些边缘
- 配饰:说明需要保留的眼镜、珠宝或其他物品
复杂主体
- 透明效果:说明玻璃、烟雾或半透明元素
- 精细细节:注明毛皮、羽毛或复杂图案
- 多个主体:描述哪些内容应保留,哪些应移除
提示词技巧
请求移除背景时,请包含:
- 主体类型:商品、人物、动物、物体
- 边缘复杂度:简单边缘,或头发/毛皮/精细细节
- 输出格式:透明 PNG 或替换后的背景
- 背景颜色:若要替换为纯色,请提供具体的十六进制代码
- 使用场景:电商、社交媒体、合成等
提示词结构示例
"Remove the background from this [subject type].
[Specific edge requirements like hair or fur details].
Output as [transparent PNG / white background / specific scene].
This is for [use case] - [any specific requirements]."
错误处理
| 错误 | 原因 | 解决方案 |
|---|---|---|
Failed to create prediction: HTTP 422 | 余额不足 | 在 eachlabs.ai 充值 |
| 边缘质量较差 | 输入分辨率较低 | 使用分辨率更高的源图像 |
| 边缘周围出现光晕 | 背景颜色复杂 | 使用 max 模式以改善边缘检测效果 |
| 超时 | 图像较大或处理较复杂 | 将客户端超时时间设为至少 10 分钟 |
相关技能
each-sense- 核心 API 文档product-photo-generation- 从头生成产品图片image-edit- 通用图像编辑功能
评论
支持 Markdown