Deep Learning CNN Model to Auto-Detect Vehicle’s Number Plate Using Python and Flask API

In this article, I am going to show you how you can create CNN Model or Deep Learning Model for Vehicle’s Number Plate Detection System that will get the owner’s information using Python and Flask API.

In this task :
👉Create a model that will detect a car in a live stream or video and recognize characters on the number plate of the car.
👉Secondly, it will use the characters and fetch the owner’s information using RTO APIs.
👉Create a Web portal where all this information will be displayed (using HTML, CSS, and JS).

Prerequisite: →

  1. Python and Deep Learning Libraries Installed OR (You can use Google Colab)

Code Part-1

(Vehicle’s Number Plate Detection)

The following tasks will be performed in the above code:

  1. First of all, the important libraries are imported like NumPy, cv2, and matplotlib.

Code Part-2

(Displaying the Image)

The following tasks will be performed in the above code:

  1. The above code is used to display the image.

Code Part-3

(Preprocessing Image)

Code Part-4

( Segmentation of Image’s Characters)

Now this part is the Preprocessing of the Image i.e (Number Plate of Vehicle)

Code Part-5

(Image Augmentation and Calculate Accuracy)

Now it’s time to get the training dataset and validation dataset and create a model. We have generated our data that is the preprocessed images dataset from previous steps.

Code Part-6

(Creating and Training the Model)

Code Part-7

Code Part-8

(Getting Vehicle’s Owner Information)

Now the last part is to test the model using the API to get the vehicle’s information.

Flask Web App

Now we will convert the above Deep Learning code into a Flask WebApp.

Code for Getting Vehicle’s Owner Info (prediction.py)

Now this is the main app.py file for Flask

The functionality of this code is to:

  1. Get the HTML file index.html and render it.

Index.html code

This is a simple HTML file with a background image with some heading and a submit button where you can submit your image or video to test the model.

CarDetails.html code

This HTML file will get the output given by the API and place it within the placeholders and output the details as shown below.

CarDetails.html output

Thanks for Reading !!

Keep Learning !! Keep Sharing !!

You can contact me on:

LinkedIn emailme

ARTH-School of technology, BCA graduate