
Explore number plate recognition using deep learning and object detection, with OCR to extract text; build a Python web app using OpenCV, TensorFlow 2, Tesseract OCR, and Flask.
Learn to handle programming errors confidently by reading the final error message, identifying the faulty line, checking variables and data types, and using Q&A support.
GitHub URL: https://github.com/tzutalin/labelImg
Extract the zip and follow OS-specific dependency instructions for the image annotation tool. In the Anaconda prompt, navigate to the label image directory, install packages, then launch the GUI.
Label images with the annotation tool using Pascal VOC, drawing a rectangle around the number plate, labeling it, and saving the XML for each image.
Parse xml files to extract object bounding box coordinates (x_min, y_min, x_max, y_max) and save them to a csv using pandas in a Jupyter Notebook.
Load labels.csv, extract image paths from XML, and prepare bounding box data for object detection by joining file paths with the images directory.
Learn data preprocessing for license plate detection, including loading and converting images to arrays, setting target sizes, normalizing inputs and labels, and preparing data for model training.
Download the
1. "Images" folder with xml files
2. Jupyter Notebook : "02_Object_Detection.ipynb"
3. label.csv
Compile the model by setting the learning rate, using the Adam optimizer, and applying mean squared error loss, then review the inception resnet-inspired architecture before training.
Train an object detection model after compiling it, using tensorboard callbacks, a log directory, and fitting with x_train, y_train, and 100 epochs for validation data.
Denormalize outputs by scaling x_min/x_max with the image width and y_min/y_max with the image height, convert to integers, and verify coordinates for license plate detection.
Draw a bounding box on an image using two diagonal points, compute x_min, y_min, x_max, y_max, and render it with cv2 rectangle to visualize the license plate.
create a pipeline for YOLO license plate detection that combines preprocessing, predictions, denormalization, data type conversion, and bounding box drawing to output an image and coordinates.
Install tesseract ocr for license plate text extraction, guiding users through download, installation, and configuring environmental paths for Python integration with open source software.
Install pytesseract via the Anaconda prompt as administrator using pip install --upgrade pytesseract. Open the Python shell and import pytesseract to confirm installation; if no errors appear, installation is successful.
Apply Tesseract OCR to an image, crop to the detected bounding box coordinates to isolate the number plate, and extract the text with pytesseract.
https://reader.elsevier.com/reader/sd/pii/S187705091500383X?token=445782E737ABE4A7258278A0274E98CC2049FD220E199218078C24F856DEB35F78DC8026A0DED4F63CADC8C03EC7C9E4&originRegion=eu-west-1&originCreation=20211213141326
https://www.pyimagesearch.com/2017/02/20/text-skew-correction-opencv-python/
Install Visual Studio Code from the official site, run as administrator, and install essential extensions like autocomplete, Anaconda extension pack, Bootstrap 4, Django, Flask, and HTML snippet to streamline development.
Create your first Flask app by installing Flask, setting up a project in Visual Studio Code, defining a route, and running the server to display Hello world on localhost:5000.
Learn to import Bootstrap five by copying the css and js links from the official site into your template, using the cdn URLs for Bootstrap in your project.
Build a web app interface for license plate OCR by styling a dark Bootstrap navbar, container, and brand text reading 'number plate OCR', with home routing.
Create a footer with the footer tag, add a horizontal line and an anchor link to a site, then save and refresh the browser to view the navbar and footer.
Master template inheritance in Flask by using a shared layout.html and an index.html with Jinja2 blocks, extends, and a body block to organize page content.
Design an html upload form using post and multipart form data to upload a file, with a file input named image_name and an upload button.
Write Flask backend to receive uploaded files via post, save them to a static/upload folder, and return the result. Handle file name extraction and post and get methods.
integrate a deep learning object detection model into a Flask app to run predictions on uploaded images, returning detected bounding boxes and optical character recognition text from the license plate.
Integrate a yolo-based license plate detection with optical character recognition in a Flask app by importing the recognition module, saving uploads to static, and extracting text from detected bounding boxes.
Display license plate detection output by integrating the deep learning model with the Flask app and rendering uploaded images, predicted images, and extracted text on a front end HTML page.
Display uploaded and cropped license plate images with their text in a styled html table, using image-fluid sizing and 100% width in a simple flask web app.
There is slight difference in path setting for MAC and Linux users, Please find the data preparation code.
Create a data_images folder with train and test subfolders, copy images into each set, and generate label files containing class id, center x, center y, width, height for YOLO.
Learn how to organize labeled images for data preparation by copying images into the training and test folders and downloading resources for your project.
Create a data.yaml file for YOLO data, define a single class named license plate, and specify train, validation, and test paths for license plate images.
Explore the hardware and cloud limits of training YOLO for license plate detection, including CPU and memory constraints and the 12-hour free Google Colab limit for educational use.
Clone Ultralytics YOLO v5, install requirements, and upload data in Google Colab. Train the YOLO model to detect license plates and extract text.
Train and export a YOLO license plate detection model for OpenCV compatibility, using training weights and export scripts to generate formats such as TensorFlow Lite.
Learn to run a trained YOLO model to predict bounding boxes on test images, configure 640 by 640 input, and extract text from detections.
Load a YOLO model in OpenCV, convert images to YOLO format, and run a blob forward to produce bounding boxes, confidences, and class probabilities for number plates.
Apply confidence and probability thresholds to filter YOLO detections, compute bounding box coordinates, and perform non-maximum suppression with OpenCV to yield three meaningful license plate boxes.
Apply non maximum suppression to select bounding boxes, then draw magenta rectangles and overlay confidence scores on the image to visualize license plate detections.
Build modular functions for YOLO license plate detection: get predictions, apply non maximum suppression, and draw results, forming a complete prediction pipeline tested on sample images.
extracts text from license plates by cropping the region of interest from the bounding box, then cleans and displays the detected text in real time.
Welcome to NUMBER PLATE DETECTION AND OCR: A DEEP LEARNING WEB APP PROJECT from scratch
Image Processing and Object Detection is one of the areas of Data Science and has a wide variety of applications in the industries in the current world. Many industries looking for a Data Scientist with these skills. This course covers modeling techniques including labeling Object Detection data (images), data preprocessing, Deep Learning Model building (InceptionResNet V2), evaluation, and production (Web App)
We start this course Project Architecture that was followed to Develop this App in Python. Then I will show how to gather data and label images for object detection for Licence Plate or Number Plate using Image Annotation Tool which is open-source software developed in python GUI (pyQT).
Then after we label the image we will work on data preprocessing, build and train deep learning object detection model (InceptionResnet V2) in TensorFlow 2. Once the model is trained with the best loss, we will evaluate the model. I will show you how to calculate the
Intersection Over Union (IoU)
The precision of the object detection model.
Once we have done with the Object Detection model, then using this model we will crop the image which contains the license plate which is also called the region of interest (ROI), and pass the ROI to Optical Character Recognition API Tesseract in Python (Pytesseract). In this model, I will show you how to extract text from images. Now, we will put it all together and build a Pipeline Deep Learning model.
In the final module, we will learn to create a web app project using FLASK Python. Initially, we will learn basics concepts in Flask like URL routing, render the template, template inheritance, etc. Then we will create our website using HTML, Bootstrap. With that we are finally ready with our App.
WHAT YOU WILL LEARN?
Building Project in Python Programming
Labeling Image for Object Detection
Train Object Detection model (InceptionResNet V2) in TensorFlow 2.x
Model Evaluation
Optical Character Recognition with Pytesseract
Flask API
Flask Web App Development in HTML, Boostrap, Python
Train YOLO model with Custom data
Develop web application and integrate YOLO Model
We know that Computer Vision-Based Web App is one of those topics that always leaves some doubts. Feel free to ask questions in Q & A and we are very happy to answer all your questions.
We also provided all Notebooks, py files in the resources which will useful for reference.