background-removal について
background-removalは、each::sense APIを使って画像の背景を削除・置換するスキルです。リクエストに応じてモデルが選ばれ、エッジ、照明、影の扱い方も例とともに説明します。
主な機能
- 01リクエストに応じた画像編集モデル選択
- 02背景の削除と置換
- 03透明背景・単色背景の出力
- 04参照画像を使った合成
- 05ストリーミングと一括処理の例
- 06エッジ、照明、影のプロンプト
活用シーン
- 01透明背景の商品画像の作成
- 02ポートレートの背景差し替え
- 03被写体を参照シーンに合成
- 04複数の商品画像の一括処理
インストール
コマンドをコピーしてターミナルで実行します。
$
npx skills add https:/ / github.com/ awesome-genmedia/ skills --skill background-removalインストール後、Claude Code で/background-removalを入力して読み込まれたか確認します。
詳細
背景の削除
each::sense を使用して、ピクセル単位で正確にエッジを検出し、画像の背景を削除します。each::sense は、リクエストに最適なモデルを自動的に選択するインテリジェントな AI エージェントです。
クイックスタート
each::labs の API キーが必要です。eachlabs.ai で取得してください。
curl を使用する場合
curl -X POST https://eachsense-agent.core.eachlabs.run/v1/chat/completions \
-H "Content-Type: application/json" \
-H "X-API-Key: $EACHLABS_API_KEY" \
-d '{
"messages": [{"role": "user", "content": [
{"type": "text", "text": "Remove the background from this image completely. Return the subject on a transparent background with clean edges."},
{"type": "image_url", "image_url": {"url": "https://example.com/product-photo.jpg"}}
]
}
],
"stream": false
}'
Python を使用する場合(OpenAI SDK)
from openai import OpenAI
client = OpenAI(
api_key="YOUR_EACHLABS_API_KEY",
base_url="https://eachsense-agent.core.eachlabs.run/v1"
)
response = client.chat.completions.create(
model="eachsense/beta",
messages=[{"role": "user", "content": "Remove the background from this image completely. Return the subject on a transparent background with clean edges."}],
# Images are included in the message content array above
)
print(response.choices[0].message.content)
参照画像を使用する場合
curl -X POST https://eachsense-agent.core.eachlabs.run/v1/chat/completions \
-H "Content-Type: application/json" \
-H "X-API-Key: $EACHLABS_API_KEY" \
-d '{
"messages": [{"role": "user", "content": [
{"type": "text", "text": "Remove the background from the first image and place the subject onto the scene shown in the second image. Match lighting and scale naturally."},
{"type": "image_url", "image_url": {"url": "https://example.com/person.jpg"}},
{"type": "image_url", "image_url": {"url": "https://example.com/new-background.jpg"}}
]
}
],
"stream": false
}'
画像は、OpenAI のマルチモーダルコンテンツ形式を使用してメッセージ内で送信されます。1 回のリクエストにつき、最大 4 枚の画像を送信できます。
ストリーミング
リアルタイムの SSE レスポンスには "stream": true を、1 回のレスポンスで結果全体を受け取るには "stream": false を設定します。ストリーミングは UI で進行状況を表示する場合に便利です。スクリプトや自動化には、ストリーミングを使用しない方法がよりシンプルです。
利用可能なモデル
| モデル | 強み | 最適な用途 |
|---|---|---|
| eachlabs-bg-remover-v1 | 正確なエッジ検出、髪や毛皮への対応、透明な出力 | きれいな切り抜き、商品写真、ポートレート |
| flux-2-edit | 自然言語での背景置き換え | 指定した新しい背景への差し替え |
| flux-fill-pro | 削除後のインペインティング | 背景領域を新しいコンテンツで埋める |
背景の削除のみを行う場合、each::sense は eachlabs-bg-remover-v1 を選択し、背景の置き換えがリクエストされた場合は flux-2-edit を選択します。
ユースケース
| ユースケース | 指示 | 出力 |
|---|---|---|
| 透明な PNG | 「背景を完全に削除してください」 | 透明な背景に被写体を配置 |
| 白い背景 | 「背景を削除し、真っ白に置き換えてください」 | すっきりした EC 商品掲載画像 |
| 単色 | 「背景をブランドブルー(#2563EB)に置き換えてください」 | ブランドイメージに合ったマーケティング素材 |
| グラデーション | 「背景を柔らかなグレーから白へのグラデーションに置き換えてください」 | プロフェッショナルなポートレート |
| 背景の差し替え | 「夕焼けの熱帯のビーチに配置してください」 | ライフスタイルを表現した合成画像 |
| スタジオの背景 | 「背景を継ぎ目のないグレーのスタジオ背景に置き換えてください」 | プロフェッショナルな商品写真 |
プロンプトのヒント
きれいに削除するには
"Remove the background completely. Keep edges sharp and clean,
especially around hair and fine details. Transparent background."
背景を置き換えるには
"Remove the current background and replace it with [description].
Match the lighting direction from the original photo.
Keep a natural contact shadow beneath the subject."
影の処理
影の扱いを指定します。
"Remove background but keep the natural shadow beneath the product"
"Remove background and all shadows for a clean cutout"
"Remove background, add a soft artificial drop shadow on white"
エッジの品質
エッジの処理方法を指定します。
"Ensure hair edges are soft and natural, not hard-cut"
"Keep crisp edges around the product with no background bleed"
"Apply a very slight feather on the edges for smooth compositing"
例
EC 商品の切り抜き
curl -X POST https://eachsense-agent.core.eachlabs.run/v1/chat/completions \
-H "Content-Type: application/json" \
-H "X-API-Key: $EACHLABS_API_KEY" \
-d '{
"messages": [{"role": "user", "content": [
{"type": "text", "text": "Remove the background from this product photo and replace it with a pure white (#FFFFFF) background. Keep a soft, natural drop shadow beneath the product for a floating effect. Crisp edges with no background artifacts."},
{"type": "image_url", "image_url": {"url": "https://example.com/sneaker-on-table.jpg"}}
]
}
],
"stream": false
}'
プロフェッショナルなポートレート
curl -X POST https://eachsense-agent.core.eachlabs.run/v1/chat/completions \
-H "Content-Type: application/json" \
-H "X-API-Key: $EACHLABS_API_KEY" \
-d '{
"messages": [{"role": "user", "content": [
{"type": "text", "text": "Remove the background from this portrait photo. Replace with a smooth, soft-focus dark gray gradient that is lighter in the center. Keep hair edges natural and wispy, not hard-cut. Professional headshot quality."},
{"type": "image_url", "image_url": {"url": "https://example.com/office-portrait.jpg"}}
]
}
],
"stream": false
}'
デザイン用の透明素材
curl -X POST https://eachsense-agent.core.eachlabs.run/v1/chat/completions \
-H "Content-Type: application/json" \
-H "X-API-Key: $EACHLABS_API_KEY" \
-d '{
"messages": [{"role": "user", "content": [
{"type": "text", "text": "Remove the background from this image entirely. Output a transparent PNG with no background at all. Clean edges suitable for layering in a design tool like Figma or Photoshop. Remove all shadows."},
{"type": "image_url", "image_url": {"url": "https://example.com/plant-photo.jpg"}}
]
}
],
"stream": false
}'
ライフスタイルを表現した合成画像
curl -X POST https://eachsense-agent.core.eachlabs.run/v1/chat/completions \
-H "Content-Type: application/json" \
-H "X-API-Key: $EACHLABS_API_KEY" \
-d '{
"messages": [{"role": "user", "content": [
{"type": "text", "text": "Remove the background and place this person on a sunlit rooftop terrace overlooking a Mediterranean coastal city. Match the warm afternoon lighting from the original photo. The person should look naturally placed in the scene with correct scale and perspective."},
{"type": "image_url", "image_url": {"url": "https://example.com/standing-person.jpg"}}
]
}
],
"stream": false
}'
SNS 向けのブランド投稿
curl -X POST https://eachsense-agent.core.eachlabs.run/v1/chat/completions \
-H "Content-Type: application/json" \
-H "X-API-Key: $EACHLABS_API_KEY" \
-d '{
"messages": [{"role": "user", "content": [
{"type": "text", "text": "Remove the background from this photo and replace it with a bold coral-to-magenta gradient going from bottom-left to top-right. Keep the subject sharp with clean edges. This is for an Instagram post, so make it vibrant and eye-catching."},
{"type": "image_url", "image_url": {"url": "https://example.com/influencer-photo.jpg"}}
]
}
],
"stream": false
}'
バッチ処理
# Remove backgrounds from multiple product photos
PRODUCTS=(
"https://example.com/product-1.jpg"
"https://example.com/product-2.jpg"
"https://example.com/product-3.jpg"
"https://example.com/product-4.jpg"
)
for URL in "${PRODUCTS[@]}"; do
curl -X POST https://eachsense-agent.core.eachlabs.run/v1/chat/completions \
-H "Content-Type: application/json" \
-H "X-API-Key: $EACHLABS_API_KEY" \
-d "{
\"messages\": [{\"role\": \"user\", \"content\": \"Remove the background. Replace with pure white. Keep a soft natural shadow. Clean product cutout.\"}],
\"image_urls\": [\"$URL\"],
\"stream\": false
}"
echo "---"
done
被写体の種類とヒント
| 被写体 | 課題 | ヒント |
|---|---|---|
| 人物(髪) | 細い毛束 | 「髪のエッジを柔らかく自然に保ってください」 |
| ペット(毛皮) | ふわふわしたエッジ | 「エッジ周辺の毛並みのディテールを残してください」 |
| 商品(硬いエッジ) | 反射、影 | 「エッジをくっきりさせ、反射に対応してください」 |
| 植物(葉) | 複雑な輪郭 | 「葉のディテールと隙間を残してください」 |
| 透明な物体 | ガラス、ボトル | 「透明・半透明の領域を適切に処理してください」 |
| 複雑なシーン | 複数の被写体 | 「中央にあるメインの被写体だけを切り抜いてください」 |
よくある落とし穴
- 残す対象を指定しない:「背景を削除してください」でも問題ありませんが、必要に応じて「背景を削除し、商品の下にあるテーブルは残してください」と指示すると、より適切です。
- 色合いが自動で合うと期待する:背景を置き換える場合は、自然な仕上がりにするため、「照明を合わせてください」と必ず指定してください。
- 髪や毛皮のエッジを考慮しない:デフォルトの削除では、細部が粗く切り取られることがあります。「髪のエッジを柔らかく自然にしてください」と明示してください。
- 影の指示をしない:モデルが予測できない形で影を残したり削除したりする場合があります。影の希望を明示してください。
- 被写体と似た色の非常に雑然とした背景は、処理が難しくなります。被写体と背景のコントラストが高いほど、よりきれいに仕上がります。
関連スキル
- 画像編集 — 背景除去後の一般的な編集
- 画像のアップスケーリング — 切り抜き画像の解像度を高めます
- 顔の入れ替え — 合成画像内の顔を置き換えます
- 画像生成 — 合成用の新しい背景を生成します
ドキュメント
コメント
Markdown 対応