首页龙虾技能列表 › Segment Anything

Segment Anything

v1.0.0

使用 SAM(Segment Anything Model)去除图像背景,将前景主体提取为透明 PNG。适用于去除背景、抠图、提取前景主体或图像分割等需求。

0· 196·1 当前·1 累计
by @scikkk·MIT-0
下载技能包
License
MIT-0
最后更新
2026/4/14
安全扫描
VirusTotal
可疑
查看报告
OpenClaw
安全
high confidence
The skill's code, dependencies, and instructions are consistent with its stated purpose (running Meta's Segment Anything to remove image backgrounds); the main risks are expected operational impacts (large model downloads and installing Python packages), not misbehavior.
评估建议
This skill appears to do what it claims. Before installing, consider: (1) model weights can be large (vit_h ~2.5GB) — ensure you have bandwidth and disk space; (2) it will install Python packages (torch, torchvision, and may pip-install the segment_anything repo) which run code on your machine — if you run in a shared/production environment, prefer reviewing the segment_anything repository or running inside a contained environment (virtualenv/container); (3) downloads occur from GitHub and dl.fb...
详细分析 ▾
用途与能力
Name/description (SAM-based background removal) matches the included script and requested packages (Pillow, numpy, torch, torchvision). The script downloads official SAM checkpoints and optionally installs the segment_anything package — all actions are coherent with the stated functionality.
指令范围
SKILL.md instructs running the included script and explains behavior (prompt points, cache path ~/.cache/sam, automatic checkpoint download). Instructions do not ask to read unrelated files or exfiltrate data, but the runtime will auto-install the segment_anything package if missing and download large model weights.
安装机制
Install spec lists PyPI packages (pillow, numpy, torch, torchvision) which are expected. The script also runs pip install git+https://github.com/facebookresearch/segment-anything.git at runtime if needed. Model checkpoints are downloaded from dl.fbaipublicfiles.com (Facebook's public host) — no suspicious shorteners or private domains.
凭证需求
No environment variables, credentials, or config paths are requested. The script only writes to an application cache directory (~/.cache/sam) and the output locations provided by the user.
持久化与权限
The skill does not request always:true and is user-invocable. It will install Python packages into the running environment and persist model files under ~/.cache/sam; this modifies the local environment but is expected for ML model usage.
安全有层次,运行前请审查代码。

License

MIT-0

可自由使用、修改和再分发,无需署名。

运行时依赖

无特殊依赖

版本

latestv1.0.02026/3/14

- Initial release of segment-anything skill (sam-segmentation-zh). - Provides image background removal using Meta’s Segment Anything Model (SAM), outputting transparent PNGs. - Supports customizable models, foreground point hints, and advanced options for extracting multiple elements. - Includes CLI usage instructions and detailed parameter explanations. - Automatic handling of model downloads and dependency installation.

● 可疑

安装命令 点击复制

官方npx clawhub@latest install segment-anything
镜像加速npx clawhub@latest install segment-anything --registry https://cn.clawhub-mirror.com

技能文档

使用 Meta 的 Segment Anything Model 从图像中提取前景主体,输出透明背景的 PNG 文件。

快速开始

python3 scripts/segment.py <输入图像> <输出.png>

默认以图像中心作为前景提示点——适用于主体居中的人像和产品图。

参数说明

参数说明默认值
input输入图像路径必填
output输出 PNG 路径(单目标模式)或目录(--all 模式)必填
--model模型大小:vit_b(快速)· vit_l(中等)· vit_h(最佳质量)vit_h
--checkpoint本地权重文件路径;省略时自动下载自动
--points前景提示点,格式为 x,y,可指定多个中心点
--all网格扫描模式:提取所有独立元素关闭
--grid--all 模式的网格密度;16 表示 16×16=256 个探测点16
--iou-thresh接受掩码的最低预测 IoU(--all 模式)0.88
--min-area掩码最小面积占图像比例(--all 模式)0.001

使用示例

# 基础背景去除(自动下载 vit_h 约 2.5GB)
python3 scripts/segment.py photo.jpg output.png

# 主体偏离中心时指定提示点 python3 scripts/segment.py photo.jpg output.png --points 320,240

# 多提示点 + 轻量模型 python3 scripts/segment.py photo.jpg output.png --model vit_b --points 320,240 400,300

# 提取所有元素(每个元素输出一个 PNG) python3 scripts/segment.py photo.jpg ./elements/ --all

# 使用更密集的网格捕获小物体 python3 scripts/segment.py photo.jpg ./elements/ --all --grid 32

# 使用本地权重文件 python3 scripts/segment.py photo.jpg output.png --checkpoint /path/to/sam_vit_h_4b8939.pth

依赖安装

segment_anything 首次运行时自动安装,也可手动安装:

pip install git+https://github.com/facebookresearch/segment-anything.git
pip install pillow numpy torch torchvision

工作流程

  • 用户提供图像路径
  • 询问是否需要提示点(主体偏离中心时)
  • 运行脚本;权重文件首次使用时自动下载至 ~/.cache/sam/
  • 输出透明背景的 PNG 文件

模型选择

模型大小速度质量
vit_b~375 MB最快良好
vit_l~1.25 GB中等较好
vit_h~2.5 GB较慢最佳
有 GPU 时自动使用 CUDA 加速。

数据来源:ClawHub ↗ · 中文优化:龙虾技能库
OpenClaw 技能定制 / 插件定制 / 私有工作流定制

免费技能或插件可能存在安全风险,如需更匹配、更安全的方案,建议联系付费定制

了解定制服务