Projects

VioPlates

Computer vision

VioPlates reads Nepali number plates from traffic video and flags five violations: wrong way, illegal parking, red light, no helmet and triple riding, each confirmed by a person in a review app.

The plate detector

I trained a YOLO26n plate detector, 2.5M parameters, on a dataset of Nepali plates, split by scene into 6,384 training, 819 validation and 875 test images, so no scene appears in both training and testing.

Training
GPUColab Tesla T4
Image size640 px
Batch size32
Epochs30
OptimiserAdamW
Time48 minutes

It was still improving at epoch 30.

Results On the held-out test set, 875 images with 945 plates, it was level with the community model I compared it against. mAP50 is a standard detection score where 1.0 is perfect; mAP50-95 is a stricter version that also rewards tight boxes. The community model's numbers are probably optimistic, because it was likely trained on these photos.

ModelPrecisionRecallmAP50mAP50-95
Mine (YOLO26n, 2.5M)0.9700.9750.9930.925
Community (YOLOv8, 3.0M)0.9880.9680.9930.932

On real cars

I then tested both on 1,168 real parked cars from a different dataset, with wider shots. Mine found 83% of plates and the community model found 93%, so the community model stays the default. A near-perfect benchmark score didn't carry over to wider shots.

The character classifier

Embossed plates use Latin letters and digits, and no public model read them. My reader cuts the plate into characters and labels each one with a small CNN I trained from scratch on 32×32 images.

Version 1 Trained for 40 epochs on three Kaggle character sets, de-duplicated and split 8,372 / 1,075 / 1,271. It scored 98.4% on its test set, but only 70.8% on characters cut from real plates.

Version 2 I labelled 399 real embossed character crops from photos, split by car so no car is in both training and testing, and added them to the training data. 40 epochs, about 65 minutes on CPU. It kept its 98.4% on the test set and reached 92.5% on 161 held-out real crops. This is the version the app ships, and it's on Hugging Face with a one-file reader you can run yourself.

VersionBenchmark testReal plates
1: public crops only98.4%70.8%
2: plus 399 real crops98.4%92.5%

Cutting plates into characters

How characters are cut out mattered as much as the classifier. Dropping the red flag, judging each character's height against its neighbours and ignoring small marks took correctly split plates from 43 of 110 to 80 of 110. I wrote this part up in more detail in reading Nepal's embossed number plates.

On 30 embossed plates held out by car, exact reads went from 20% to 50% after adding the real crops, and the character error rate fell from 43% to 20%. On the 1,168 parked cars, the plate was found 93% of the time. Embossed plates were being read as the old style 36% of the time; letting plates with fewer than 4 Devanagari characters also try the embossed reader brought that to 0%. Those fixes were made after looking at the same photos.

30 held-out embossed platesBefore real cropsAfter
Read exactly20%50%
Character error rate43%20%

The helmet model

I fine-tuned the open helmet-yolo11m model on DeBoniz's helmet detection dataset, 18,159 images split 16,384 / 1,130 / 643.

Training
Starting modelhelmet-yolo11m
GPUColab Tesla T4
Epochs12

Results On that dataset's test split, mAP50 went from 0.361 to 0.97. On 18 rider crops I labelled myself, accuracy went from 89% to 100%. On Kathmandu street clips it removed a false flag, a bronze helmet seen side-on that had been read as no helmet, lost one real flag, and added 8 new flags, at least 4 of which looked real. These numbers are being reproduced before the fine-tune goes into the app.

Helmet modelTest mAP50My 18 rider crops
Before fine-tuning0.36189%
After 12 epochs0.97100%

Testing the rules

The models feed five rules. Wrong-way traffic is rare, so I made it by playing normal traffic videos backwards. Forwards, no road raised a single flag. Matching flags to vehicles was loosened from 0.5 to 0.3 overlap after 13 of 17 apparent false flags turned out to be correct ones just under 0.5; both numbers were reported.

For red lights, the light reader matched the signal on 515 of 516 frames. With the red signal pasted over every frame of a real clip, so cars leaving on green became runners, 3 of 3 were flagged within one frame, with no false flags. That's one camera and three crossings: it shows the rule and the light reader work together on real video, and it isn't an accuracy figure.

Wrong way, reversed videoCaughtFalse alarms
UA-DETRAC, held-out road90 of 900
UA-DETRAC, tuning road32 of 371
Kathmandu clip, full pipeline24 of 280

Data and credits

Models YOLO26 (AGPL-3.0). The community plate and character detectors from praaajg's Nepali Number Plate Recognition (AGPL-3.0). helmet-detection-yolo11 (MIT).

Training data Vehicle Number Plate Dataset (Nepal) and Nepalese License Plate Character Dataset (Apache-2.0). Individual Character images of Nepali LP and Embossed Number Plate dataset (MIT). Nepali Private License Plates and DeBoniz's helmet detection dataset (CC-BY-4.0).

Testing only UA-DETRAC (CC BY-NC-SA 3.0).

Video clips From Pexels, by Riaz Uddin, Karma Rayshar, Anil Prasad Shrestha (one, two) and Martyn Day.

Made by me Plate text labels for 115 embossed plates, 560 real embossed character crops, helmet and rider labels for 18 rider crops, and fixed train/test splits: by scene for plates, by car for characters.

Built with

  • PyTorch
  • YOLO
book a chat