README.md 3.13 KB
Newer Older
1
# PaddleOCR车牌识别
shizhm's avatar
shizhm committed
2

3
4
## 模型介绍

Your Name's avatar
Your Name committed
5
车牌识别(Vehicle License Plate Recognition,VLPR) 是计算机视频图像识别技术在车辆牌照识别中的一种应用。车牌识别技术要求能够将运动中的汽车牌照从复杂背景中提取并识别出来,在高速公路车辆管理,停车场管理和城市交通中得到广泛应用。PaddleOCR车牌识别包括本文检测和文本识别两部分内容,其中使用DBnet作为文本检测模型,SVTR作为文本识别模型。车牌识别过程:输入->图像预处理->文字检测->文本识别->输出。
6
7
8

## 模型结构

Your Name's avatar
Your Name committed
9
DBnet是一种基于分割的文本检测方法,相比传统分割方法需要设定固定阈值,该模型将二值化操作插入到分割网络中进行联合优化,通过网络学习可以自适应的预测图像中每一个像素点的阈值,能够在像素水平很好的检测自然场景下不同形状的文字。SVTR是一种端到端的文本识别模型,通过单个视觉模型就可以一站式解决特征提取和文本转录两个任务,同时也保证了更快的推理速度。百度PaddleOCR开源项目提供了车牌识别的预训练模型,本示例使用PaddleOCR提供的蓝绿黄牌识别模型进行推理。
10

shizhm's avatar
shizhm committed
11
## Python版本推理
liucong's avatar
liucong committed
12

shizhm's avatar
shizhm committed
13
下面介绍如何运行Python代码示例,Python示例的详细说明见Doc目录下的Tutorial_Python.md。
shizhm's avatar
shizhm committed
14

shizhm's avatar
shizhm committed
15
### 下载镜像
16

Your Name's avatar
Your Name committed
17
在光源可拉取推理的docker镜像,PaddleOCR工程推荐的镜像如下:
18

Your Name's avatar
Your Name committed
19
20
21
```python
docker pull image.sourcefind.cn:5000/dcu/admin/base/custom:ort1.14.0_migraphx3.0.0-dtk22.10.1
```
22

shizhm's avatar
shizhm committed
23
### 设置Python环境变量
liucong's avatar
liucong committed
24

shizhm's avatar
shizhm committed
25
26
27
28
29
```
export PYTHONPATH=/opt/dtk/lib:$PYTHONPATH
```

### 安装依赖
liucong's avatar
liucong committed
30
31
32

```
# 进入python示例目录
shizhm's avatar
shizhm committed
33
cd <path_to_paddleocr_migraphx>/Python
liucong's avatar
liucong committed
34
35
36
37
38

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

shizhm's avatar
shizhm committed
39
40
### 运行示例

liucong's avatar
liucong committed
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
依赖安装成功之后,可在当前目录执行如下指令运行程序推理:

```
# 开启环境变量
export MIGRAPHX_DYNAMIC_SHAPE=1

# 运行示例程序
python PaddleOCR_infer_migraphx.py
```

PaddleOCR车牌识别结果为:

```
皖AD19906
```

## C++版本推理

shizhm's avatar
shizhm committed
59
60
61
下面介绍如何运行C++代码示例,C++示例的详细说明见Doc目录下的Tutorial_Cpp.md。

### 下载镜像
liucong's avatar
liucong committed
62

shizhm's avatar
shizhm committed
63
64
65
66
67
在光源中下载MIGraphX镜像: 

```
docker pull image.sourcefind.cn:5000/dcu/admin/base/custom:ort1.14.0_migraphx3.0.0-dtk22.10.1
```
liucong's avatar
liucong committed
68

Your Name's avatar
Your Name committed
69

shizhm's avatar
shizhm committed
70
### 构建工程
Your Name's avatar
Your Name committed
71
72
73

```
rbuild build -d depend
74
75
```

Your Name's avatar
Your Name committed
76
77
78
79
### 设置环境变量

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

80
```
shizhm's avatar
shizhm committed
81
export LD_LIBRARY_PATH=<path_to_paddleocr_migraphx>/depend/lib64/:$LD_LIBRARY_PATH
Your Name's avatar
Your Name committed
82
83
84
```

然后执行:
85

Your Name's avatar
Your Name committed
86
87
88
89
```
source ~/.bashrc
```

shizhm's avatar
shizhm committed
90
### 运行示例
Your Name's avatar
Your Name committed
91

liucong's avatar
liucong committed
92
成功编译PaddleOCR车牌识别工程后,执行如下命令运行该示例:
93
94

```
shizhm's avatar
shizhm committed
95
# 进入paddleocr migraphx工程根目录
shizhm's avatar
shizhm committed
96
cd <path_to_paddleocr_migraphx> 
liucong's avatar
liucong committed
97
98
99
100

# 进入build目录
cd ./build/

Your Name's avatar
Your Name committed
101
# 开启环境变量
102
103
104
export MIGRAPHX_DYNAMIC_SHAPE=1

# 运行示例
shizhm's avatar
shizhm committed
105
./PaddleOCR_VLPR
Your Name's avatar
Your Name committed
106
107
108
109
110
```

PaddleOCR车牌识别结果为:

```
shizhm's avatar
shizhm committed
111
皖AD19906
Your Name's avatar
Your Name committed
112
113
```

shizhm's avatar
shizhm committed
114
## 源码仓库及问题反馈
115
116
117
118
119
120

​		https://developer.hpccube.com/codes/modelzoo/paddleocr_migraphx

## 参考

​		https://github.com/PaddlePaddle/PaddleOCR