README.md 2.05 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
11
采用ONNXRuntime框架使用DCU进行推理,下面介绍如何运行python代码示例,Python示例的详细说明见Doc目录下的Tutorial_Python.md。

yangql's avatar
yangql committed
12
13
### 下载镜像

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

```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
29
# 进入resnet50 ort工程根目录
yangql's avatar
yangql committed
30
31
32
33
34
35
36
37
cd <path_to_resnet50_ort> 

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

# 安装依赖
pip install -r requirements.txt
```
yangql's avatar
yangql committed
38
39
40
41
42
### 下载模型

```python
sh ./Resource/Models/download.sh
```
yangql's avatar
yangql committed
43
44
45
46
47
48
49
50
51

### 运行示例

```python
python Classifier.py
```

## C++版本推理

yangql's avatar
yangql committed
52
采用ONNXRuntime框架使用DCU进行推理,下面介绍如何运行C++代码示例,C++示例的详细说明见Doc目录下的Tutorial_Cpp.md。
yangql's avatar
yangql committed
53
54
55

### 下载镜像

yangql's avatar
yangql committed
56
在光源中下载ONNXRuntime推理框架镜像: 
yangql's avatar
yangql committed
57
58
59
60
61
62
63
64
65
66
67
68

```
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
```

yangql's avatar
yangql committed
69
70
71
72
73
### 下载模型

```python
sh ./Resource/Models/download.sh
```
yangql's avatar
yangql committed
74
75
76
77
78
79
80
81
82
83
84
85
86
87

### 安装OpenCV并构建工程

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

rbuild build -d depend
```

### 设置环境变量

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

```
yangql's avatar
yangql committed
88
export LD_LIBRARY_PATH=<path_to_resnet50_ort>/depend/lib64/:$LD_LIBRARY_PATH
yangql's avatar
yangql committed
89
90
91
92
93
94
95
96
97
98
99
```

然后执行:

```
source ~/.bashrc
```

### 运行示例

```python
yangql's avatar
yangql committed
100
# 进入resnet50 ort工程根目录
yangql's avatar
yangql committed
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
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