KaptchaOCR ft-medium: text CAPTCHA reader
Give it a text CAPTCHA image; it returns the characters in it: letters, digits and simple sums like 5+?=8.
It is a 73 MB ONNX model that reads one image in about 69 ms on a laptop CPU.
It is the most accurate on known CAPTCHA styles, at 2.5× the latency of ft-small. The model is one part of KaptchaOCR, a Rust library and HTTP server that prepares the image,
runs the model and turns its output into text.
Which model should I use?
All three readers were fine-tuned on the same data and differ only in size.
| Model | Preset | Size | Whole CAPTCHA right | Characters right | Time per image |
|---|---|---|---|---|---|
ft-tiny | fast | 4.3 MB | 67.0% | 88.8% | 9.8 ms |
ft-small | balanced | 20 MB | 80.4% | 93.0% | 28 ms |
ft-medium (this model) | accurate | 73 MB | 90.7% | 96.0% | 69 ms |
Scores are on 4,399 held-out CAPTCHA images; time is the mean on an Intel i5-1145G7 laptop CPU, one process. "Whole CAPTCHA right" means every character matches, including upper/lower case.
How well it works
On known CAPTCHA styles. The test images were never used in training, but they come from the same six public sources as the training images (named by codename). Exact match per source:
| Source | Exact |
|---|---|
atlas | 82% |
birch | 98% |
cobalt | 99% |
dune | 74% |
ember | 97% |
fjord | 100% |
| All 4,399 images | 90.7% |
On new CAPTCHA styles. On CAPTCHA generators it never saw, accuracy drops. This is the honest range to plan for:
| Unseen generator | Exact | Exact, ignoring case |
|---|---|---|
Python captcha library | 53.0% | 77.0% |
| PIL: rotated glyphs, lines, speckle | 54.3% | 76.7% |
About half of these errors are upper/lower case only (c/C, w/W). If your CAPTCHAs are not case-sensitive,
normalize case and accuracy rises a lot.
Use it
The easiest way is the KaptchaOCR server, which already includes this model:
# preset `accurate` selects this model
kaptchaocr --ocr --manifest model/models.json --profile accurate
Then send an image over HTTP, or use the Python client:
from kaptchaocr import Client
client = Client("http://127.0.0.1:8000")
answer = client.solve(open("captcha.png", "rb").read())
print(answer.text)
To use the files from this repo directly (non-inline build), keep the charset next to the model with the same base name:
kaptchaocr --ocr --ocr-path medium_rec.onnx # reads medium_rec.json from the same folder
Model list entry: {"name": "ft-medium", "task": "rec", "path": "medium_rec.onnx", "charset": "medium_rec.json"}
Technical details
| Files | medium_rec.onnx (model), medium_rec.json (charset) |
| Base model | PP-OCRv6 medium recognizer (PaddleOCR) |
| How it reads | CTC: the model scores every character at each horizontal position; KaptchaOCR merges repeats and removes blanks to get the text |
| Input | RGB image resized to 48 px high; any width |
| Output vocabulary | 18,710 characters, listed in medium_rec.json and kept from the base model. The training labels use 73 of them (case-sensitive letters, digits and a few symbols) |
| Training data | zaltahir/kaptchaocr-rec: 169,311 images, some shown more than once (194,355 training rows) |
| Validation | 5,000 images |
Limitations
- New styles are harder (see above). Retraining on the new style is the fix; none is included here.
- Math: the training labels contain no
- * / × ÷, so subtraction, multiplication and division are often misread. KaptchaOCR's math solver refuses to answer when it finds no operator, but the raw text is still returned. - Only reads text. It does not solve picture CAPTCHAs ("click all the cars").
License
Apache-2.0. Fine-tuned from PP-OCRv6 (PaddleOCR, Apache-2.0).
Links
- KaptchaOCR on GitHub: the library, server, CLI and Python client
- All KaptchaOCR models and datasets
- Full benchmark: method, tables, charts