You are on page 1of 63

ACE ENGINEERING COLLEGE

GENDER DETECTION AND ADVERTISEMENT


RECOMMENDATION FROM VOICE RECOGNITION
Mini Project Report

Submitted in partial fulfillment of the requirements for the award of the Degree of

Bachelor of Technology (B.Tech)

In

DEPARTMENT OF CSE (ARTIFICIAL INTELLIGENCE & MACHINE LEARNING)

By

B.RASHMITHA 20AG1A6608
S.MANJUNADHA 20AG1A6653
MD.JUNAID 20AG1A6640

Under the Esteemed Guidance of


Mrs.G Mounika
Assistant Professor

Department of CSE (Artificial Intelligence & Machine Learning)


ACE ENGINEERING COLLEGE

An Autonomous Institution

(NBA ACCREDITED B.TECH COURSES: EEE, ECE,MECH, CIVIL & CSE, ACCORDED NAAC ‘A’
GRADE)

(Affiliated to Jawaharlal Nehru Technological University, Hyderabad, Telangana)

Ghatkesar, Hyderabad – 501301

DECEMBER 2023

i
ACE ENGINEERING COLLEGE

ACE
Engineering College
An Autonomous Institution

(NBA ACCREDITED B. TECH COURSES: EEE, ECE, MECH, CIVIL & CSE, ACCORDED NAAC ‘A’ GRADE)

(Affiliated to Jawaharlal Nehru Technological University, Hyderabad, Telangana)

Ghatkesar, Hyderabad – 501 301

Website : www.aceec.ac.in
E-mail: info@aceec.ac.in

CERTIFICATE

This is to certify that the Mini Project work entitled “GENDER DETECTION AND ADVERTISEMENT
RECOMMENDATION FROM VOICE RECOGNITION” is being submitted by B.Rashmitha
(20AG1A6608), S.Manjunadha (20AG1A6653), Md.Junaid (20AG1A6640) in partial fulfillment for the
award of Degree of BACHELOR OF TECHNOLOGY in DEPARTMENT OF CSE (ARTIFICIAL
INTELLIGENCE & MACHINE LEARNING) to the Jawaharlal Nehru Technological University,
Hyderabad during the academic year 2023-24 is a record of Bonafide work carried out by him under our
guidance and supervision. The results embodied in this report have not been submitted by the student to any
other University or Institution for the award of any degree or diploma.

Internal Guide Head of the Department


Mrs. G Mounika Dr. KAVITHA SOPPARI
Designation Professor and Head
Dept. of CSE (AI & ML) Dept. of CSE (AI & ML)

EXTERNAL EXAMINER

ii
ACE ENGINEERING COLLEGE

ACKNOWLEDGEMENT
We would like to express our gratitude to all the people behind the screen who have helped
us transform an idea into a real time application.

We would like to express our heart-felt gratitude to my parents without whom. We would not
have been privileged to achieve and fulfill our dreams.

A special thanks to our Secretary, Prof. Y. V. GOPALA KRISHNA MURTHY, for having
founded such an esteemed institution. We are also grateful to our beloved principal, Dr. B. L.
RAJU for permitting us to carry out this project.

We profoundly thank Dr. KAVITHA SOPPARI, Head of the Department of CSE (Artificial
Intelligence & Machine Learning), who has been an excellent guide and a great source of
inspiration for our work.
We extremely thank Mr. Shashank Tiwari Assistant Professor, Project coordinator, who
helped us in all the way in fulfilling of all aspects in completion of our Mini Project.

We are very thankful to our internal guide Mrs. G Mounika, Designation who has been an
excellent and given continuous support for the Completion of our project work.

The satisfaction and euphoria that accompany the successful completion of the task would be
great, but incomplete without the mention of the people who made it possible, whose constant
guidance and encouragement crown all the efforts with success. In this context, we would like
to thank all the other staff members, both teaching and non-teaching, who have extended their
timely help and eased our task.
B.Rashmitha (20AG1A6608)
S.Manjunadha (20AG1A6653)
Md.Junaid (20AG1A6640)

iii
ACE ENGINEERING COLLEGE

DECLARATION

This is to certify that the work reported in the present project titled “GENDER DETECTION
AND ADVERTISEMENT RECOMMENDATION FROM VOICE RECOGNITION” is a
record work done by us in the Department of CSE (Artificial Intelligence & Machine Learning), ACE
Engineering College.

No part of the thesis is copied from books/journals/internet and whenever the portion is
taken, the same has been duly referred in the text; the reported are based on the project work done
entirely by us not copied from any other source.

B.Rashmitha (20AG1A6608)
S.Manjunadha (20AG1A6653)
Md.Junaid (20AG1A6640)

iv
ACE ENGINEERING COLLEGE

v
ACE ENGINEERING COLLEGE

ABSTRACT

• Gender identification is considered to be one of the major problems in the field of signal
processing. Formerly, this problem has been solved using various image classification
techniques which typically includes information extraction from a set of images. However,
gender classification using vocal features has recently been a topic of interest to a lot of
researchers across the globe. A scrutiny of some of the human vocal features reveals that
classifying gender goes way beyond just the frequency and the pitch of a person. One of
the most challenging problems faced in machine learning is feature selection or as is
technically known as dimensionality reduction. A similar problem is faced while deciding
gender-specific traits-which serve a significant purpose in classifying the gender of a
person. This paper will inspect the efficiency and significance of machine learning
algorithms to the voice-based gender identification problem. This voice-based gender
detection can be used for classifying user and displaying related advertisement based on
the user.

vi
ACE ENGINEERING COLLEGE

INDEX
CONTENTS PAGE NO
1. INTRODUCTION.............................................................................1
Machine Learning...........................................................................................2
Deep Learning................................................................................................7
Existing System..............................................................................................10
Proposed System...........................................................................................12

2. LITERATURE-SURVEY................................................................19
About the Project.......................................................................................................20

Counter Approach.....................................................................................................21

Feasibility Analysis...................................................................................................21

3. SYSTEM REQUIREMENTS......................................................... 24
Hardware Requirements…...................................................................24
Software Requirements........................................................................ 24
4. SYSTEM ARCHITECTURE..........................................................25
Traffic sign preprocessing stage...................................................................25

5. SYSTEM DESIGN.............................................................................. 26
Introduction to UML...............................................................................26
UML Diagrams........................................................................................27
Use case Diagram.........................................................................27
Activity Diagram..........................................................................28
Sequence Diagram.......................................................................29
Architecture Diagram........................................................................................30
Class Diagram..................................................................................................30
Algorithm.........................................................................................................31
6. IMPLEMENTATION….......................................................................................33
Code Sample.................................................................................................................... 33
Data set sample................................................................................................................. 37
final output........................................................................................................................ 38

vii
ACE ENGINEERING COLLEGE

Code output....................................................................................................................... 39

7. FUTURE ENHANCEMENT AND CONCLUSION…...................44


Future Scope...................................................................................................................... 44

8. REFERENCES.......................................................................46
APPENDIX...............................................................................................47

viii
ACE ENGINEERING COLLEGE

LIST OF FIGURES
Figure Name Page No.

Convolutional neural network is transferring the image 8


Existing System Scheme 11
Fully Connected Layer 13
Convolutional Layer 13
Convolutional Filter 14
Activation Functions 15
Visualization of CNN Architecture 17
Traffic Sign Classification 21
System Architecture 25
Traffic Sign Pre-processing Stage 25
Use case Diagram 27
Activity Diagram 28
Sequence Diagram 29
Architecture Diagram 30
Class Diagram 30
CNN 32
CNN Architecture 32
The Main GUI 38
GUI Output 38
The Final Output 43

ix
ACE ENGINEERING COLLEGE

x
ACE ENGINEERING COLLEGE

CHAPTER 1
INTRODUCTION

Nowadays, there is a lot of attention being given to the ability of the car to drive itself.
One of the many important aspects for a self-driving car is the ability for it to detect traffic
signs in order to provide safety and security for the people not only inside the car but also
outside of it. The traffic environment consists of different aspects whose main purpose is to
regulate flow of traffic, make sure each driver is adhering to the rules so as to provide a safe
and secure environment to all the parties concerned. We have focused our project on the all
kinds of traffic signs and a few of the traffic signs which we have in our data set is as shown in
the figure below.

Traffic signs have a strict color scheme, which includes red, blue, and white that allow
us to distinguish traffic signs from the background scene. It is not difficult for human beings to
distinguish traffic signs from a background, so for a computer detection system, color
information is also an important feature. In the present research as red, green, blue image
(RGB) is too sensitive to illumination, color space conversion algorithms have often been
applied to traffic sign detection.

We used the data set from Kaggle.com. The data set contains more than 50,000 images
of different traffic signs. It is further classified into 43 different classes. The data set is quite
varying, some of the classes have many images while some classes have few images. The size
of the dataset is around 300 MB. The dataset has a train folder which contains images inside
each class and a test folder which we will use for testing our model.

The problem we are trying to solve has some advantages such as traffic signs being
unique thereby resulting in object variations being small and traffic signs are clearly visible to
the driver/system. The proposed approach consists of building a model using convolutional
neural networks by extracting traffic signs from an image using color information. We have
used convolutional neural networks (CNN) to classify the traffic signs.. The proposed approach
consists of building a model using convolutional neural networks by extracting traffic signs
from an image using color information. The proposed approach consists of building a model
using convolutional neural by extracting traffic signs from an image using color information.

1
ACE ENGINEERING COLLEGE

MACHINE LEARNING

Machine learning is the scientific study of algorithms and statistical models that computer
systems use to perform a specific task without using explicit instructions, relying on patterns
and inference instead. It is seen as a subset of artificial intelligence. Machine learning
algorithms build a mathematical model based on sample data, known as "training data", in
order to make predictions or decisions without being explicitly programmed to perform the
task. Machine learning algorithms are used in a wide variety of applications, such as email
filtering and computer vision, where it is difficult or infeasible to develop a conventional
algorithm for effectively performing the task. Machine learning is closely related to
computational statistics, which focuses on making predictions using computers. The study of
mathematical optimization delivers methods, theory and application domains to the field of
machine learning. Data mining is a field of study within machine learning, and focuses on
exploratory data analysis through unsupervised learning. In its application across business
problems, machine learning is also referred to as predictive analytics.

The name machine learning was coined in 1959 by Arthur Samuel. Tom M. Mitchell
provided a widely quoted, more formal definition of the algorithms studied in the machine
learning field: "A computer program is said to learn from experience E with respect to some
class of tasks T and performance measure P if its performance at tasks in T, as measured by P,
improves with experience E. This definition of the tasks in which machine learning is
concerned offers a fundamentally operational definition rather than defining the field in
cognitive terms.

This follows Alan Turing's proposal in his paper "Computing Machinery and
Intelligence, in which the question Can machines think?" is replaced with the question "Can
machines do what we (as thinking entities) can do In Turing's proposal the various
characteristics that could be possessed by a thinking machine and the various implications in
constructing one are exposed. Machine learning uses data to detect various patterns in a given
dataset. It can learn from past data and improve automatically. It is a data-driven technology.
Machine learning is much similar to data mining as it also deals with huge amount of data. .
The study of mathematical optimization delivers methods, theory and application domains to
the field of machine learning.

2
ACE ENGINEERING COLLEGE

How does Machine Learning Work?

A Machine Learning system learns from historical data, builds the prediction models, and
whenever it receives new data, predicts the output for it. The accuracy of predicted output
depends upon the amount of data, as the huge amount of data helps to build a better model
which predicts the output more accurately.

Machine learning tasks are classified into several broad categories. In supervised learning, the
algorithm builds a mathematical model from a set of data that contains both the inputs and the
desired outputs. For example, if the task were determining whether an image contained a
certain object, the training data for a supervised learning algorithm would include images with
and without that object (the input), and each image would have a label (the output) designating
whether it contained the object. In special cases, the input may be only partially available, or
restricted to special feedback Semi-supervised learning algorithms develop mathematical
models from incomplete training data, where a portion of the sample input doesn't have labels.
Classification algorithms and regression algorithms are types of supervised learning.
Classification algorithms are used when the outputs are restricted to a limited set of values.
For a classification algorithm that filters emails, the input would be an incoming email, and
the output would be the name of the folder in which to file the email. For an algorithm that
identifies spam emails, the output would be the prediction of either "spam" or "not spam",
represented by the Boolean values true and false. Regression algorithms are named for their
continuous outputs, meaning they may have any value within a range. Examples of a
continuous value are the temperature, length, or price of an object.

Reinforcement learning algorithms are given feedback in the form of positive or negative
reinforcement in a dynamic environment and are used in autonomous vehicles or in learning to
play a game against a human opponent Other specialized algorithms in machine learning
include topic modeling, where the computer program is given a set of natural language
documents and finds other documents that cover similar topics. Machine learning algorithms
can be used to find the unobservable probability density function in density estimation
problems. Meta learning algorithms learn their own inductive bias based on previous
experience. In developmental robotics, robot learning algorithms generate their own sequences
of learning experiences, also known as a curriculum, to cumulatively acquire new skills
through self-

3
ACE ENGINEERING COLLEGE

guided exploration and social interaction with humans. These robots use guidance mechanisms
such as active learning, maturation, motor synergies, and imitation.

Types of learning algorithms


The types of machine learning algorithms differ in their approach, the type of data they input
and output, and the type of task or problem that they are intended to solve.

• Supervised learning

• Unsupervised learning

• Reinforcement learning
Supervised learning
Supervised learning algorithms build a mathematical model of a set of data that
contains both the inputs and the desired outputs. The data is known as training data and
consists of a set of training examples. Each training example has one or more inputs and the
desired output, also known as a supervisory signal. In the mathematical model, each training
example is represented by an array or vector, sometimes called a feature vector, and the
training data is represented by a matrix.

Supervised learning algorithms include classification and regression. Classification


algorithms are used when the outputs are restricted to a limited set of values, and regression
algorithms are used when the outputs may have any numerical value within a range. Similarity
learning is an area of supervised machine learning closely related to regression and
classification, but the goal is to learn from examples using a similarity function that measures
how similar or related two objects are. It has applications in ranking, recommendation
systems, visual identity tracking, face verification, and speaker verification.

Supervised learning can be grouped further in two categories of algorithms:

1. Classification

2. Regression

4
ACE ENGINEERING COLLEGE

Unsupervised learning
Unsupervised learning algorithms take a set of data that contains only inputs, and find
structure in the data, like grouping or clustering of data points. The algorithms, therefore, learn
from test data that has not been labeled, classified or categorized. Instead of responding to
feedback, unsupervised learning algorithms identify commonalities in the data and react based
on the presence or absence of such commonalities in each new piece of data. A central
application of unsupervised learning is in the field of density estimation in statistics, though
unsupervised learning encompasses other domains involving summarizing and explaining data
features.

Cluster analysis is the assignment of a set of observations into subsets (called clusters)
so that observations within the same cluster are similar according to one or more predestinated
criteria, while observations drawn from different clusters are dissimilar. Different clustering
techniques make different assumptions on the structure of the data, often defined by some
similarity metric and evaluated, for example, by internal compactness, or the similarity
between members of the same cluster, and separation, the difference between clusters. Other
methods are based on estimated density and graph connectivity.

It can be further classifieds into two categories of algorithms:

3. Clustering
4. Association

Reinforcement learning:
Reinforcement learning is an area of machine learning concerned with how software
agents ought to take actions in an environment so as to maximize some notion of cumulative
reward. Due to its generality, the field is studied in many other disciplines, such as game
theory, control theory, operations research, information theory, simulation-based optimization,
multi agent systems, swarm intelligence, statistics and genetic algorithms. In machine
learning, the environment is typically represented as a Markov Decision Process (MDP).
Many reinforcement learning algorithms use dynamic programming techniques.
Reinforcement learning algorithms do not assume knowledge of an exact mathematical model
of the MDP, and are used when exact models are infeasible. Reinforcement learning
algorithms are used in autonomous vehicles or in learning to play a game against a human

5
ACE ENGINEERING COLLEGE

opponent.

6
ACE ENGINEERING COLLEGE

Prerequisites
Before learning machine learning, you must have the basic knowledge of followings so that
you can easily understand the concepts of machine learning:
Fundamental knowledge of probability and linear algebra.
The ability to code in any computer language, especially in Python language.
Knowledge of Calculus, especially derivatives of single variable and multivariate
functions.

Linear Regression in Machine Learning:


Linear regression is one of the easiest and most popular Machine Learning algorithms.
It is a statistical method that is used for predictive analysis. Linear regression makes
predictions for continuous/real or numeric variables such as sales, salary, age, product price,
etc. Linear regression algorithm shows a linear relationship between a dependent (y) and one
or more independent (y) variables, hence called as linear regression. Since linear regression
shows the linear relationship, which means it finds how the value of the dependent variable is
changing according to the value of the independent variable. The linear regression model
provides a sloped straight line representing the relationship between the variables. Consider
the below image:

Linear regression can be further divided into two types of the algorithm:

Simple Linear Regression


Multiple Linear Regression

Simple Linear Regression:


If a single independent variable is used to predict the value of a numerical dependent
variable, then such a Linear Regression algorithm is called Simple Linear Regression.

Multiple Linear regression:


If more than one independent variable is used to predict the value of a numerical
dependent variable, then such a Linear Regression algorithm is called Multiple Linear
Regression.

7
ACE ENGINEERING COLLEGE

DEEP LEARNING

Deep learning is a branch of machine learning which is completely based on artificial


neural networks, as neural network is going to mimic the human brain so deep learning is also
a kind of mimic of human brain. In deep learning, we don’t need to explicitly program
everything. The concept of deep learning is not new. It has been around for a couple of years
now. It’s on hype nowadays because earlier we did not have that much processing power and
a lot of data. As in the last 20 years, the processing power increases exponentially, deep
learning and machine learning came in the picture. A formal definition of deep learning is-
neurons, in human brain approximately 100 billion neurons all together this is a picture of an
individual neuron and each neuron is connected through thousands of their neighbors. The
question here is how we recreate these neurons in a computer. So, we create an artificial
structure called an artificial neural net where we have nodes or neurons. We have some
neurons for input value and some for output value and in between, there may be lots of
neurons interconnected in the hidden layer.

Architectures
1. Deep Neural Network: It is a neural network with a certain level of complexity
(having multiple hidden layers in between input and output layers). They are capable of
modeling and processing non-linear relationships.

2. Deep Belief Network (DBN): It is a class of Deep Neural Network. It is multi layer
belief networks.

ALGORITHM USED

Random Forest Algorithm

Random Forest is a popular machine learning algorithm that belongs to the


supervised learning technique. It can be used for both Classification and Regression
problems in ML. It is based on the concept of ensemble learning, which is a process
of combining multiple classifiers to solve a complex problem and to improve the
performance of the model.
As the name suggests, "Random Forest is a classifier that contains a number of
decision trees on various subsets of the given dataset and takes the average to improve the
8
ACE ENGINEERING COLLEGE

predictive accuracy of that dataset."


Instead of relying on one decision tree, the random forest takes the prediction from
each tree and based on the majority votes of predictions, and it predicts the final output.The
greater number of trees in the forest leads to higher accuracy and prevents the problem of
overfitting.

9
ACE ENGINEERING COLLEGE

Why should we use Random Forest?

Random Forest is a widely embraced ensemble learning technique in machine


learning, finding applications in both classification and regression tasks. Its popularity
stems from the compelling advantages it offers. One of the foremost reasons for
using Random Forest is its ability to achieve high accuracy in predicting outcomes. By
constructing multiple decision trees and combining their predictions, the model excels
at capturing intricate relationships within the data.

A notable strength of Random Forest lies in its capacity to mitigate overfitting,


a common challenge in machine learning. Unlike individual decision trees, the
ensemble nature of Random Forest ensures robustness and generalizability to new,
unseen data. This resilience is particularly valuable in situations where the dataset may
contain outliers, as Random Forests are adept at handling such anomalies by
averaging predictions across multiple trees..

Another practical aspect of Random Forest is its ability to manage missing


values within the dataset. Given its reliance on multiple trees, even if one tree has
missing values for a particular feature, the collective predictions from the other trees
remain robust. Moreover, the model provides insights into feature importance, aiding
in the interpretation of the contributions of different variables to the predictions. This
information proves valuable for feature selection and model interpretation.

The versatility of Random Forest extends to its compatibility with various types
of data, including both categorical and numerical features. Unlike certain algorithms
that require feature scaling, Random Forests operate effectively without this
preprocessing step. The ease of use and interpretability are further enhanced by the
model's simplified tuning process. While Random Forests have hyperparameters, they
are often less sensitive and easier to fine-tune compared to more complex models.

10
ACE ENGINEERING COLLEGE

Parallelization is another advantageous feature, as each tree's training in a


Random Forest is an independent task, enabling faster training on large datasets.
Additionally, the model's inherent capacity to reduce variance by averaging
predictions contributes to its robust performance in the face of noisy data.

How does Random Forest algorithm work?


The Random Forest algorithm is an ensemble learning method designed to
enhance the accuracy and robustness of predictive models. At its core, the algorithm
employs a process known as bootstrapped sampling or bagging. This involves
creating multiple random samples, or bootstrap samples, from the original dataset.
Each of these samples, generated with replacement, serves as the training set for
individual decision trees. The utilization of bootstrapped samples introduces diversity
among the trees, as some instances may be repeated or omitted in each
subset.Random Forest works in two-phase first is to create the random forest by
combining N decision tree, and second is to make predictions for each tree created in
the first phase.

The Working process can be explained in the below steps and diagram:

Step-1: Select random K data points from the training set.

Step-2: Build the decision trees associated with the selected data points (Subsets).

Step-3: Choose the number N for decision trees that you want to build.

Step-4: Repeat Step 1 & 2.

Step-5: For new data points, find the predictions of each decision tree, and assign the
new data points to the category that wins the majority votes.

The working of the algorithm can be better understood by the below example:

Example: Suppose there is a dataset that contains multiple fruit images. So, this dataset
is given to the Random forest classifier. The dataset is divided into subsets and given to
11
ACE ENGINEERING COLLEGE

each decision tree. During the training phase, each decision tree produces a prediction
result, and when a new data point occurs, then based on the majority of results, the
Random Forest classifier predicts the final decision. Consider the below image:

12
ACE ENGINEERING COLLEGE

Applications of Random Forest


Random Forest is a versatile machine learning algorithm that finds applications across
various domains due to its ability to handle complex tasks and provide robust predictions.
Here are some common applications of Random Forest:

Classification:
Random Forest is widely used for classification tasks, where the goal is to
assign a predefined label or category to input data. Applications include spam detection,
image classification, and medical diagnosis.

Regression:

In regression tasks, Random Forest can predict a continuous numerical value. This is
valuable in scenarios such as predicting house prices, stock prices, or other numerical
outcomes.

Image Recognition:

Random Forest can be employed for image recognition tasks, where it classifies
objects or patterns within images. It can be part of a broader system for object detection and
image segmentation.

Healthcare:
In healthcare, Random Forest is used for disease prediction and diagnosis. It can
analyze patient data to predict the likelihood of diseases, identify risk factors, and assist in
medical decision-making.

Finance:
Random Forest is applied in finance for tasks such as credit scoring, fraud detection,
and stock price prediction. Its ability to handle large datasets and provide accurate
predictions is particularly beneficial in financial analytics.

Remote Sensing:
In the field of remote sensing, Random Forest is utilized for land cover classification
and analysis. It can process satellite or aerial imagery to identify and classify different types
of land cover.

13
ACE ENGINEERING COLLEGE

Ecology and Environmental Sciences:


Random Forest is employed in ecological modeling to predict species distribution,
analyze biodiversity patterns, and assess the impact of environmental variables on
ecosystems

Customer Churn Prediction:


Businesses use Random Forest to predict customer churn, helping them identify
factors that contribute to customer attrition and develop strategies to retain customers.

Marketing:
Random Forest can be used for customer segmentation, targeting, and predicting the
success of marketing campaigns. It helps marketers make data-driven decisions to optimize
their strategies.

Quality Control:
In manufacturing and production, Random Forest can assist in quality control by
predicting defects or identifying factors that contribute to product defects.

Social Sciences:
Researchers in social sciences use Random Forest for tasks such as predicting voting
behavior, analyzing survey data, and studying patterns in social networks.

Anomaly Detection:
Random Forest can be effective in detecting anomalies or outliers in datasets, making
it useful for fraud detection in financial transactions or identifying unusual patterns in
cybersecurity.

14
ACE ENGINEERING COLLEGE

EXISTING SYSTEM

Many different approaches to traffic sign recognition have been proposed and it is
difficult to compare between those approaches since they are based on different data.
Moreover, some articles concentrate on the techniques used to classify the images like
Random Forest.

One of the proposed systems did this in three stages segmentation, image recognition,
image classifications which appears to be the complex method.

• Existing system worked on this using three different techniques HSV color space for
enhancement and threshold techniques are used in segmentation

• Random Forest classifier is used for image classification , SVM classifier is also
involved in image recognition stage

• Traffic sign detection and recognition are done using precision and recall curves
which is a complicated task.

The well-defined colors and shapes are two main cues for traffic sign detection. Thus,
we can divide the detection methods into two categories: color-based and shape-based. Color-
based methods are usually fast and invariant to translation, rotation and scaling. As color can
be easily affected by the lighting condition, the main difficulty of color-based methods is how
to be invariant to different lighting conditions. These methods tend to follow a common
scheme: the image is transformed into a color space and then threshold. Some authors perform
this thresholding directly in RGB (Rd Green Blue) space, even if it is very sensitive to
illumination

15
ACE ENGINEERING COLLEGE

changes. To overcome this, simple formulas relating red, green and blue components are
employed.

The existing system consists of three stages: segmentation, shape detection and
recognition. In the first stage, we aim to segment the images to extract ROIs. In the second
one, we detect the desired shapes from the ROIs. In the last stage, we recognize the
information included in the detected traffic signs. Fig. 2 illustrates the algorithm scheme of the
proposed method. In this section, we detail each step of the proposed approach.

Fig 1.3 Existing System Scheme

DISADVANTAGES OF EXISTING SYSTEM

• Existing system worked on this using three different techniques HSV color space for
enhancement and threshold techniques are used in segmentation

• Random Forest classifier is used for image classification , SVM classifier is also
involved in image recognition stage

• Traffic sign detection and recognition are done using precision and recall curves
which is a complicated task.

PROPOSED SYSTEM

16
ACE ENGINEERING COLLEGE

There are several different types of traffic signs like speed limits, no entry, traffic
signals, turn left or right, children crossing, no passing of heavy vehicles, etc. Traffic signs
classification is the process of identifying which class a traffic sign belongs to.

In the present project, we will build a deep neural network model that can classify
traffic signs present in the image into different categories. With this model, we are able to read
and understand traffic signs which are a very important task for all autonomous vehicles. The
main advantage of CNN compared to its predecessors is that it automatically detects the
important features without any human supervision. For example, given many pictures of cats
and dogs it learns distinctive features for each class by itself. CNN is also computationally
efficient.

CONVOLUTIONAL NEURAL NETWORK

Convolutional neural networks have gained a special status over the last few years as
an especially promising form of deep learning. Rooted in image processing, convolutional
layers have found their way into virtually all subfields of deep learning, and are very
successful for the most part. The fundamental difference between fully connected and
convolutional neural networks is the pattern of connections between consecutive layers.

In a convolutional layer of a neural network, on the other hand, each unit is connected
to a (typically small) number of nearby units in the previous layer. Furthermore, all units are
connected to the previous layer in the same way, with the exact same weights and structure.
This leads to an operation known as convolution, giving the architecture its name (see Figure
1.4 for an illustration of this idea). In the next section, we go into the convolution operation in
some more detail, but in a nutshell all it means for us is applying a small “window” of weights
(also known as filters) across an image, as illustrated in Figure.

17
ACE ENGINEERING COLLEGE

Fi g 1.4.1(a) Fully Connected Layer Fig 1.4.1(b) Convolutional Layer


In a fully connected layer (left), each unit is connected to all units of the previous
layers. In a convolutional layer (right), each unit is connected to a constant number of units in
a local region of the previous layer. Furthermore, in a convolutional layer, the units all share
the weights for these connections, as indicated by the shared linetypes.

There are motivations commonly cited as leading to the CNN approach, coming from
different schools of thought. The first angle is the so-called neuroscientific inspiration behind
the model. The second deals with insight into the nature of images, and the third relates to
learning theory. We will go over each of these shortly before diving into the actual mechanics.
It has been popular to describe neural networks in general, and specifically convolutional
neural networks, as biologically inspired models of computation. At times, claims go as far as
to state that these mimic the way the brain performs computations. While misleading when
taken at face value, the biological analogy is of some interest.

Convolution
The convolution operation, as you probably expect from the name of the architecture,
is the fundamental means by which layers are connected in convolutional neural networks. We
use the built in Tensor Flow conv2d():

tf.nn.conv2d(x, W, strides=[1, 1, 1, 1], padding='SAME')

Here, x is the data — the input image, or a downstream feature map obtained further
along in the network, after applying previous convolution layers. As discussed previously, in
typical CNN models we stack convolutional layers hierarchically, and feature map is simply a
commonly used term referring to the output of each such layer. Another way to view the
output
of these layers is as processed images, the result of applying a filter and perhaps some other
operations. Here, this filter is parameterized by W, the learned weights of our network
representing the convolution filter.
18
ACE ENGINEERING COLLEGE

This is just the set of weights in the small “sliding window” we see in following figure.

Fig 1.4.1(c) Convolution Filter

The output of this operation will depend on the shape of x and W, and in our case is
fourdimensional.

The image data x will be of shape:


[None, 28, 28, 1] meaning that we have an unknown number of images, each 28×28
pixels and with one color channel

(Since these are grayscale images). The weights W we use will be of

shape: [5, 5, 1, 32]

Where the initial 5×5×1 represents the size of the small “window” in the image to be
convolved, in our case a 5×5 region. In images that have multiple color channels (RGB, as
briefly discussed we regard each image as a three-dimensional tensor of RGB values, but in
this one channel data they are just two-dimensional, and convolutional filters are applied to
two

dimensional regions.

Later, when we tackle the CIFAR10 data, we’ll see examples of multiple-channel images
and how to set the size of weights W accordingly. The final 32 is the number of feature maps.
19
ACE ENGINEERING COLLEGE

In other words, we have multiple sets of weights for the convolutional layer — in this case, 32
of them. Recall that the idea of a convolutional layer is to compute the same feature along the
image; we would simply like to compute many such features and thus use multiple sets of
convolutional filters. The strides argument controls the spatial movement of the filter W
across the image (or feature map) x.

The value [1, 1, 1, 1] means that the filter is applied to the input in one-pixel intervals
in each dimension, corresponding to a “full” convolution. Other settings of this argument
allow us to introduce skips in the application of the filter — a common practice that we apply
later — thus making the resulting feature map smaller.

Finally, setting padding to 'SAME' means that the borders of x are padded such that the
size of the result of the operation is the same as the size of x.

ACTIVATION FUNCTIONS

Following linear layers, whether convolutional or fully connected, it is common


practice to apply nonlinear activation functions (see Figure for some examples). One practical
aspect of activation functions is that consecutive linear operations can be replaced by a single
one, and thus depth doesn’t contribute to the expressiveness of the model unless we use
nonlinear activations between the linear layers.

Fig 1.4.2 Activation Functions

Pooling
It is common to follow convolutional layers with pooling of outputs. Technically,

20
ACE ENGINEERING COLLEGE

pooling means reducing the size of the data with some local aggregation function, typically
within each feature map. The reasoning behind this is both technical and more theoretical. The
technical aspect is that pooling reduces the size of the data to be processed downstream. This
can drastically reduce the number of overall parameters in the model, especially if we use fully
connected layers after the convolutional ones. The more theoretical reason for applying
pooling is that we would like our computed features not to care about small changes in
position in an image. For instance, a feature looking for eyes in the top right part of an image
should not change too much if we move the camera a bit to the right when taking the picture,
moving the eyes slightly to the center of the image. Aggregating the “eye-detector feature”.
Spatially allows the model to overcome such spatial variability between images, capturing
some form of invariance .In our example we apply the max pooling operation on 2×2 blocks
of each feature map:

tf.nn.max_pool(x, ksize=[1, 2, 2, 1], strides=[1, 2, 2, 1], padding='SAME') Dropout

The final element we will need for our model is dropout. This is a regularization trick
used in order to force the network to distribute the learned representation across all the
neurons. Dropout “turns off” a random preset fraction of the units in a layer, by setting their
values to zero during training. These dropped-out neurons are random — different for each
computation
— forcing the network to learn a representation that will work even after the dropout. This
process is often thought of as training an “ensemble” of multiple networks, thereby increasing
generalization. When using the network as a classifier at test time (“inference”), there is no
dropout and the full network is used.

THE MODEL

First, we define helper functions that will be used extensively throughout this chapter
to create our layers. Doing this allows the actual model to be short and readable (later in the
book we will see that there exist several frameworks for greater abstraction of deep learning
building blocks, which allow us to concentrate on rapidly designing our networks rather than
the somewhat tedious work of defining all the necessary elements).

model = Sequential() model.add(Conv2D(filters=32, kernel_size=(5,5),


activation='relu', input_shape=X_train.shape[1:]))
21
ACE ENGINEERING COLLEGE

model.add(Conv2D(filters=32, kernel_size=(5,5), activation='relu'))


model.add(MaxPool2D(pool_size=(2, 2))) model.add(Dropout(rate=0.25))
model.add(Conv2D(filters=64, kernel_size=(3, 3), activation='relu'))
model.add(Conv2D(filters=64, kernel_size=(3, 3), activation='relu'))
model.add(MaxPool2D(pool_size=(2, 2))) model.add(Dropout(rate=0.25))
model.add(Flatten()) model.add(Dense(256, activation='relu'))
model.add(Dropout(rate=0.5))
model.add(Dense(43, activation='softmax'))

Fig 1.4.3 Visualization of CNN architecture


This model will take slightly longer to run (but still way under an hour, even without
sophisticated hardware) and achieve an accuracy of approximately 75%. There is still a rather
large gap between this and the best known methods.

There are several independently applicable elements that can help close this gap: Model Size

Most successful methods for this and similar datasets use much deeper networks with
many more Adjustable parameters.

Additional Types of Layers and Methods


Additional types of popular layers are often used together with the layers presented here, such

22
ACE ENGINEERING COLLEGE

as Local response normalization.

Optimization Tricks

Domain Knowledge

Pre-processing utilizing domain knowledge often goes a long way. In this case that
would be good old-fashioned image processing.

Data Augmentation

Adding training data based on the existing set can help. For instance, if an image of a
dog is flipped horizontally, then it is clearly still an image of a dog (but what about a vertical
flip?). Small shifts and rotations are also commonly used. Reusing successful methods and
architectures

As in most engineering fields, starting from a time-proven method and adapting it to


your needs is often the way to go. In the field of deep learning this is often done by fine-
tuning pretrained models. The final model we will present in this chapter is a smaller version
of the type of model that actually produces great results for this dataset.

23
ACE ENGINEERING COLLEGE

CHAPTER 2

LITERATURE SURVEY

The purpose of the literature survey is to place the each work in the context of its
contribution to understanding the research problem being studied. It also identifies new ways
to interpret prior research.

In the past, a number of works have been published in the field of TSR. Most of them
include the module of detecting, tracking, and classifying images in a single pipeline while
others only specialize in some or anyone of them. Among the early works in this field a
multilayer perceptron-based classification method was proposed for TSR.

In Bahlmann, Zhu, Ramesh, Pellkofer, and Koehler (2005), a comprehensive system


for traffic sign detection, tracking, and recognition was proposed. The system detects and
tracks the traffic sign based on a combination of AdaBoost and Haar wavelet features, and
recognizes the traffic signs using Gaussian probability density modeling.In Gil-Jimenez,
Lafuente-Arroyo, Gomez-Moreno, Lopez-Ferreras, and Maldonado-Bascon (2005), a method
was proposed which segments traffic signs using color information and recognizes the shape
of traffic signs using FFT signature.

In Gao, Podladchikova, Shaposhnikov, Hong, and Shevtsova (2006), a complex human


vision based color appearance model (CIECAM97) was used to segment and classify traffic
signs. In Broggi, Cerri, Medici, Porta, and Ghisio (2007), a three-way neural network pipeline
of color segmentation, shape detection, and classification was proposed for Italian road traffic
signs recognition. In Li and Wang (2018), Faster RCNN (Ren, He, Girshick, & Sun, 2015)
and MobileNet (Howard et al., 2017) based traffic sign recognition system was proposed to
detect traffic sign and classified traffic signs using a CNN with asymmetric kernels.

In Hu, Zhu, Li, and Li (2010), SIFT was used to detect key points followed by the bag
ofwords method for traffic signs detection and lastly a Support Vector Machine for
classification. A method proposed in Hoferlin and Zimmermann (2009) created a TSR system
utilizing SIFT and SURF (Bay, Tuytelaars, & Van Gool, 2006) feature descriptors executed
on
24
ACE ENGINEERING COLLEGE

Multi-Layer Perceptron for classification. HOG based approaches for TSR include (Creusen,
Wijnhoven, Herbschleb, & de With, 2010; ssssQingsong, Juan, & Tiantian, 2010; Xie, Liu, Li,
& Qu, 2009). Apart from the carefully crafted hand-coded features, lately, it has been shown
in Antipov, Berrani, Ruchaud, and Dugelay (2015) and Sharif Razavian, Azizpour, Sullivan,
and Carlsson (2014) that learned features are just as good or better in many diverse datasets.
For traffic sign classification, a multi-class classification challenge held at the International
Joint Conference on Neural Networks (IJCNN) 2011 (Stallkamp, Schlipsing, Salmen, & Igel,
2012) paved the way for further research on TSR. During the competition, Cireşan et al.
(2012) topped the final phase of the competition with 99.46% accuracy by combining five
deep neural networks (DNNs) over each of the five different preprocessed inputs and
averaging individual predictions of each DNN which resulted in beating not only the average
human performance (98.84%) but the best individual human performance (99.22%) as well
(Stallkamp et al., 2012). In Sermanet and LeCun (2011), Sermanet et al. proposed a multiscale
architecture with a layer- skipping connection that feeds outputs of all the layers to the
classifier producing the second- highest accuracy of 98.97% during the phase-1 of the
competition. Latter on, they complemented their architecture with a 2- layer classifier and
grayscale images to push the accuracy even further to 99.17% which is better than the average
human performance. Later on, after the competition, many works came out rethinking many
aspects of the current best approaches.

ABOUT THE PROJECT

In this Project, you will learn how to train your own traffic sign classifier/recognizer
capable of obtaining over 95% accuracy using Deep Learning. In the 2020 Honda Accord
models, a front camera sensor is mounted to the interior of the windshield behind the
rearview mirror.

That camera polls frames, looks for signs along the road, and then classifies them. The
recognized traffic sign is then shown on the LCD dashboard as a reminder to the driver. It’s
admittedly a pretty neat feature and the rest of the drive quickly turned from a vehicle test
drive into a lecture on how computer vision and deep learning algorithms are used to
recognize traffic signs.

25
ACE ENGINEERING COLLEGE

This is done in two stages using CNN algorithm as shown in below figure:

Fig 2.1 Traffic Sign Classification

COUNTER APPROACH

A counter approach for real-time traffic sign detection and recognition in a real traffic
situation was proposed. First, the images of the road scene were converted to grayscale
images, and then we filtered the grayscale images with simplified Gabor wavelets (SGW),
where the parameters were optimized. The edges of the traffic signs were strengthened, which
was helpful for the next stage of the process. Second, we extracted the region of interest using
the maximally stable extremal regions algorithm and classified the superclass of traffic signs
using the support vector machine (SVM). Finally, we used convolution neural networks with
input by simplified Gabor feature maps, where the parameters were the same as the detection
stage, to classify the traffic signs into their subclasses.

FEASIBILITY ANALYSIS

The growth and recognition of project management have changed significantly over
the past few years, and these changes are expected to continue and expand. And with the
rise of

26
ACE ENGINEERING COLLEGE

project management comes the need for a feasibility study. , a feasibility analysis is used to
determine the viability of an idea, such as ensuring a project is legally and technically feasible
as well as economically justifiable. It tells us whether a project is worth the investment—in
some cases, a project may not be doable. There can be many reasons for this, including
requiring too many resources, which not only prevents those resources from performing other
tasks but also may cost more than an organization would earn back by taking on a project that
isn’t profitable.

TYPES OF FEASIBILITY STUDY

A feasibility analysis evaluates the project’s potential for success; therefore, perceived
objectivity is an essential factor in the credibility of the study for potential investors and
lending institutions. There are five types of feasibility studies separate areas that a feasibility
study examines, described below.

• Technical Feasibility
• Economic Feasibility
• Legal Feasibility
• Operational Feasibility
• Scheduling Feasibility

Technical Feasibility

This assessment focuses on the technical resources available to the organization. It


helps organizations determine whether the technical resources meet capacity and whether the
technical team is capable of converting the ideas into working systems. Technical feasibility
also involves the evaluation of the hardware, software, and other technical requirements of the
proposed system.

As an exaggerated example, an organization wouldn’t want to try to put Star Trek’s


transporters in their building— currently, this project is not technically feasible.

Economic Feasibility

27
ACE ENGINEERING COLLEGE

This assessment typically involves a cost/ benefits analysis of the project, helping
organizations determine the viability, cost, and benefits associated with a project before
financial resources are allocated. It also serves as an independent project assessment and
enhances project credibility— helping decision-makers determine the positive economic
benefits to the organization that the proposed project will provide.

Legal Feasibility

This assessment investigates whether any aspect of the proposed project conflicts with
legal requirements like zoning laws, data protection acts or social media laws. Let’s say an
organization wants to construct a new office building in a specific location. A feasibility study
might reveal the organization’s ideal location isn’t zoned for that type of business. That
organization has just saved considerable time and effort by learning that their project was not
feasible right from the beginning.

Operational Feasibility

This assessment involves undertaking a study to analyze and determine whether—and


how well— the organization’s needs can be met by completing the project. Operational
feasibility studies also examine how a project plan satisfies the requirements identified in the
requirements analysis phase of system development.

Scheduling Feasibility

This assessment is the most important for project success; after all, a project will fail if
not completed on time. In scheduling feasibility, an organization estimates how much time the
project will take to complete.

28
ACE ENGINEERING COLLEGE

CHAPTER 3
SYSTEM REQUIREMENTS

HARDWARE
REQUIREMENTS Training Mode &
Testing Mode OPERATING SYSTEM:
windows PROCESSOR : 1.7GHZ
RAM : 4GB minimum
HARD DISK : 200GB

SOFTWARE REQUIREMENTS
It is the starting point of the software development activity, as the system grows more
complex it becomes evident that, the goal of the phase is more. The software project is
initiated by the client needs.
• Tools: Spyder or Jupyter

• Operating Systems: Windows

• Language: Python

• IDE: Anaconda
• Packages: numpy, pandas, matplotlib, sklearn, Keras, PIL and image classification.

29
ACE ENGINEERING COLLEGE

CHAPTER 4

SYSTEM ARCHITECTURE

Fig 4 System Architecture


The first section is Input Image, where the images have been taken by the model and the Image
Extraction block is responsible for creating images related to traffic sign. Region processing
stage preprocesses the image as shown in below figure 4.2 and the recognized image will be
processed and passed through the CNN based extraction where the image will be classified and
identified.

4.1 TRAFFIC SIGN PREPROCESSING STAGE


This stage is the image processing procedure. Input image with natural background viewing
image is fed into the system. The image data is read both in color, and black and white mode
(Fig.4.2 (a) and (b) show color and black & white images, respectively). As the black and
white mode, image is the base image used to find the threshold of this image. This threshold is
the criterion to change an image from black and white to a binary image. Moreover, the binary
image is used to find contours and the interesting region later on.

z
Fig 4.1 Traffic Sign Preprocessing Stage
30
ACE ENGINEERING COLLEGE

CHAPTER 5
SYSTEM DESIGN
INTRODUCTION TO UML

The Unified Modelling Language allows the software engineer to express an analysis model
using the modelling notation that is governed by a set of syntactic, semantic and pragmatic
rules.

A UML system is represented using five different views that describe the system from
distinctly different perspective. Each view is defined by a set of diagram, which is as follows:

User Model View

• This view represents the system from the users’ perspective.

• The analysis representation describes a usage scenario from the end-users’ perspective.

Structural Model View

• In this model, the data and functionality are arrived from inside the system. • This

model view models the static structures.

Behavioural Model View

• It represents the dynamic of behavioural as parts of the system, depicting he interactions of


collection between various structural elements described in the user model and structural
model view.

Implementation Model View

• In this view, the structural and behavioural as parts of the system are represented as they
are to be built.

31
ACE ENGINEERING COLLEGE

Environmental Model View

• In this view, the structural and behavioural aspects of the environment in which the
system is to be implemented are represented.

UML DIAGRAMS

USE CASE DIAGRAM


To model a system, the most important aspect is to capture the dynamic behaviour. To
clarify a bit in details, dynamic behaviour means the behaviour of the system when it is
running/operating.

Use case diagrams are used to gather the requirements of a system including internal
and external influences. These requirements are mostly design requirements. So when a
system is analyzed to gather its functionalities use cases are prepared and actors are identified.
In brief, the purposes of use case diagrams can be as follows:

a. Used to gather requirements of a system.

b. Used to get an outside view of a system.


c. Identify external and internal factors influencing the system.
USE CASE DIAGRAM

Fig 5.2.1 Use Case Diagram

32
ACE ENGINEERING COLLEGE

ACTIVITY DIAGRAM
Activity diagram is another important diagram in UML to describe dynamic aspects
of the system. Activity diagram is basically a flow chart to represent the flow form one
activity to another activity. The activity can be described as an operation of the system. So
the purposes can be described as:

• Draw the activity flow of a system.


• Describe the sequence from one activity to another.
• Describe the parallel, branched and concurrent flow of the system.

Fig 5.2.2Activity Diagram

33
ACE ENGINEERING COLLEGE

SEQUENCE DIAGRAM
Sequence diagrams describe interactions among classes in terms of an exchange of
messages over time. They're also called event diagrams. A sequence diagram is a good way to
visualize and validate various runtime scenarios. These can help to predict how a system will
behave and to discover responsibilities a class may need to have in the process of modelling a
new system.

Fig 5.2.3 Sequence Diagram

34
ACE ENGINEERING COLLEGE

ARCHITECTURE DIAGRAM
Architectural model (in software) is a rich and rigorous diagram, created using
available standards, in which the primary concern is to illustrate a specific set of tradeoffs
inherent in the structure and design of a system or ecosystem. Software architects use
architectural models to communicate with others and seek peer feedback. An architectural
model is an expression of a viewpoint in software architecture.

Illustrate: the idea behind creating a model is to communicate and seek valuable
feedback. The goal of the diagram should be to answer a specific question and to share that
answer with others to (a) see if they agree, and (b) guide their work. Rule of thumb:

know what it is you want to say, and whose work you intend to influence with it.

Fig 5.3 Architecture Diagram

Class Diagram

Fig 5.4 Class Diagram

35
ACE ENGINEERING COLLEGE

ALGORITHM

Convolutional neural network

Cnns are a class of deep neural networks that can recognize and Classify particular features
from images and are widely used for analyzing visual images.

Their applications range from image and video recognition, image classification, medical
image analysis, computer vision and natural language processing.

Convolution Layers

There are three types of layers that make up the CNN which are the convolutional layers,
pooling layers, and fully-connected (FC) layers. When these layers are stacked, a CNN
architecture will be formed.

1. Convolutional Layer

This layer is the first layer that is used to extract the various features from the input images. In
this layer, the mathematical operation of convolution is performed between the input image
and a filter of a particular size m x m .

The output is termed as the feature map which gives us information about the image such as
the corners and edges. Later, this feature map is fed to other layers to learn several other
features of the input image.

2. Pooling Layer

In most cases, a convolutional layer is followed by a pooling layer. The primary aim of this
layer is to decrease the size of the convolved feature map to reduce the computational costs.

3. Fully Connected Layer

The fully connected (FC) layer consists of the weights and biases along with the neurons and

36
ACE ENGINEERING COLLEGE

is used to connect the neurons between two different layers. These layers are usually placed
before the output layer and form the last few layers of a CNN architecture.

Fig 5.5 CNN

Fig 5.5.1 CNN Architecture

37
ACE ENGINEERING COLLEGE

CHAPTER 6
IMPLEMENTATION

CODE
SAMPLE import
numpy as np import
pandas as pd
import matplotlib.pyplot as plt
!pip install opencv-python
import cv2
!pip install tensorflow
import tensorflow as tf
from PIL import
Image
from sklearn.model_selection import train_test_split
from keras.utils import to_categorical
from keras.models import Sequential, load_model
from keras.layers import Conv2D, MaxPool2D, Dense, Flatten, Dropout
import os
os.chdir('C:/project')
data = []
labels = []
# We have 43 Classes
classes = 43
cur_path = os.getcwd()
for i in range(classes):
path =
os.path.join(cur_path,'train',str(i))
images = os.listdir(path)
38
ACE ENGINEERING COLLEGE

for a in
images: try:

39
ACE ENGINEERING COLLEGE

image = Image.open(path + '\\'+


a) image = image.resize((30,30))
image = np.array(image)
data.append(image)
labels.append(i)
except Exception as
e:
print(e)
data = np.array(data)
labels = np.array(labels)
os.mkdir('training')

np.save('./training/data',data)
np.save('./training/target',labels)
data=np.load('./training/data.npy')
labels=np.load('./training/target.npy')
print(data.shape, labels.shape)
X_train, X_test, y_train, y_test = train_test_split(data, labels, test_size=0.2, random_state=0)
y_train = to_categorical(y_train, 43)
y_test = to_categorical(y_test, 43)
model = Sequential()
model.add(Conv2D(filters=32, kernel_size=(5,5),
activation='relu', input_shape=X_train.shape[1:]))
model.add(Conv2D(filters=32, kernel_size=(5,5), activation='relu'))
model.add(MaxPool2D(pool_size=(2, 2)))
model.add(Dropout(rate=0.25))
model.add(Conv2D(filters=64, kernel_size=(3, 3), activation='relu'))
model.add(Conv2D(filters=64, kernel_size=(3, 3), activation='relu'))
model.add(MaxPool2D(pool_size=(2, 2)))
model.add(Dropout(rate=0.25))
40
ACE ENGINEERING COLLEGE

model.add(Flatten())
model.add(Dense(256, activation='relu'))
model.add(Dropout(rate=0.5))
# We have 43 classes that's why we have defined 43 in the dense
model.add(Dense(43, activation='softmax'))
#Compilation of the model
model.compile(loss='categorical_crossentropy', optimizer='adam', metrics=['accuracy'])
epochs = 20
history = model.fit(X_train, y_train, batch_size=32, epochs=epochs, validation_data=(X_test,
y_test))
# accuracy
plt.figure(0)
plt.plot(history.history['accuracy'], label='training accuracy')
plt.plot(history.history['val_accuracy'], label='val accuracy')
plt.title('Accuracy')
plt.xlabel('epochs')
plt.ylabel('accuracy')
plt.legend()
plt.show()
# Loss
plt.plot(history.history['loss'], label='training loss')
plt.plot(history.history['val_loss'], label='val loss')
plt.title('Loss')
plt.xlabel('epochs')
plt.ylabel('loss')
plt.legend()
plt.show()
def testing(testcsv):
y_test = pd.read_csv(testcsv)

41
ACE ENGINEERING COLLEGE

label = y_test["ClassId"].values
imgs = y_test["Path"].values
data=[]
for img in imgs:
image = Image.open(img)
image = image.resize((30,30))
data.append(np.array(image))
X_test=np.array(data)
return X_test,label
Y_pred = np.argmax(model.predict(X_test), axis=-1)
#np.argmax(model.predict(x), axis=-1)
Y_pred
from sklearn.metrics import accuracy_score
print(accuracy_score(label, Y_pred))
model.save("./training/TSR.h5")
from PIL import
Image import numpy
as np
import matplotlib.pyplot as plt
def test_on_img(img):
data=[]
image = Image.open(img)
image = image.resize((30,30))
data.append(np.array(image))
X_test=np.array(data)
Y_pred = np.argmax(model.predict(X_test), axis=-1)
return image,Y_pred
plot,prediction = test_on_img(r'C:\project\Test\00500.png')
s = [str(i) for i in prediction]

42
ACE ENGINEERING COLLEGE

a = int("".join(s))
print("Predicted traffic sign is: ",
classes[a]) plt.imshow(plot)
plt.show()

DATASET SAMPLE
We have used the dataset from the kaggle
website. The link is below:
https://www.kaggle.com/datasets/meowmeowmeowmeowmeow/gtsrb-german-traffic-si

GTSRB - German Traffic Sign Recognition Benchmark


The German Traffic Sign Benchmark is a multi-class, single-image classification challenge held
at the International Joint Conference on Neural Networks (IJCNN) 2011. We cordially invite
researchers from relevant fields to participate: The competition is designed to allow for
participation without special domain knowledge. Our benchmark has the following
properties:

● Single-image, multi-class classification problem


● More than 40 classes
● More than 50,000 images in total
● Large, lifelike database

43
ACE ENGINEERING COLLEGE

Testing class:

Training dataset:

The final output :

Fig 6.3.1 The main GUI

44
ACE ENGINEERING COLLEGE

Fig 6.3.2 GUI Output.


Code outputs:

Defining dataset

45
ACE ENGINEERING COLLEGE

Building model

Accuracy graph

46
ACE ENGINEERING COLLEGE

loss graph

47
ACE ENGINEERING COLLEGE

TESTING AND GETTING ACCURACY S

48
ACE ENGINEERING COLLEGE

Fig 6.3.3 The final output ,that is predicting the image

49
ACE ENGINEERING COLLEGE

CHAPTER 7
FUTURE ENHANCEMENT AND CONCLUSION

FUTURE ENHANCEMET

The future enhancement for this project would be more intractable graphical user
interface. If given more time we can train the model with more data and if possible increase the
accuracy rate and decrease the loss of the model even to a very little extent.This makes the
project more versatile and gives more user interaction.
Traffic Signs are useful to all the individuals who are driving a vehicle on the road.
Traffic Signs guide the drivers for following all the traffic rules and avoid any disruption to the
pedestrians. The environmental constraints including lighting, shadow , distance (sign is quite
far), air pollution, weather conditions in addition to motion blur, and vehicle vibration which are
common in any real time system may affect the detection and thus the classification. Hence, there
is a need for further research and advancements to deal with these issues. Also, there are certain
traffic signs that may not be predicted accurately. For this, augmentation and one hot encoding
techniques can be used. Augmentation involves shifting of the image, zoom in and rotate the
images (if required).
This system helps the driver to observe the sign close to his / her eyes on the screen. This saves
the time and efforts in manually checking whether any traffic sign board is there, identifying
what type of sign it is and act accordingly. Traffic Sign Classification, thus, has a wide application
in building smarter cars like automatic driving cars, where the system automatically detects,
recognizes a traffic sign and displays it.

CONCLUSION
The proposed system is simple and does the classification quite accurately on the GTSRB dataset
as well as the newly generated one (consisting of truly existing images of all type), and finally the
model can successfully capture images and predict them accurately even if the background of the
image is not much clear. The proposed system uses Convolutional Neural Network (CNN) to
train the model. The images are pre-processed, and histogram equalization is done to enhance the
image contrast. The final accuracy on the test dataset is 93% and on the built dataset is 69%. The
web cam predictions done by the model are also accurate and take very less time. The benefits of
“Traffic Sign classification and detection system” are generally focused on driver convenience.

50
ACE ENGINEERING COLLEGE

Despite the advantages of traffic sign classification, there are drawbacks. There can be times
when the traffic signs are covered or not visible clearly. This can be dangerous as the driver
won’t be able to keep a check on his vehicle speed and can lead to accidents, endangering other
motorists or pedestrians, demanding further research.

51
ACE ENGINEERING COLLEGE

CHAPTER 8
REFERENCES

1. LeCun Y, Bengio Y, Hinton G (2015) Deep learning. Nature 521(7553):436–444

2. Plamondon R, Srihari SN (2000) Online and off-line handwriting recognition: a


comprehensive survey. IEEE Trans Pattern Anal Mach Intell 22(1):63–84

3. Tu Y, Lin Y, Wang J, Kim JU (2018) Semi-supervised learning with generative adversarial


networks on digital signal modulation classification. Comput Mater Continua 55(2):243–254

4.Wang J, Ju C, Gao Y, Sangaiah AK, Kim G (2018) A PSO based energy efficient coverage
control algorithm for wireless sensor networks. Comput Mater Continua 56(3):433– 446

52
ACE ENGINEERING COLLEGE

APPENDIX

PYTHON
Python is an interpreted high-level programming language for general-purpose
programming Created by Guido van Rossum and first released in 1991, Python has a design
philosophy that emphasizes code readability, notably using significant whitespace. It provides
constructs that enable clear programming on both small and large scales.
Python interpreters are available for many operating systems. CPython the reference
implementation of Python, is source software and has a community-based development model,
as do nearly all of its variant implementations. CPython is managed by the non-profit Python
Software Foundation.

SPYDER

Spyder is an interactive programming environment with several similarities to


MATLAB. Spyder has an editor and an interactive shell. It also has an interface for
debugging, inspectors for objects and documentation, and variable and folder explorers.

To launch Spyder, after activating your environment and updating the PYTHONPATH
variable, type: spyder Spyder will launch .There are some settings you'll probably want to
change after you launch it for the first time. Go to Preferences -> IPython Console -> Graphics
and select Backend:Qt5. Restart Spyder. This will prevent inline figure plotting (displaying
plots in a separate window). Once launched, we are good to go.

SETTING UP SPYDER THROUGH ANACONDA

Set up Anaconda and Spyder

1. Download the Anaconda Python distribution (we recommend the command line
version)

2. Install Anaconda Python Environments

Environments are a very useful Python feature. They make it easy to work with
different versions of Python and Packages without interference (cheat sheet).

53

You might also like