README.md 1.97 KB
Newer Older
fengyf1's avatar
fengyf1 committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# SAM

## 项目简介

SAM 是 Meta 推出的通用图像分割模型,通过三阶段架构实现零样本分割。它支持点、框等提示方式,能精准分割图像对象,通用性强、效果精准。

## 环境部署

### 1. 拉取镜像

```
docker pull image.sourcefind.cn:5000/dcu/admin/base/vllm:0.9.2-ubuntu22.04-dtk25.04.1-rc5-rocblas101839-0811-das1.6-py3.10-20250913-rc1
```

### 2. 创建容器

```
docker run -it \
--network=host \
--hostname=localhost \
--name=SAM_infer \
-v /opt/hyhal:/opt/hyhal:ro \
-v $PWD:/workspace \
--ipc=host \
--device=/dev/kfd \
--device=/dev/mkfd \
--device=/dev/dri \
--shm-size=512G \
--privileged \
--group-add video \
--cap-add=SYS_PTRACE \
--security-opt seccomp=unconfined \
image.sourcefind.cn:5000/dcu/admin/base/vllm:0.9.2-ubuntu22.04-dtk25.04.1-rc5-rocblas101839-0811-das1.6-py3.10-20250913-rc1 \
/bin/bash  
```

## 测试步骤

### 1. 拉取优化后代码仓库

```
git clone http://developer.sourcefind.cn/codes/bw-bestperf/SAM.git
cd SAM
```

### 2. 安装依赖

```
pip install pycocotools -i https://pypi.tuna.tsinghua.edu.cn/simple
pip install onnx -i https://pypi.tuna.tsinghua.edu.cn/simple
pip install onnxruntime-1.19.2+das.opt1.dtk25041-cp310-cp310-manylinux_2_28_x86_64.whl 
pip install -e .
```

 ### 4. 下载模型与数据集

```
# 模型下载
wget https://dl.fbaipublicfiles.com/segment_anything/sam_vit_h_4b8939.pth
# 数据集下载
wget -O  coco_2017.zip  https://ai-studio-online.bj.bcebos.com/v1/9b15388b52fa45bb8f4e66343d6e2fa690630a526df64fcd90d8ed8a124627bd?responseContentDisposition=attachment%3Bfilename%3Dmini-coco2017.zip&authorization=bce-auth-v1%2F5cfe9a5e1454405eb2a975c43eace6ec%2F2025-10-11T02%3A23%3A00Z%2F60%2F%2Fdb2d898bccb4ef8674047b3eda1aaaa094a71c8f87a7d2b51f49ee16e30c77ac
# 数据集解压
unzip coco_2017.zip  -d mini_coco/
```

### 5. 测试命令

```
python scripts/amg_amp_compile_v2_warmup.py --checkpoint sam_vit_h_4b8939.pth --model-type vit_h --input mini_coco/val2017 --output ./output
```