README.md 3.76 KB
Newer Older
sunxx1's avatar
sunxx1 committed
1
2
# ShuffleNetV2

sunxx1's avatar
sunxx1 committed
3
4
5
6
7
8
## 论文

ShuffleNet V2: Practical Guidelines for Efficient CNN Architecture Design

- https://openaccess.thecvf.com/content_ECCV_2018/papers/Ningning_Light-weight_CNN_Architecture_ECCV_2018_paper.pdf

sunxx1's avatar
sunxx1 committed
9
## 模型结构
sunxx1's avatar
sunxx1 committed
10
11
12

ShuffleNetV2 是一种轻量级神经网络模型,旨在提高深度学习模型的效率和速度。ShuffleNetV2 利用组卷积和通道重排等技术,在保持准确性的同时,将参数量和计算量大幅降低。

sunxx1's avatar
sunxx1 committed
13
14
![20231124114915](./images/20231124114915.png)

sunxx1's avatar
sunxx1 committed
15
## 算法原理
sunxx1's avatar
sunxx1 committed
16
17
18

ShuffleNetV2 的网络结构可以分为两个部分:基础网络和分类器。基础网络主要包含一系列 ShuffleNetV2 单元,用于提取图像特征;分类器则将提取的特征映射到类别概率上。

sunxx1's avatar
sunxx1 committed
19
![20231124120131](./images/20231124120131.png)
sunxx1's avatar
sunxx1 committed
20

sunxx1's avatar
sunxx1 committed
21
## 环境配置
sunxx1's avatar
sunxx1 committed
22

sunxx1's avatar
sunxx1 committed
23
### Docker(方法一)
sunxx1's avatar
sunxx1 committed
24

sunxx1's avatar
sunxx1 committed
25
26
27
28
```python
git clone --recursive http://developer.hpccube.com/codes/modelzoo/shufflenet_v2_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
29
docker run --shm-size 10g --network=host --name=shufflenet_v2 --privileged --device=/dev/kfd --device=/dev/dri --group-add video --cap-add=SYS_PTRACE --security-opt seccomp=unconfined -v $PWD/shufflenet_v2_mmcv :/home/shufflenet_v2_mmcv  -it <your IMAGE ID> bash
sunxx1's avatar
sunxx1 committed
30
31
32
33
34
35
36
37
38
39

cd shufflenet_v2_mmcv/mmclassification-mmcv
pip install -r requirements.txt
```

### Dockerfile(方法二)

```plaintext
cd shufflenet_v2_mmcv/docker
docker build --no-cache -t densenet121_mmcv:latest .
dcuai's avatar
dcuai committed
40
docker run --shm-size 10g --network=host --name=shufflenet_v2 --privileged --device=/dev/kfd --device=/dev/dri --group-add video --cap-add=SYS_PTRACE --security-opt seccomp=unconfined -v $PWD/../../shufflenet_v2_mmcv:/home/shufflenet_v2_mmcv -it <your IMAGE ID> bash
sunxx1's avatar
sunxx1 committed
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# 若遇到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安装
sunxx1's avatar
sunxx1 committed
58

sunxx1's avatar
sunxx1 committed
59
```plaintext
sunxx1's avatar
sunxx1 committed
60
61
pip install -r requirements.txt
```
sunxx1's avatar
sunxx1 committed
62

sunxx1's avatar
sunxx1 committed
63
## 数据集
sunxx1's avatar
sunxx1 committed
64

sunxx1's avatar
sunxx1 committed
65
在本测试中可以使用ImageNet数据集。
sunxx1's avatar
sunxx1 committed
66

sunxx1's avatar
sunxx1 committed
67
68
下载ImageNet数据集:https://image-net.org/

dcuai's avatar
dcuai committed
69
70
71
72
73
74
下载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
75

sunxx1's avatar
sunxx1 committed
76
```
dcuai's avatar
dcuai committed
77
78
79
80
81
82
83
84
85
data
    ├──imagenet
        ├── meta
            ├──val.txt
            ├──train.txt
            ...
        ├── train
        ├── val
  
sunxx1's avatar
sunxx1 committed
86
```
sunxx1's avatar
sunxx1 committed
87

sunxx1's avatar
sunxx1 committed
88
## 训练
sunxx1's avatar
sunxx1 committed
89
90
91

将训练数据解压到data目录下。

sunxx1's avatar
sunxx1 committed
92
### 单机8卡
sunxx1's avatar
sunxx1 committed
93
94
95

    ./shufflenet_v2.sh

dcuai's avatar
dcuai committed
96
97
98
99
100
## result

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

### 精度
sunxx1's avatar
sunxx1 committed
101
102
103

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

sunxx1's avatar
sunxx1 committed
104
105
106
107
| 卡数 |          精度           |
| :--: | :---------------------: |
|  8   | top1:0.6960;top5:0.8895 |

sunxx1's avatar
sunxx1 committed
108
109
110
111
112
113
114
115
116
117
## 应用场景

### 算法类别

图像分类

### 热点行业

制造,能源,交通,网安

dcuai's avatar
dcuai committed
118
## 源码仓库及问题反馈
sunxx1's avatar
sunxx1 committed
119

sunxx1's avatar
sunxx1 committed
120
https://developer.hpccube.com/codes/modelzoo/shufflenet_v2_mmcv
sunxx1's avatar
sunxx1 committed
121

dcuai's avatar
dcuai committed
122
## 参考资料
sunxx1's avatar
sunxx1 committed
123

dcuai's avatar
dcuai committed
124
https://github.com/open-mmlab/mmpretrain