赞
踩
1,熟悉训练数据集;
2,加载本地车牌数据集;
3,定义网络模型;
4,输入数据集训练模型;
5,保存模型在线推理;
6,GUI可视化 ;
本项目所有的数据都是基于CCPD2019数据集,CCPD2019数据集包含了25万多幅中国城市车牌图像和车牌检测与识别信息的标注,主要采集于合肥市,采集人员手持Android POS机对停车场的车辆拍照进行数据采集。所拍摄的车牌照片涉及多种复杂环境,包括模糊、倾斜、雨天、雪天等。具体分类如下
类别 | 描述 | 数量级 |
---|---|---|
CCPD-base | 通用车牌图片 | 200k |
CCPD-blur | 由于摄像机镜头抖动导致的模糊车牌图片 | 5k |
CCPD-challenge | 在车牌检测识别任务中较有挑战性的图片 | 10k |
CCPD-db | 车牌区域亮度较亮、较暗或者不均匀 | 20k |
CCPD-fn | 车牌离摄像头拍摄位置相对较近或较远 | 20k |
CCPD-np | 没有安装车牌的新车图片 | 3k |
CCPD-rotate | 车牌水平倾斜20到50度,竖直倾斜-10到10度 | 10k |
CCPD-tilt | 车牌水平倾斜15到45度,竖直倾斜15到45度 | 10k |
CCPD-weather | 车牌在雨雪雾天气拍摄得到 | 10k |
同目录下的splits文件夹包含各类别的标签 ,包含了由CCPD-Base中的图像被拆分成的训练train集,验证val集,测试test则由非CCPD-Base中的图像组成。
CCPD数据集里面的每张图像的文件名就是该图像对应的数据标注。例如图片
ccpd_base\01-86_91-298&341_449&414-458&394_308&410_304&357_454&341-0_0_14_28_24_26_29-124-24.jpg的文件名可以由分割符’-'分为多个部分:
在知道数据大体情况和每张图片携带的信息后,其实可以情景再现,下面任选一张图片,提取像素信息和位置信息和内容信息进行展示以便更好的掌握数据集具体情况。
# -*- encoding: utf-8 -*- ''' @Project : license_plate @Desc : 车牌识别,包括车牌语义分割,车牌识别 @Time : 2023/04/19 20:42:53 @Author : 帅帅de三叔,zengbowengood@163.com ''' import os from PIL import Image, ImageDraw, ImageFont provincelist = [ "皖", "沪", "津", "渝", "冀", "晋", "蒙", "辽", "吉", "黑", "苏", "浙", "京", "闽", "赣", "鲁", "豫", "鄂", "湘", "粤", "桂", "琼", "川", "贵", "云", "西", "陕", "甘", "青", "宁", "新"] wordlist = [ "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"] def DrawBox(im, box): #车牌边框 draw = ImageDraw.Draw(im) draw.rectangle(box, outline='red', width=3) def DrawPoint(im, points):#绘制车牌四个边界点 draw = ImageDraw.Draw(im) for p in points: radius =3 draw.ellipse((p[0]-radius, p[1]-radius, p[0]+radius, p[1]+radius), fill='green') def DrawLable(im, label): #绘制车牌 draw = ImageDraw.Draw(im) font = ImageFont.truetype('simsun.ttc', 64) draw.text((30, 30), label, font=font, fill='red') def ImgShow(imgpath, box, points, label): #显示效果 im = Image.open(imgpath) DrawBox(im, box) DrawPoint(im, points) DrawLable(im, label) im.show() im.save(r"D:\项目\车牌\result.jpg") if __name__=="__main__": imgpath = r"D:\项目\车牌\CCPD\CCPD2019\ccpd_base\01-86_91-298&341_449&414-458&394_308&410_304&357_454&341-0_0_14_28_24_26_29-124-24.jpg" im = Image.open(imgpath) imgname = os.path.basename(imgpath).split('.')[0] _,_,box, points,label,brightness,blurriness = imgname.split('-') box = box.split('_') box= [tuple(map(int, i.split('&'))) for i in box] # DrawBox(im, box) # im.show() #显示带车牌框的图片 points = points.split('_') points = [tuple(map(int, i.split('&'))) for i in points] # DrawPoint(im, points) # im.show() label = label.split('_') province = provincelist[int(label[0])] word = [wordlist[int(i)] for i in label[1:]] label = province+''.join(word) # print(label) # DrawLable(im, label) # im.show() ImgShow(imgpath,box,points,label)
展示效果如下
从展示效果图可以看到车牌框圈出来了,车牌四个角也用绿色点描上了,车牌内容也在左上角标注了,是不是对数据集有了更深的了解呢?
参考文献
1,CCPD车牌数据集介绍
https://blog.csdn.net/LuohenYJ/article/details/117752120
https://blog.csdn.net/guyuealian/article/details/128704181
2,图像语义分割
https://huggingface.co/docs/transformers/tasks/semantic_segmentation
3,基于深度学习的车牌检测识别(Pytorch)(ResNet +Transformer)
https://blog.csdn.net/weixin_48866452/article/details/120319588
4,pytorch加载自己的图片数据集的两种方法
https://blog.csdn.net/qq_53345829/article/details/124308515
5,pytorch的 Custom Dataset
https://pytorch.org/tutorials/beginner/basics/data_tutorial.html
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。