Commit d0d41b4a authored by liuhy's avatar liuhy
Browse files

编写readme

parent e5b8ff62
...@@ -6,12 +6,13 @@ LPR是一个基于深度学习技术的车牌识别模型,主要识别目标 ...@@ -6,12 +6,13 @@ LPR是一个基于深度学习技术的车牌识别模型,主要识别目标
模型采用LPRNet,模型结构主要包含三部分:一个轻量级CNN主干网络、基于预定位置的字符分类头部、基于贪婪算法的序列解码。此外模型使用CTC Loss和RMSprop优化器。 模型采用LPRNet,模型结构主要包含三部分:一个轻量级CNN主干网络、基于预定位置的字符分类头部、基于贪婪算法的序列解码。此外模型使用CTC Loss和RMSprop优化器。
## 数据集 ## 数据集
推荐使用一个车牌数据集[CCPD](https://github.com/detectRecog/CCPD "CCPD介绍") 推荐使用一个车牌数据集[CCPD](https://github.com/detectRecog/CCPD "CCPD官网GITHub"),也可参考[CCPD](https://blog.csdn.net/LuohenYJ/article/details/117752120 "CCPD中文版介绍"),该数据集由中科大收集,可用于车牌的检测与识别。我们提供了一个脚本cut_ccpd.py用于剪裁出CCPD数据集中的车牌位置,以便用于LPR模型的训练,在cut_ccpd.py中修改img_path和save_path即可,分别是CCPD数据集中ccpd_base文件夹的路径和剪裁出的图像保存路径。
## 训练及推理
导出onnx模型: 导出onnx模型:
python test.py --export_onnx true python test.py --export_onnx true
推理onnx模型: 推理onnx模型:
python LPRNet_ORT_infer.py python LPRNet_ORT_infer.py
## 训练及推理
## 性能和准确率数据 ## 性能和准确率数据
## 参考 ## 参考
\ No newline at end of file
# -*- coding: utf-8 -*-
# @Author: liuhy
# @Email: 17603873430@163.com
# @Date: 2023-02-28 15:14:13
# @Last Modified time: 2023-03-01 17:52:20
# coding:utf-8
import os
import cv2
import time
provinces = ['皖', '沪', '津', '渝', '冀', '晋', '蒙', '辽', '吉', '黑', '苏', '浙', '京', '闽', '赣', '鲁', '豫', '鄂', '湘', '粤', '桂', '琼', '川', '贵', '云', '藏', '陕', '甘', '青', '宁', '新', '警', '学', 'O']
alphabets = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 'L', 'M', 'N', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W','X', 'Y', 'Z', 'O']
ads = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 'L', 'M', 'N', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X','Y', 'Z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'O']
def cut_img(img_path, save_path):
images = os.listdir(img_path)
for i, image in enumerate(images):
try:
print('\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\bProcessing:%s'%i, end='',flush=True)
img = cv2.imread(os.path.join('ccpd_base', image))
info = image.split('-')
r1, r2, l1, l2 = info[3].split('_')
rx1, ry1 = r1.split('&')
lx1, ly1 = l1.split('&')
im = img[int(ly1):int(ry1), int(lx1):int(rx1)]
label_index = info[4].split('_')
label = provinces[int(label_index[0])]
label += alphabets[int(label_index[1])]
if label_index[2].isalnum():
label += ads[int(label_index[2])]
else:
label += alphabets[int(label_index[2])]
label += ads[int(label_index[3])]
label += ads[int(label_index[4])]
label += ads[int(label_index[5])]
label += ads[int(label_index[6])]
im = cv2.resize(im, (94, 24))
if os.path.exists(save_path) is False:
os.mkdir(save_path)
cv2.imencode('.jpg', im)[1].tofile(save_path + '/' + label + '.jpg')
except Exception as e:
print('wrong image:', image)
if __name__=='__main__':
img_path = 'CCPD/ccpd_base'
save_path = 'CCPD/lp_base'
cut_img(img_path, save_path)
...@@ -80,7 +80,6 @@ class my_lprnet(nn.Module): ...@@ -80,7 +80,6 @@ class my_lprnet(nn.Module):
logits = torch.cat((out1, out2, out3, out4), 1) logits = torch.cat((out1, out2, out3, out4), 1)
logits = self.container(logits) logits = self.container(logits)
logits = torch.mean(logits, dim=2) logits = torch.mean(logits, dim=2)
# logits = logits.view(self.class_num, -1)
return logits return logits
def build_lprnet(class_num, phase=False): def build_lprnet(class_num, phase=False):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment