This project implements a deep learning pipeline for automatic number plate detection using OpenCV for preprocessing and PyTorch for model development, training, and inference. It includes all code for loading annotated datasets, preprocessing images and labels, training a bounding box regression model, and visualizing results on test images.
Automatic Number Plate Recognition (ANPR) is an essential computer vision tool for smart transportation and surveillance. In this project, images are processed using OpenCV, and a convolutional neural network (ResNet18 backbone) is trained with PyTorch to predict the bounding boxes of number plates in vehicle images. All bounding box targets are normalized to ensure efficient regression and accurate localization.
- Loads and processes annotated datasets with OpenCV.
- Trains a lightweight PyTorch model for bounding box regression.
- Visualizes predictions and bounding boxes on test images.
- Uses TensorBoard to track loss and validation metrics.
- Code is modular for quick experimentation and transfer learning.
- Clone this repository:
git clone <your-repo-url>
cd <your-repo-directory>- Install required Python packages:
pip install torch torchvision opencv-python plotly scikit-learn pillow tensorboard- (Optional) Start TensorBoard to monitor training:
tensorboard --logdir object_detection- Dataset
- Place your annotated image dataset in the correct directory structure (e.g., /input/number-plate-detection/).
- Annotations should provide [xmin, xmax, ymin, ymax] coordinates for number plate bounding boxes per image.
- Data Preparation and Preprocessing:
- After configuring dataset paths, run the notebook or python scripts to preprocess images and labels using OpenCV and convert them to PyTorch tensors.
- Model Training:
- Execute training cells/scripts. Loss and validation metrics are logged to TensorBoard.
- Prediction and Visualization:
- Run inference on new images. Predicted bounding boxes will be rendered on the images for easy verification.
- OpenCV (image loading, visualization, preprocessing)
- PyTorch (deep learning, modeling, training, inference)
- torchvision (pretrained models, transforms)
- scikit-learn (data splitting)
- TensorBoard (training monitoring)
- Plotly (visualization)