跪拜 Guibai
← All articles
Artificial Intelligence

A Weekend Plate Recognizer Hits 99% on CCPD, Then Real Photos Humble It

By 雨后的天空 ·
Read original on juejin.cn ↗ Google Translate ↗ Alt translation

Benchmark accuracy on a curated dataset like CCPD can mislead; the long tail of real-world captures—province distribution, camera angle, lighting, and document reproduction—is what actually determines production performance, so teams should evaluate by subgroup rather than a single aggregate metric.

Summary

A two-day DIY build produced a license plate recognition pipeline: YOLOv8n for detection, LPRNet with CTC for end-to-end character recognition, and a small FastAPI service wrapped around it. On the CCPD benchmark, the model hit 0.99 mAP50 for detection and strong exact-match recognition, thanks largely to CCPD's clean, front-facing, Anhui-dominant imagery.

When the same pipeline met real vehicle photos from an auto insurance business, accuracy collapsed. Out-of-province plates were guessed wrong, tilted and distant shots missed plates entirely, double-deck yellow plates became garbled, screenshots and PDF scans never appeared in training, and HSV color thresholds flipped blue to black at dusk. The post's lesson is blunt: model structure sets the floor, data sets the ceiling. The long tail of real captures—province mix, camera angle, lighting, and document reproduction—dwarfs model choice.

The developer lists practical fixes: add data by province and color, augment for real capture conditions, evaluate accuracy separately by subgroup rather than a single total, and replace the HSV color heuristic with a learned classifier. The business integration quietly went back to the commercial API that had worked all along.

Takeaways
— CCPD encodes ground-truth annotations inside filenames rather than separate label files; parsing the filename yields both the bounding box and the plate string.
— A single YOLOv8n training run on CCPD reached 0.99 mAP50 in about a hundred epochs.
— Chinese license plates omit the letters I and O to avoid confusion with 1 and 0, so the character set excludes them.
— LPRNet performs CTC-based end-to-end recognition without character segmentation; greedy CTC decoding removes blanks and merges adjacent repeated characters.
— Blanks in CTC output are necessary to preserve repeated characters that would otherwise collapse, such as the five 1s in a plate like 京A11111.
— The production test revealed five failure modes: province misclassification (CCPD is Anhui-heavy), tilted or distant shots, double-deck yellow plates, screenshots/PDF scans, and color errors under low light.
— HSV color thresholds misjudged a blue plate as black and a green plate as yellow in evening light.
— The developer recommends grouped evaluation by province and color because overall accuracy hides severe per-subgroup failures.
— Replacing the HSV color heuristic with a small classification network is suggested as a more robust approach.
Conclusions

The gap between 99% on CCPD and poor real-world performance is a distribution shift—CCPD is mostly front-facing, clear, Anhui-registered vehicles—so the model architecture, YOLOv8n plus LPRNet, is not the weak point; the data coverage is.

A single aggregate accuracy number masks large variances per subclass; the evaluation strategy of splitting by province, color, and capture condition is what separates a demo from something deployable.

The author's experience with HSV color thresholds shows how fragile hand-tuned rules are under lighting changes; a learned classifier is a cheap and reliable upgrade.

The commercial API the developer switched back to likely succeeds not because of a fancier model, but because it has trained on a much broader distribution of real-world captures over time.

Concepts & terms
CCPD
Chinese City Parking Dataset, a large open-source license plate dataset with hundreds of thousands of images. Annotations are embedded in the filenames, and it is heavily biased toward front-facing, Anhui-registered plates.
LPRNet
A lightweight license plate recognition model that reads an entire plate image and outputs a character sequence via CTC, eliminating the need for per-character segmentation. The model is only a few hundred kilobytes.
CTC (Connectionist Temporal Classification)
A decoding method for sequence recognition that maps a per-timestep probability distribution to a label sequence. The greedy variant drops blank tokens and merges adjacent identical characters.
Source: juejin.cn ↗ Google Translate ↗ Backup ↗