Traffic Sign Classification using Residual Networks(ResNet)

栏目: IT技术 · 发布时间: 5年前

内容简介:Deep Convolutional Neural Networks(CNNs)are widely used to solve various computer vision tasks in the field of Artificial Intelligence. This article focuses on developing a deep learning model in order to recognize traffic signs. :x::no_entry_sign::no_pede

Deep Residual Learning to Classify Traffic Signs

Jun 6 ·4min read

Traffic Sign Classification using Residual Networks(ResNet)

Photo by Hanns Adrian Böhme on Unsplash

Deep Convolutional Neural Networks(CNNs)are widely used to solve various computer vision tasks in the field of Artificial Intelligence. This article focuses on developing a deep learning model in order to recognize traffic signs. :x::no_entry_sign::no_pedestrians::no_bicycles:

Table of Contents

  • Data Analysis
  • Create a ResNet Model
  • Model Training
  • Model Evaluation
  • Predictions
  • References

First of all, we need a dataset to train the deep learning model to recognize traffic signs. Kaggle Datasets is the best platform to find datasets for different tasks. Such as Machine Learning(ML), Deep Learning(DL), and Data Science.

Here is one of the datasets contains nearly 73,139 diverse images of traffic signs of 43 classes.

Data Analysis

In this section, we are going to use a simple way to analyze the dataset.

Here is a simple count plot to analyze the spread of data in classes. The below code is used to plot the graph:

Traffic Sign Classification using Residual Networks(ResNet)

Countplot w.r.t to classes

Let’s visualize some of the samples from the dataset. This will help us to understand the data. The below code serves the purpose by plotting 100 images from the dataset.

Traffic Sign Classification using Residual Networks(ResNet)

Images from the Dataset

Create a ResNet Model

In this section, we are going to create a deep learning model to recognize traffic signs.

Residual Network(ResNet)

Microsoft introduced the deep residual learning framework to overcome the ‘degradation’ problem which is a hard optimization task. The shortcut connections i.e., skipping one or more layers as shown in the below figure.

Traffic Sign Classification using Residual Networks(ResNet)

Skip Connection in Residual Networks

These shortcut connections perform identity mapping and the outputs are added to the outputs of stacked layers. This has solved many problems such as :

  • Easy to optimize
  • It gains accuracy from greatly increased depth, producing results that are better than previous network architectures.

For a better understanding of deep residual learning. Use the research paper entitled ‘Deep Residual Learning for Image Recognition’ which is freely available on arxiv.

We are going to use the TensorFlow applications module which provides different popular deep learning models with pretrained weights to use.

We are going to use ResNet50 architecture without pretrained weights. We add the dense layer with softmax activation at the end to predict the classes. Below is used to create the model.

You can see the visualization of the model created using the plot_model method.

Model Training

These are the parameters used during the training process. The batch size as 32, epochs 50, learning rate as 0.001, loss metric ‘Categorical Cross Entropy’, optimizer as ‘Adam’. The callbacks ModelCheckpoint, EarlyStopping, ReduceLROnPlateau, and CSVLogger are used in the training of the ResNet50 model. You can use the below link for understanding the nuts and bolts of callbacks.

The below code is used to compile and fit the model.

The graphs between accuracy over epochs on training and validation data.

Traffic Sign Classification using Residual Networks(ResNet)

Accuracy Graph

The graph between loss over epochs on training and validation data.

Traffic Sign Classification using Residual Networks(ResNet)

Loss Graph

You can see the loss and accuracy converges after 20 epochs.

Model Evaluation

Classification Report

Let’s see the classification report which helps to evaluate the model.

The output results in the form precision, recall, F1 score with respect to each class.

Confusion Matrix

The confusion matrix is used to describe the performance of the classification model. The below code is used to generate confusion matrix:

The resultant confusion matrix is shown below:

Traffic Sign Classification using Residual Networks(ResNet)

Confusion Matrix

Classwise Accuracy

The classwise accuracy can be derived using the below code:

Predictions

Few samples from the unseen data are used for predicting the class labels using the trained ResNet50 model. The below code is used for this purpose:

The prediction of the unseen data is shown below:

Traffic Sign Classification using Residual Networks(ResNet)

Predictions

The code that I have written for the task is available as Kaggle Notebook. Feel free to use it. Here is the link:

References


以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

CSS权威指南(第三版·英文影印版)

CSS权威指南(第三版·英文影印版)

[美] Eric A.Meyer / 东南大学出版社 / 2007-06 / 68.00元

著名的CSS专家Eric A.Meyer他招牌式的智慧和无与伦比的经验引领读者探索了CSS的各个部 分,包括属性、标记、特性和实现。此外,他还就现实应用中的一些问题,例如浏览器的支持和设计方针,发表了看法。你所要知道的就是HTML 4.0的知识,这样就可以创建整洁、易于维护的脚本,以与桌面出版系统同样的优雅和控制能力管理网站布局和分页。你将会学到: 精妙地设计文本风格 用户界面、......一起来看看 《CSS权威指南(第三版·英文影印版)》 这本书的介绍吧!

HTML 压缩/解压工具
HTML 压缩/解压工具

在线压缩/解压 HTML 代码

HTML 编码/解码
HTML 编码/解码

HTML 编码/解码

Markdown 在线编辑器
Markdown 在线编辑器

Markdown 在线编辑器