README.md 2.41 KB
Newer Older
yangql's avatar
yangql committed
1
2
3
# ResNet50

## 模型介绍
yangql's avatar
yangql committed
4
使用ONNXRuntime推理框架对ResNet50模型进行推理。
yangql's avatar
yangql committed
5
6
7
8
9

## 模型结构
ResNet50模型包含了49个卷积层、一个全连接层。

## Python版本推理
yangql's avatar
yangql committed
10
采用ONNXRuntime框架使用DCU进行推理,模型文件下载链接:https://github.com/onnx/models/blob/main/vision/classification/resnet/model/resnet50-v2-7.onnx,执行sh ./Resource/Models/download.sh 可以下载模型并将resnet50-v2-7.onnx模型文件保存在Resource/文件夹下。下面介绍如何运行python代码示例,Python示例的详细说明见Doc目录下的Tutorial_Python.md。
yangql's avatar
yangql committed
11
12
### 下载镜像

yangql's avatar
yangql committed
13
在光源中下载ONNXRuntime推理框架镜像: 
yangql's avatar
yangql committed
14
15
16
17
18
19
20
21
22
23
24
25
26
27

```python
docker pull image.sourcefind.cn:5000/dcu/admin/base/custom:ort1.14.0_migraphx3.0.0-dtk22.10.1
```

### 设置Python环境变量

```
export PYTHONPATH=/opt/dtk/lib:$PYTHONPATH
```

### 安装依赖

```python
yangql's avatar
yangql committed
28
# 进入resnet50 ort工程根目录
yangql's avatar
yangql committed
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
cd <path_to_resnet50_ort> 

# 进入示例程序目录
cd Python/

# 安装依赖
pip install -r requirements.txt
```

### 运行示例

```python
python Classifier.py
```

## C++版本推理

yangql's avatar
yangql committed
46
采用ONNXRuntime框架使用DCU进行推理,模型文件下载链接:https://github.com/onnx/models/blob/main/vision/classification/resnet/model/resnet50-v2-7.onnx ,执行sh ./Resource/Models/download.sh 可以下载模型并将resnet50-v2-7.onnx模型文件保存在Resource/文件夹下。下面介绍如何运行C++代码示例,C++示例的详细说明见Doc目录下的Tutorial_Cpp.md。
yangql's avatar
yangql committed
47
48
49

### 下载镜像

yangql's avatar
yangql committed
50
在光源中下载ONNXRuntime推理框架镜像: 
yangql's avatar
yangql committed
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76

```
docker pull image.sourcefind.cn:5000/dcu/admin/base/custom:ort1.14.0_migraphx3.0.0-dtk22.10.1
```

### 安装Opencv依赖

```python
cd <path_to_resnet50_ort>
sh ./3rdParty/InstallOpenCVDependences.sh
```


### 安装OpenCV并构建工程

```
source /opt/dtk/env.sh

rbuild build -d depend
```

### 设置环境变量

将依赖库依赖加入环境变量LD_LIBRARY_PATH,在~/.bashrc中添加如下语句:

```
yangql's avatar
yangql committed
77
export LD_LIBRARY_PATH=<path_to_resnet50_ort>/depend/lib64/:$LD_LIBRARY_PATH
yangql's avatar
yangql committed
78
79
80
81
82
83
84
85
86
87
88
```

然后执行:

```
source ~/.bashrc
```

### 运行示例

```python
yangql's avatar
yangql committed
89
# 进入resnet50 ort工程根目录
yangql's avatar
yangql committed
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
cd <path_to_resnet50_ort> 

# 进入build目录
cd build/

# 执行示例程序
./ResNet50
```


## 源码仓库及问题反馈

https://developer.hpccube.com/codes/modelzoo/resnet50_ort

## 参考

https://github.com/onnx/models/tree/main/vision/classification/resnet