分割任何物体模型 (SAM)可根据点或框等输入提示生成高质量物体蒙版,并可用于为图像中的所有物体生成蒙版。该模型已在包含 1100 万张图像和 11 亿个蒙版的数据集上进行了训练,并且在各种分割任务中具有强大的零样本性能
###1.1说明 已在RTX40系列、3090、3080ti适配;
推理模式分为point prompt、Box prompt (xywh)以及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_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
请下载预训练的权重检查点。将它放在/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
请下载预训练的权重检查点。将它放在/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