README.md 4.01 KB
Newer Older
xinghao's avatar
xinghao committed
1
2
3
4
5
6
7
8
9
10
11
12
13
# SSD
## 论文
SSD: Single Shot MultiBox Detector

- https://link.springer.com/chapter/10.1007/978-3-319-46448-0_2
## 模型结构
SSD模型结构包括一个基础卷积网络(如VGG16或ResNet)作为特征提取器,后接多个卷积层,这些层负责生成不同尺度的特征图,以便于检测不同大小的物体。

## 算法原理
SSD通过在每个特征图上直接预测边界框和类别概率,使用多种尺寸的默认框来覆盖图像中的目标,在一个前向传播中完成目标检测,显著提高了检测速度。


## 环境配置
dcuai's avatar
dcuai committed
14
### Docker(方法一)
xinghao's avatar
xinghao committed
15
```bash
dcuai's avatar
dcuai committed
16
docker pull image.sourcefind.cn:5000/dcu/admin/base/pytorch:2.1.0-ubuntu20.04-dtk24.04.1-py3.10
dcuai's avatar
dcuai committed
17
docker run -it  --shm-size 80g --network=host --name=docker_name --privileged --device=/dev/kfd --device=/dev/dri --group-add video --cap-add=SYS_PTRACE --security-opt seccomp=unconfined image.sourcefind.cn:5000/dcu/admin/base/pytorch:2.1.0-ubuntu20.04-dtk24.04.1-py3.10 bin/bash
xinghao's avatar
xinghao committed
18
19
20
21
22
23
```
其它非深度学习库参照requirements.txt安装:
```
pip install -r requirements.txt
pip install pycocotools
```
dcuai's avatar
dcuai committed
24
### Dockerfile(方法二)
dcuai's avatar
dcuai committed
25
26
27
28
29
30
31
32
33
34
35
```bash
cd ./docker

docker build --no-cache -t ssd_pytorch:latest .
docker run -it  --shm-size 80g --network=host --name=docker_name --privileged --device=/dev/kfd --device=/dev/dri --group-add video --cap-add=SYS_PTRACE --security-opt seccomp=unconfined ssd_pytorch:latest bin/bash
```
其它非深度学习库参照requirements.txt安装:
```
pip install -r requirements.txt
pip install pycocotools
```
dcuai's avatar
dcuai committed
36
37
38


### Anaconda(方法三)
chenzk's avatar
chenzk committed
39
1、关于本项目DCU显卡所需的特殊深度学习库可从光合开发者社区下载安装: https://developer.sourcefind.cn/tool/
dcuai's avatar
dcuai committed
40
41
42
43
44
45
46
47
48
49
50
51
52
53
```
DTK软件栈: dtk24.04.1
python: python3.10
torch: 2.1.0
torchvision: 0.16.0
```
2、其它非深度学习库参照requirements.txt安装:
```
pip install -r requirements.txt
pip install pycocotools
```

Tips:以上dtk软件栈、python、torch、mmcv等DCU相关工具版本需要严格一一对应

xinghao's avatar
xinghao committed
54
55
56
57
58
59
60
61
62
63
64
## 数据集
#### 小数据集

coco2017_50数据集

解压后使用训练/推理命令默认使用该数据集。

#### 标准数据集

Pascal VOC数据集

chenzk's avatar
chenzk committed
65
66
67
下载地址:
[Pascal VOC 2007](http://host.robots.ox.ac.uk/pascal/VOC/voc2007/index.html)
[Pascal VOC 2012](http://host.robots.ox.ac.uk/pascal/VOC/voc2012/VOCtrainval_11-May-2012.tar)
xinghao's avatar
xinghao committed
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116

```
VOCdevkit0712/voc2007_2012/VOCdevkit
|__ VOC2007
    |_ JPEGImages
    |_ Annotations
    |_ ImageSets
    |_ SegmentationClass
|__ VOC2012
    |_ JPEGImages
    |_ Annotations
    |_ ImageSets
    |_ SegmentationClass
```
`SSD/ssd/config/path_catlog.py`中第5行`DATA_DIR = '{path_to_dataset}'`指定数据集。

使用VOC2007:`DATA_DIR = 'VOCdevkit0712/voc2007_2012/VOCdevkit/VOC2007/'`

使用VOC2012:`DATA_DIR = 'VOCdevkit0712/voc2007_2012/VOCdevkit/VOC2012/'`

使用VOC0712:`DATA_DIR = 'VOCdevkit0712/voc2007_2012/VOCdevkit/'`

注意:如果使用标准数据集,将命令中`--config-file`改成`configs/vgg_ssd300_voc0712`'

## 训练

### 单卡训练
```bash
python train.py --config-file configs/vgg_ssd300_coco2017_50_trainval.yaml
```

### 多卡训练

```bash
python -m torch.distributed.launch --nproc_per_node=4 train.py --config-file configs/vgg_ssd300_coco2017_50_trainval.yaml SOLVER.WARMUP_FACTOR 0.03333 SOLVER.WARMUP_ITERS 1000
```
## 推理

### 单卡推理

```bash
python test.py --config-file configs/vgg_ssd300_coco2017_50_trainval.yaml
```
### 多卡推理

```bash
python -m torch.distributed.launch --nproc_per_node=4 test.py --config-file configs/vgg_ssd300_coco2017_50_trainval.yaml
```

dcuai's avatar
dcuai committed
117
## result
xinghao's avatar
xinghao committed
118
119
120
121
122

### 输出实例

![result](result.jpg)

dcuai's avatar
dcuai committed
123
### 精度
xinghao's avatar
xinghao committed
124

dcuai's avatar
dcuai committed
125
|        | VOC2007 test(mAP) | coco test-dev2015(mAP) |
xinghao's avatar
xinghao committed
126
127
128
129
130
131
132
133
134
135
136
| :----: | :----------: | :---------------: |
| SSD300 |     77.2     |       25.1        |
| SSD512 |     79.8     |       28.8        |

## 应用场景

### 算法类别
目标检测
### 热点应用行业
金融,交通,教育
## 源码仓库及问题反馈
dcuai's avatar
dcuai committed
137
https://developer.sourcefind.cn/codes/modelzoo/ssd_pytorch
xinghao's avatar
xinghao committed
138
139

## 参考资料
dcuai's avatar
dcuai committed
140
https://github.com/lufficc/SSD