README.md 3.56 KB
Newer Older
sunxx1's avatar
sunxx1 committed
1
# VGG16
sunxx1's avatar
sunxx1 committed
2
## 论文
Rayyyyy's avatar
Rayyyyy committed
3
`VERY DEEP CONVOLUTIONAL NETWORKS FOR LARGE-SCALE IMAGE RECOGNITION`
sunxx1's avatar
sunxx1 committed
4
5
- https://arxiv.org/abs/1409.1556

sunxx1's avatar
sunxx1 committed
6
## 模型结构
sunxx1's avatar
sunxx1 committed
7
VGG模型是2014年ILSVRC竞赛的第二名,第一名是GoogLeNet。但是VGG模型在多个迁移学习任务中的表现要优于GoogLeNet。而且,从图像中提取CNN特征,VGG模型是首选算法。
sunxx1's avatar
sunxx1 committed
8

sunxx1's avatar
sunxx1 committed
9
10
![20231124132639](./images/20231124132639.png)

sunxx1's avatar
sunxx1 committed
11
## 算法原理
sunxx1's avatar
sunxx1 committed
12
VGG16共有16个层,是一个相当深的卷积神经网络。VGG各种级别的结构都采用了5段卷积,每一段有一个或多个卷积层。
sunxx1's avatar
sunxx1 committed
13

sunxx1's avatar
sunxx1 committed
14
![20231124132925](./images/20231124132925.png)
sunxx1's avatar
sunxx1 committed
15

sunxx1's avatar
sunxx1 committed
16
## 环境配置
sunxx1's avatar
sunxx1 committed
17
### Docker(方法一)
Rayyyyy's avatar
Rayyyyy committed
18
```bash
sunxx1's avatar
sunxx1 committed
19
20
21
git clone --recursive http://developer.hpccube.com/codes/modelzoo/vgg16_mmcv.git
docker pull image.sourcefind.cn:5000/dcu/admin/base/pytorch:1.10.0-centos7.6-dtk-22.10.1-py37-latest
# <your IMAGE ID>用以上拉取的docker的镜像ID替换
dcuai's avatar
dcuai committed
22
docker run --shm-size 10g --network=host --name=vgg16 --privileged --device=/dev/kfd --device=/dev/dri --group-add video --cap-add=SYS_PTRACE --security-opt seccomp=unconfined -v $PWD/vgg16_mmcv:/home/vgg16_mmcv -it <your IMAGE ID> bash
sunxx1's avatar
sunxx1 committed
23

sunxx1's avatar
sunxx1 committed
24
cd vgg16_mmcv/mmclassification-mmcv
sunxx1's avatar
sunxx1 committed
25
26
pip install -r requirements.txt
```
sunxx1's avatar
sunxx1 committed
27

sunxx1's avatar
sunxx1 committed
28
29
30
31
### Dockerfile(方法二)
```plaintext
cd vgg16_mmcv/docker
docker build --no-cache -t vgg16_mmcv:latest .
dcuai's avatar
dcuai committed
32
docker run --rm --shm-size 10g --network=host --name=vgg16 --privileged --device=/dev/kfd --device=/dev/dri --group-add video --cap-add=SYS_PTRACE --security-opt seccomp=unconfined -v $PWD/../../vgg16_mmcv:/home/vgg16_mmcv -it <your IMAGE ID> bash
sunxx1's avatar
sunxx1 committed
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# 若遇到Dockerfile启动的方式安装环境需要长时间等待,可注释掉里面的pip安装,启动容器后再安装python库:pip install -r requirements.txt
```

### Anaconda(方法三)
1、关于本项目DCU显卡所需的特殊深度学习库可从光合开发者社区下载安装: https://developer.hpccube.com/tool/
```plaintext
DTK驱动:dtk22.10.1
python:python3.7
torch:1.10.0
torchvision:0.10.0
mmcv:1.6.1
Tips:以上dtk驱动、python、torch等DCU相关工具版本需要严格一一对应
```

2、其它非特殊库参照requirements.txt安装
```plaintext
pip install -r requirements.txt
```

sunxx1's avatar
sunxx1 committed
52
## 数据集
Rayyyyy's avatar
Rayyyyy committed
53
在本测试中可以使用ImageNet数据集,下载ImageNet数据集:http://113.200.138.88:18080/aidatasets/project-dependency/imagenet-2012
sunxx1's avatar
sunxx1 committed
54

dcuai's avatar
dcuai committed
55
56
57
58
59
下载val数据:链接:https://pan.baidu.com/s/1oXsmsYahGVG3uOZ8e535LA?pwd=c3bc 提取码:c3bc 替换ImageNet数据集中的val目录

或者从SCNet下载[ImageNet](http://113.200.138.88:18080/aidatasets/project-dependency/imagenet-2012)
- ImageNet数据集中的val部分[val](http://113.200.138.88:18080/aidatasets/project-dependency/shufflenet_v2_mmcv)
处理后的数据结构如下:
sunxx1's avatar
sunxx1 committed
60

sunxx1's avatar
sunxx1 committed
61
```
Rayyyyy's avatar
Rayyyyy committed
62
63
64
65
66
67
68
69
├── data
│   ├── imagenet
│       ├── meta
│           ├── val.txt
│           ├── train.txt
│           ...
│       ├── train
│       ├── val
sunxx1's avatar
sunxx1 committed
70
```
sunxx1's avatar
sunxx1 committed
71

sunxx1's avatar
sunxx1 committed
72
## 训练
sunxx1's avatar
sunxx1 committed
73
74
将训练数据解压到data目录下。

sunxx1's avatar
sunxx1 committed
75
### 单机8卡
Rayyyyy's avatar
Rayyyyy committed
76
77
78
```
bash ./vgg16.sh
```
dcuai's avatar
dcuai committed
79
80
81
82
83

## result
![img](https://developer.hpccube.com/codes/modelzoo/vit_pytorch/-/raw/master/image/README/1695381570003.png)

### 精度
sunxx1's avatar
sunxx1 committed
84
85
测试数据使用的是ImageNet数据集,使用的加速卡是DCU Z100L。

sunxx1's avatar
sunxx1 committed
86
87
88
89
| 卡数 |          精度           |
| :--: | :---------------------: |
|  8   | top1:0.7162;top5:0.9049 |

sunxx1's avatar
sunxx1 committed
90
91
92
93
94
95
96
## 应用场景
### 算法类别
图像分类

### 热点行业
制造,能源,交通,网安

dcuai's avatar
dcuai committed
97
## 源码仓库及问题反馈
Rayyyyy's avatar
Rayyyyy committed
98
- https://developer.hpccube.com/codes/modelzoo/vgg16_mmcv
sunxx1's avatar
sunxx1 committed
99

dcuai's avatar
dcuai committed
100
## 参考资料
Rayyyyy's avatar
Rayyyyy committed
101
- https://github.com/open-mmlab/mmpretrain