A YOLOv5-lite based program using a custom model fine-tuned to detect French car plates, with added Optical Character Recognition (OCR) to read plates characters.
This project is based on YoloV5-lite.
Here is a short video demonstrating the program detecting and reading a french licence plate:
CarPlateDetection.webm
- Python 3.10
- pip
- Clone the repository:
git clone https://github.com/Toufik1247/CarPlateDetection.git- Install Tesseract-OCR
sudo apt update
sudo apt install tesseract-ocr
- If python3-venv is not installed, install with
sudo apt-get install python3-venv
- Create your virtual environment:
python3 -m venv venvcarplatedetection
- Activate your virtual environment:
source venvcarplatedetection/bin/activate
- Install dependencies:
cd CarPlateDetection
pip install -r requirements.txt
- Open upsampling.py in file editor:
cd ..
nano venvcarplatedetection/lib/python3.10/site-packages/torch/nn/modules/upsampling.py
- Replace the following function:
def forward(self, input: Tensor) -> Tensor:
return F.interpolate(input, self.size, self.scale_factor, self.mode, self.align_corners,
recompute_scale_factor=self.recompute_scale_factor)
with (be careful to indent correctly)
def forward(self, input: Tensor) -> Tensor:
return F.interpolate(input, self.size, self.scale_factor, self.mode, self.align_corners,
# recompute_scale_factor=self.recompute_scale_factor
)
Run the program using your webcam:
cd CarPlateDetection
python3 detect.py --source 0