优云智算
控制台
立即注册

segment-anything

分割任何物体模型 (SAM)可根据点或框等输入提示生成高质量物体蒙版,并可用于为图像中的所有物体生成蒙版。该模型已在包含 1100 万张图像和 11 亿个蒙版的数据集上进行了训练,并且在各种分割任务中具有强大的零样本性能

镜像大小
40 GB
当前版本
v1.0
累计部署
13
累计运行
54 h
最近更新
2025-07-03

运行环境

框架版本
PyTorch-1.8.1
CUDA版本
11.1
应用
JupyterLab: 8888
支持卡型
RTX40系2080
+10

segment-anything 镜像使用教程

1 介绍

分割任何物体模型 (SAM)可根据点或框等输入提示生成高质量物体蒙版,并可用于为图像中的所有物体生成蒙版。该模型已在包含 1100 万张图像和 11 亿个蒙版的数据集上进行了训练,并且在各种分割任务中具有强大的零样本性能

###1.1说明 已在RTX40系列、3090、3080ti适配;

2 使用

推理模式分为point prompt、Box prompt (xywh)以及Points_box prompt

2.1 point promp

推理

请下载预训练的权重检查点。将它放在/workspace/segment-anything/checkpoint文件夹中。(注意:vit_b类型对应/workspace/segment-anything/checkpoint/sam_vit_b_01ec64.pth;vit_h类型对应/workspace/segment-anything/checkpoint/sam_vit_h_4b8939.pth) 运行下面的命令来推理;

cd /workspace/segment-anything/notebooks

python inference_point.py 

可以自己指定图片、checkpoint、模型类型、输出路径以及点的坐标;

python inference_point.py --image_path /workspace/segment-anything/truck.jpg --input_point '[[500,375]]' --output_dir /workspace/segment-anything/output_masks --checkpoint /workspace/segment-anything/checkpoint/sam_vit_b_01ec64.pth --type vit_b

2.2 Box prompt (xywh)

推理

请下载预训练的权重检查点。将它放在/workspace/segment-anything/checkpoint文件夹中。(注意:vit_b类型对应/workspace/segment-anything/checkpoint/sam_vit_b_01ec64.pth;vit_h类型对应/workspace/segment-anything/checkpoint/sam_vit_h_4b8939.pth) 运行下面的命令来推理;

cd /workspace/segment-anything/notebooks

python inference_box.py 

可以自己指定图片、checkpoint、模型类型、输出路径以及框的坐标;

python inference_box.py --image_path /workspace/segment-anything/truck.jpg --input_box '[425, 600, 700, 875]' --output_dir /workspace/segment-anything/output_masks --checkpoint /workspace/segment-anything/checkpoint/sam_vit_b_01ec64.pth --type vit_b

2.3 Points_box prompt

推理

请下载预训练的权重检查点。将它放在/workspace/segment-anything/checkpoint文件夹中。(注意:vit_b类型对应/workspace/segment-anything/checkpoint/sam_vit_b_01ec64.pth;vit_h类型对应/workspace/segment-anything/checkpoint/sam_vit_h_4b8939.pth); 运行下面的命令来推理下;

cd /workspace/segment-anything/notebooks

python inference_box_point.py 

可以自己指定图片、checkpoint、模型类型、输出路径以及点和框的坐标;

python inference_box_point.py --image_path /workspace/segment-anything/truck.jpg --input_box '[425, 600, 700, 875]' --input_point '[[575,750]]' --output_dir /workspace/segment-anything/output_masks --checkpoint /workspace/segment-anything/checkpoint/sam_vit_b_01ec64.pth --type vit_b
0 个镜像 · 被使用 13
版本日志
v1.0最新
2025-02-13
评分
0.0
暂无评分
我的评分
未评分