README.md 3.75 KB
Newer Older
sunxx1's avatar
sunxx1 committed
1
# InceptionV3
dcuai's avatar
dcuai committed
2
3
4
## 论文
`Rethinking the Inception Architecture for Computer Vision`
- https://arxiv.org/pdf/1512.00567v3.pdf
sunxx1's avatar
sunxx1 committed
5
6
7
8
9

## 模型结构

InceptionV3的整体结构由多个Inception模块组成,每个Inception模块由多个并行的卷积层和池化层组成。这些并行的卷积层和池化层的输出再被级联在一起,形成了一个高维度的特征向量,这个向量再被输入到下一个Inception模块中进行处理。

dcuai's avatar
dcuai committed
10
<div align=center>
dcuai's avatar
dcuai committed
11
     <img src="images/structure.png"/>
dcuai's avatar
dcuai committed
12
13
14
15
16
17
</div>

## 算法原理
Inception-v3 架构的使用 factorized convolutions (分解卷积) ,使用两个3x3的卷积核代替5x5的卷积核可以减少 28% 的参数量,另外分解后多使用了一个激活函数,增加了非线性表达的能力,分解示意图如下所示:

<div align=center>
dcuai's avatar
dcuai committed
18
     <img src="images/pic.png"/>
dcuai's avatar
dcuai committed
19
20
21
22
23
</div>

## 环境配置

### Docker(方法一)
chenzk's avatar
chenzk committed
24
此处提供[光源](https://www.sourcefind.cn/#/service-details)拉取docker镜像的地址与使用步骤,以及[光合](https://developer.sourcefind.cn/tool/)开发者社区深度学习库下载地址
dcuai's avatar
dcuai committed
25
26
27
28
29
30
31
32
33
34
35
36

```
docker pull image.sourcefind.cn:5000/dcu/admin/base/pytorch:2.1.0-ubuntu20.04-dtk24.04.2-py3.10
docker run -it --shm-size=128G -v /path/your_code_data/:/path/your_code_data/ -v /opt/hyhal:/opt/hyhal:ro --privileged=true --device=/dev/kfd --device=/dev/dri/ --group-add video --name inceptionv3_pytorch  <your IMAGE ID> bash # <your IMAGE ID>为以上拉取的docker的镜像ID替换
```
### Dockerfile(方法二)
此处提供dockerfile的使用方法
```
docker build --no-cache -t inceptionv3:latest .
docker run -it --shm-size=128G -v /path/your_code_data/:/path/your_code_data/ -v /opt/hyhal:/opt/hyhal:ro --privileged=true --device=/dev/kfd --device=/dev/dri/ --group-add video --name inceptionv3_pytorch bash
```
### Anaconda(方法三)
chenzk's avatar
chenzk committed
37
关于本项目DCU显卡所需的特殊深度学习库可从[光合](https://developer.sourcefind.cn/tool/)开发者社区下载安装。
dcuai's avatar
dcuai committed
38
39
40
41
42
43
44
```
DTK驱动:dtk24.04.2
python:python3.10
torch: 2.1.0
torchvision: 0.16.0
```
`Tips:以上dtk驱动、python、torch等DCU相关工具版本需要严格一一对应`
wanglch's avatar
wanglch committed
45

sunxx1's avatar
sunxx1 committed
46
## 数据集
wanglch's avatar
wanglch committed
47

sunxx1's avatar
sunxx1 committed
48
在本测试中可以使用ImageNet数据集。
chenzk's avatar
chenzk committed
49
数据集快速下载中心:[ImageNet2012](https://www.image-net.org/challenges/LSVRC/2012/index.php)
dcuai's avatar
dcuai committed
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
可参考[data/extract_ILSVRC.sh](https://developer.sourcefind.cn/codes/modelzoo/inceptionv3_pytorch/-/blob/master/data/extract_ILSVRC.sh)处理数据集,处理后数据集结构如下:
```
data
└── imagenet
    ├── train
    │   ├── n01440764
    │   │   ├── n01440764_10026.JPEG
    │   │   ├── n01440764_10027.JPEG
    ├──val
    │   ├── n01440764 
    │   │   ├── ILSVRC2012_val_00000293.JPEG
    ├── meta
    │   ├── train.txt
    │   └── val.txt
```
wanglch's avatar
wanglch committed
65

dcuai's avatar
dcuai committed
66
## 训练
sunxx1's avatar
sunxx1 committed
67

dcuai's avatar
dcuai committed
68
69
70
训练命令:
```
    chmod +x inception_v3.sh
sunxx1's avatar
sunxx1 committed
71
    ./inception_v3.sh ${isperf} ${output_json} ${ngpu}
dcuai's avatar
dcuai committed
72
73
74
75
76
77
78
79
    例如:HIP_VISIBLE_DEVICES=4,5,6,7 ./inception_v3.sh 0 output.json 4
```
${isperf}=0时,执行main.py;${isperf}=1时,执行perf.py

## result
<div align=center>
    <img src="images/result.png"/>
</div>
sunxx1's avatar
sunxx1 committed
80

dcuai's avatar
dcuai committed
81
### 精度
sunxx1's avatar
sunxx1 committed
82
83
84

测试数据使用的是ImageNet数据集,使用的加速卡是DCU Z100L。

sunxx1's avatar
sunxx1 committed
85
86
87
88
| 卡数 |           精度            |
| :--: | :-----------------------: |
|  8   | top1:0.73888;top5:0.90528 |

dcuai's avatar
dcuai committed
89
90
91
92
93
## 应用场景
### 算法类别
`图像分类`
### 热点应用行业
`科研,制造,医疗,教育`
wanglch's avatar
wanglch committed
94
95

## 预训练权重
chenzk's avatar
chenzk committed
96
[inception_v3](https://drive.google.com/drive/folders/17ju2HN7Y6pyPK2CC_AqnAfTOe9_3hCQ8?usp=sharing)
wanglch's avatar
wanglch committed
97

dcuai's avatar
dcuai committed
98
## 源码仓库及问题反馈
chenzk's avatar
chenzk committed
99
- https://developer.sourcefind.cn/codes/modelzoo/inceptionv3_pytorch
dcuai's avatar
dcuai committed
100
101
## 参考资料
- https://github.com/Lornatang/InceptionV3-PyTorch.git