如果有问题,欢迎下方评论

交通标志识别,识别效果如下所示:

该模型一共可以识别42种交通标志,其中每种交通标志对应的标签如下所示:

     0:'no traffic sign',1:'ban honking',2:'ban left',3:'ban rigth',4:'ban parking-P',5:'ban parking-X',6:'rang xing',7:'ban parking-ting',8:'ban motor vehicle',9:'ban pedestrian',10:'ban u-turn',11:'ban straight ',12:'slow down',13:'ban overtaking',14:'ban left and right',15:'limt:5',16:'limt:15',17:'limt:30',18:'limt:40',19:'limt:50',20:'limt:60',21:'limt:70',22:'limt:80',23:'limt:120',24:'straight or left',25:'straight or right',26:'left or rigth',27:'go straight',28:'go left',29:'go right',30:'motor vehicles',31:'not motor vehicles',32:'allow u-turn',33:'road of people',34:'walk',35:'roundabout',36:'attention people',37:'attention child',38:'village',39:'left turn',40:'right turn',41:'continuous crooked road',42:'crossroad'

文章最后有提供下载链接,如有需要可自行前往下载。

首先导入相关模块:

import tensorflow as tf
import numpy as np
import pandas as pd
import cv2
import matplotlib.pyplot as plt
import os
from sklearn.model_selection import train_test_split

读取图片:target.txt的内容如下所示,前面对应图片名字,后面对应图片的类别

x=[]
y=[]
with open ('./target.txt','r') as f:for j,i in enumerate(f):path=i.split()[0]lable=i.split()[1]print('读取第%d个图片'%j,path,lable)src=cv2.imread('./suju/'+path)x.append(src)y.append(int(lable))

将数据归一化,并且划训练集和验证集

x=np.array(x)
y=np.array(y)
x.shape,y.shape
y=y[:,None]
x_train,x_test,y_train,y_test=train_test_split(x,y,stratify=y,random_state=0)
#归一化
x_train=x_train.astype('float32')/255
x_test=x_test.astype('float32')/255y_train_onehot=tf.keras.utils.to_categorical(y_train)
y_test_onehot=tf.keras.utils.to_categorical(y_test)

搭建网络模型

model=tf.keras.Sequential([tf.keras.Input(shape=(80,80,3)),tf.keras.layers.Conv2D(filters=32,kernel_size=(3,3),padding='same',activation='relu'),tf.keras.layers.MaxPooling2D(pool_size=(2,2),strides=(2,2)),tf.keras.layers.Conv2D(filters=64,kernel_size=(3,3),padding='same',activation='relu'),tf.keras.layers.MaxPooling2D(pool_size=(2,2),strides=(2,2)),tf.keras.layers.Conv2D(filters=32,kernel_size=(3,3),padding='same',activation='relu'),tf.keras.layers.MaxPooling2D(pool_size=(2,2),strides=(2,2)),tf.keras.layers.Flatten(),tf.keras.layers.Dense(1000,activation='relu'),tf.keras.layers.Dropout(rate=0.5),tf.keras.layers.Dense(43,activation='softmax')
])
model.compile(loss='categorical_crossentropy',optimizer='adam',metrics=['accuracy']
)
train_history=model.fit(x_train,y_train_onehot,batch_size=100,epochs=8,validation_split=0.2,verbose=1,)

画图显示模型的loss和acc

la=[str(i) for i in range(1,9)]
def show(a,b,c,d):fig,axes=plt.subplots(1,2,figsize=(10,4))axes[0].set_title('accuracy of train and valuation')axes[0].plot(la,train_history.history[a],marker='*')axes[0].plot(train_history.history[b],marker='*')axes[0].set_xlabel('epoch')axes[0].set_ylabel('accuracy')aa=round(train_history.history[a][7],2)bb=round(train_history.history[b][7],2)axes[0].text(la[7],train_history.history[a][7],aa,ha='center',va='bottom')axes[0].text(la[7],train_history.history[b][7],bb,ha='center',va='top')#axes[0].set_xticks(la,['as','asd',3,4,5,6,7,8])
#     for x1,y1 in zip(la,train_history.history[a]):
#         y1=round(y1,2)
#         axes[0].text(x1,y1,y1,ha='center',va='bottom',fontsize=10,c='b')axes[0].legend(['train_accuracy','val_accuracy'])axes[1].set_title('loss of train and valuation')axes[1].plot(la,train_history.history[c],marker='*')axes[1].plot(train_history.history[d],marker='*')axes[1].set_xlabel('epoch')axes[1].set_ylabel('loss')cc=round(train_history.history[c][7],2)dd=round(train_history.history[d][7],2)axes[1].text(la[7],train_history.history[c][7],cc,ha='center',va='top')axes[1].text(la[7],train_history.history[d][7],dd,ha='center',va='bottom')axes[1].legend(['train_loss', 'val_loss'])#axes[1].show()show('accuracy','val_accuracy','loss','val_loss')

下面是我训练的loss和acc:

保存模型

model.save('traffic_model2.h5')

然后只需要设计一个gui界面并进行识别即可,在这里就不演示了,下载链接里面有训练好的模型,以及gui界面,只需要运行项目中的mian.py即可。

该项目的运行环境为tensorflow2.0及以上版本即可。

更新版交通标志识别,链接地址:交通标志识别—2

交通标志识别项目下载链接:下载地址

python tensorflow 交通标志识别相关推荐

  1. Python交通标志识别基于卷积神经网络的保姆级教程(Tensorflow)

    项目介绍 TensorFlow2.X 搭建卷积神经网络(CNN),实现交通标志识别.搭建的卷积神经网络是类似VGG的结构(卷积层与池化层反复堆叠,然后经过全连接层,最后用softmax映射为每个类别的 ...

  2. 交通标志识别Python+TensorFlow实现(QT界面+WEB界面)

    介绍 交通标志识别系统,采用Python+TensorFlow构建神经网络,通过对数据集图像的训练,得到模型,然后采用QT构建桌面端可视化操作软件,Django构建网页端WEB可视化操作平台.可识别5 ...

  3. Python基于YOLOv5的交通标志识别系统[源码]

    1.图片演示: 2.视频演示: [项目分享]Python基于YOLOv5的交通标志识别系统[源码&技术文档&部署视频&数据集]_哔哩哔哩_bilibili 3.标注好的数据集: ...

  4. 交通标志识别系统-tensorflow项目

    介绍 交通标志识别系统,可作为计算机类专业毕设项目.机器学习,人工智能,深度学习,模式识别项目.基于tensorflow,采用 Inception-ResNet-v2模型实现对58个类别的接近6K张交 ...

  5. python交通标志识别_YOLOv3目标检测实战:交通标志识别

    在无人驾驶中,交通标志识别是一项重要的任务.本项目以美国交通标志数据集LISA为训练对象,采用YOLOv3目标检测方法实现实时交通标志识别. 具体项目过程包括包括:安装Darknet.下载LISA交通 ...

  6. Python基于YOLOv5的交通标志识别系统[源码&技术文档&部署视频&数据集]

    1.图片演示: 2.视频演示: 3.标注好的数据集: 4.YOLO网络的构建: 网络结构是首先用Focus将计算图长宽变为原先1/4, channel 数量乘4.再用bottlenectCSP 提取特 ...

  7. 基于YOLOv5和Python开发的中国交通标志识别系统

    基于YOLOv5和Python开发的中国交通标志识别系统,可识别45种交通标志,识别率高 YID:95120644426759544cmfighting233

  8. python识别简单训练模型_Python3+OpenCV实现简单交通标志识别

    由于该项目是针对中小学生竞赛并且是第一次举行,所以识别的目标交通标志仅仅只有直行.右转.左转和停车让行. 数据集:https://pan.baidu.com/s/1sLl0CadEutv3PQXhmq ...

  9. 智能小车交通标志识别功能的实现(python,ubuntu)

    From sztu 自动化专业的小菜鸡. 1.基本介绍 交通标志识别代码存在于~\config\teleop\src\smartcar\scripts文件目录下的camera_cmd.py中. 程序说 ...

最新文章

  1. 授权管理【学习笔记】《卓有成效的管理者》 第二章 掌握自己的时间
  2. 微信朋友圈装x代码_NBA总决赛朋友圈装X图鉴:直男之间有真正的友谊吗?
  3. 实现一个 WPF 版本的 ConnectedAnimation
  4. .NET小笔记之程序集
  5. 初学__Python——用包来管理多个模块
  6. flutter 一行代码取消 返回按钮
  7. fatal: remote origin already exists.报错已成功解决
  8. python爬虫基础扫盲之URL
  9. 转载:不投简历,如何获得月薪2万的工作
  10. java 出栈_Java开发中巧妙使用链表来实现模拟栈的入栈出栈操作
  11. 冷高轮时间王思聪吃热狗windows电脑壁纸下载
  12. JS加入收藏夹操作代码
  13. 生活中的十大心理学现象
  14. Nebula3 SDK (Apr 2009)更新内容
  15. PCM与DSD究竟是什么??
  16. IOS开发-ERROR ITMS-90096: Your binary is not optimized for iPhone 5
  17. 【论文简述】Rethinking Depth Estimation for Multi-View Stereo: A Unified Representation(CVPR 2022)
  18. 开关电源计算机仿真技术pdf,求开关电源的计算机仿真技术?
  19. CMD文件详解与DSP存储空间
  20. 绝了!搜狗输入法这骚操作!

热门文章

  1. 来看看Google的未来工作环境设计,有你喜欢的元素吗?
  2. Qt 绘制图片自适应窗口大小(QImage,QPixmap,QLabel)
  3. 关于JAVA中的IO模型
  4. R语言ggplot2可视化可视化排序的棒棒糖图、类似于排序的条形图(Lollipop Chart)、为可视化图像添加标题和副标题、题注信息、自定义轴坐标文本的角度
  5. “FOR loop contains no keywords”问题解决
  6. MongoDB和Node.js的Mongoose简介
  7. React使用“re-resizable”实现dom的拉伸缩放效果
  8. docker+网桥+redis主从+哨兵模式
  9. Element的Notification通知自定义样式手动关闭直接渲染带html格式的字符串
  10. 分布式系统的分类总结