Writings

98% on the benchmark, 25% on real plates: reading Nepal's embossed number plates

· 5 min read

I'm building a system that reads Nepali number plates from traffic footage and flags violations, like riding without a helmet. Reading the plates was where the published numbers and reality disagreed most.

two kinds of plate

Nepal has two plate styles on the road at once. The older ones are painted in Devanagari: a zone, a lot number, a vehicle class and a number, like बा २ प ४५६७. The newer embossed plates use Latin letters and digits, like B AD 1484, with the Nepal flag on the left and the province name above.

A pale green hatchback with an older red plate on its bumper, the registration painted in white Devanagari over two lines, starting बा.४च.
The older style: painted, in Devanagari.
A grey SUV with a white embossed plate reading B AD 6028 in black Latin letters, the Nepal flag on the left and BAGMATI in small letters above.
The newer embossed style: Latin letters and digits, with the flag and province.

Photos from nepali-private-license-plates by mukulboro, CC-BY-4.0.

There are good public models for the old plates. I started with a pair of open YOLO models, one to find the plate and one to find and label its characters, and on Devanagari plates they work. On embossed plates the character model returned nothing, or a handful of eights. It had never seen a Latin letter.

a classifier that looked finished

The first fix looked easy. There are public datasets of single Nepali plate characters on Kaggle (one, two), including one of embossed characters. I trained a small CNN (1.4 MB) on about 8,000 of them. On their held-out test set it scored 98.4%, and 99.8% on embossed characters.

To use it, the reader thresholds the plate, cuts out the dark blobs that look like characters, and labels each one. On the single real embossed photo I had, it read the plate exactly. That looked like the job done.

then I tried real plates

A dataset on Hugging Face has 1,172 photos of parked cars in Kathmandu, each plate boxed and labelled embossed, provincial or regional. It has no plate text, but the plate type alone let me test something.

Telling the styles apart. 36% of embossed plates were being called old Devanagari plates. The Devanagari model would fire once on an embossed plate, read "PRA 4 4", and that single stray syllable was enough to skip the embossed reader. Letting any plate with fewer than four Devanagari characters try the embossed reader as well fixed it: no embossed plate is called old now, and 82% get the right style.

Actually reading them. For this I needed plate text, so I transcribed and checked all 115 embossed photos by hand. 110 of them are usable embossed Nepali plates: three aren't (one hand-painted plate, and an Indian plate photographed twice), and two couldn't be read with confidence. Against those labels the reader got 25% of plates exactly right.

The classifier that scored 98% on its benchmark got only 71% of characters cut from real plates right. The clean crops it learned from are tightly framed and evenly lit. Real plates are tilted, reflective and photographed from wherever the camera happened to be.

Characters labelled correctly
  • Public test set98.4%
  • Real plates70.8%

what was actually wrong

Looking at the failures showed that labelling characters wasn't even the main problem. Cutting the plate into characters was:

  • The flag counted as a character, adding one at the start of the plate.
  • Tilted plates made the characters look too short relative to the crop, so they were thrown out and nothing was read at all.
  • Stickers and screws became extra characters once I loosened the size limit to catch the tilted ones.

Three small rules fixed most of it. Drop blobs that are mostly red. Measure character height against the plate's other characters, not the crop. Drop anything clearly shorter than the main characters. Before, only 43 of the 110 plates split into the right number of pieces; afterwards 80 did.

Plates split into the right number of pieces, out of 110
  • Before the rules43
  • After80

Those 80 plates also gave me 560 real character crops, labelled for free, since a plate that splits into exactly as many pieces as its text has characters labels itself. I split the plates by car first: several cars had been photographed twice, and a car in both training and testing would flatter the result. The 399 crops from training-side cars went into training, repeated a few times since there are so few; the 161 from held-out cars were kept for testing.

results

On 30 plates from cars the model never saw, with the cutting fixes in place for both:

Clean crops onlyPlus real crops
Characters from real plates (161)70.8%92.5%
Plates read exactly20%50%
Character error rate43%20%

Accuracy on the clean public test sets didn't drop.

what I'd tell someone starting out

  • A benchmark score tells you about the benchmark. 98% on clean crops became 71% on real ones, so test on data that looks like what you'll actually see, as early as you can, even if you only have a little.
  • Look at the failures before you touch the model. The biggest gains here came from three rules about blob size and colour, not from training.
  • A few hundred real examples go a long way. 399 characters from real plates did more than 8,000 clean ones.
  • Split by whatever repeats. Here it was the car; elsewhere it's the video, the patient or the scene.

limits

Thirty test plates is a small sample: 50% could plausibly be anywhere from about 35% to 65%. Every plate is a parked car in Kathmandu photographed up close; traffic cameras see plates smaller, blurrier and at harsher angles. And 30 of the 110 plates still split into the wrong number of pieces, which is where the next improvement is.

try it

book a chat