This is my Bachelors degree project. It implements YOLOv8 and a CNN-based custom OCR model to perform Automatic Number Plate Detection (ANPR) on Indian four-wheelers.
The system is optimized to perform OCR on 2-Row Indian High Security Registration Plates (HSRNs).
The model detects 1-Row HSRNs (from Bikes) but does not perform OCR correctly.
It doesn't detect Indian Green HSRNs (for EVs) at all.
- License plate detection is handled through YOLOv8, and the model is trained in Google Colab.
- OCR is integrated directly within the license plate detection pipeline, making it seamless and efficient.
- Complete containerized solution using Docker for easy setup and deployment.
Follow the steps below to build and run the project using Docker. This setup eliminates the need to configure different environments manually, as everything is containerized and optimized for WSL.
- WSL: Ubuntu 24.04 LTS
- Docker: Install Docker and set it up on your Windows and shares with WSL system.
- NVIDIA GPU Support (Optional): Ensure Docker supports your GPU configuration and CUDA version.
- VcXsrv (For GUI support): Required to visualize outputs.
- First Clone the repo.
- Download the character model from the link: MEGA
- Put it in
weights/
folder.
-
Ensure you have Docker installed and running in WSL.
-
Use the pre-configured
Dockerfile
to create the container:FROM nvcr.io/nvidia/tensorflow:24.05-tf2-py3 # Install dependencies for GUI support RUN apt-get update && apt-get install -y --no-install-recommends \ libgl1-mesa-glx \ libglib2.0-0 \ x11-apps && \ rm -rf /var/lib/apt/lists/* # Install PyTorch with CUDA 12.4 support RUN pip install torch==2.6.0 torchvision==0.21.0 torchaudio==2.6.0 --index-url https://download.pytorch.org/whl/cu124 # Install additional Python packages RUN pip install --no-cache-dir imutils deskew ultralytics
-
Build the Docker image:
docker build -t anpr_ml .
-
Set up VcXsrv for GUI support:
-
Install VcXsrv: Download it here.
-
Launch the 'XLaunch' application with these settings:
-
-
Allow TCP connections on port 6000 in your Windows firewall.
-
Open WSL & Setup x11 apps:
sudo apt install x11-apps
-
Then Set the display variable in shell:
echo "export DISPLAY=$(ip route list default | awk '{print $3}'):0" >> ~/.bashrc echo "export LIBGL_ALWAYS_INDIRECT=1" >> ~/.bashrc source ~/.bashrc
-
Define your project folder(cloned repo) location in a variable for easier reference:
PROJECT=/path/to/your/project
-
Launch the Docker container with an optimized and simplified command:
docker run --gpus all --ipc=host --ulimit memlock=-1 --ulimit stack=67108864 \ --env DISPLAY=$DISPLAY \ --env YOLO_CONFIG_DIR=/app/ANPR/config \ --volume /tmp/.X11-unix:/tmp/.X11-unix \ -v $PROJECT:/app/ANPR \ -it --rm anpr_ml
-
Inside the container, navigate to the project directory:
cd /app/ANPR
-
Run the full detection and OCR pipeline:
python main_detection.py
-
The results, including detected license plate numbers and processed images, will be saved in the
Results/
directory.
To process videos, check the Video_Detection/
folder in the data->old_code directory. You can download sample video files here. Make sure to mount the appropriate data directories within the Docker container.
Run the corresponding detection script for videos within the container.
- Ensure VcXsrv is running and properly configured before launching the Docker container.
- To use Nvidia GPU with Docker, ensure you have the Nvidia container toolkit installed and ready.
With this Docker-based setup, the entire installation and runtime dependencies are managed for you, ensuring stability and reproducibility across environments.