File size: 4,662 Bytes
c724c39 4f2bb82 c724c39 4f2bb82 c724c39 4f2bb82 c724c39 4f2bb82 9835036 4f2bb82 c724c39 4f2bb82 c724c39 4f2bb82 c724c39 4f2bb82 3739346 4f2bb82 3739346 4f2bb82 c724c39 4f2bb82 c724c39 4f2bb82 c724c39 4f2bb82 c724c39 4f2bb82 c724c39 4f2bb82 8c75150 4f2bb82 c724c39 4f2bb82 c724c39 cfff3e4 c724c39 4f2bb82 c724c39 4f2bb82 c724c39 4f2bb82 c724c39 4f2bb82 c724c39 4f2bb82 c724c39 4f2bb82 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | ---
language:
- en
license: agpl-3.0
library_name: onnxruntime
tags:
- captcha
- ocr
- cnn
- onnx
- phpwind
pipeline_tag: image-to-text
model_type: phpwind-captcha-ocr
metrics:
- name: validation accuracy
type: accuracy
value: 0.8861
---
# PHPWind Captcha OCR
[](https://huggingface.co/FlanChanXwO/phpwind-captcha-ocr)
[](https://onnx.ai/)
[](https://github.com/alibaba/phpwind)
[](LICENSE)
An ONNX OCR model trained on four-digit numeric captcha images from one legacy
PHPWind deployment. It runs entirely on the local machine: no external API or
GPU is required.
**PHPWind reference implementation**: [alibaba/phpwind](https://github.com/alibaba/phpwind)
contains the `PwVerifyCode` and `PwGDCode` classes targeted by this model.
**中文文档**: [README_zh.md](README_zh.md)

> **Answer for the captcha shown above:** `9125`
## Scope and responsible use
This model is intended for PHPWind site operators, developers, and researchers
working with PHPWind deployments they own or are explicitly authorized to test.
Use it for local integration tests, accessibility research, or evaluation of
your own captcha implementation. Do not use it to automate account logins or
bypass access controls.
Different PHPWind versions and custom themes can generate visually different
captchas. Validate on representative, authorized samples before deployment.
## Version support
This checkpoint was trained only on four-digit captcha images from a target
deployment whose footer displayed `v0.7β`. This is an observed deployment
label, **not** a claim about an official PHPWind release version.
| Deployment or version label | Status | Evidence | Notes |
|---|---|---|---|
| Target deployment — footer label `v0.7β` | Training scope | 997 manually labelled images; 88.61% held-out validation accuracy | The only visual configuration represented in the training and reference evaluation data. |
| Other PHPWind releases, forks, themes, or captcha generators | Unverified | No version-specific evaluation | Validate with authorized representative samples; fine-tune if the visual distribution differs. |
## Quick start
Install the runtime:
```bash
pip install onnxruntime pillow numpy
```
Run local inference on a captcha image you are authorized to process:
```python
import numpy as np
import onnxruntime as ort
from PIL import Image
session = ort.InferenceSession("model.onnx", providers=["CPUExecutionProvider"])
def predict_captcha(path: str) -> str:
image = Image.open(path).convert("RGB").resize((160, 64), Image.BILINEAR)
inputs = np.asarray(image, dtype=np.float32).transpose(2, 0, 1)[None] / 255.0
logits = session.run(None, {"input": inputs})[0]
return "".join(str(int(logits[0, position].argmax())) for position in range(4))
print(predict_captcha("captcha.png"))
```
## Model interface
| Item | Value |
|---|---|
| Input | `input`: `[batch, 3, 64, 160]`, `float32`, RGB values in `[0, 1]` |
| Output | `logits`: `[batch, 4, 10]`; argmax per position gives one digit |
| Preprocessing | RGB → resize to `160 × 64` (bilinear) → divide by `255` |
| Format | ONNX, opset 18 |
| Runtime | CPU supported; no GPU requirement |
## Evaluation
The published checkpoint reached **88.61% validation accuracy** on a held-out
split of 997 manually labelled images from the target `v0.7β` footer-label
deployment. This is a model-card reference metric, not a guarantee for another
PHPWind version, theme, or deployment. See [the evaluation
protocol](docs/en/EVALUATION.md) for the scope and reproducibility requirements.
## Documentation
- [Inference guide](docs/en/INFERENCE.md) — Python and Go integration details
- [Training and fine-tuning](docs/en/TRAINING.md) — data preparation and model training
- [Evaluation](docs/en/EVALUATION.md) — offline validation protocol
- [Documentation index](docs/en/README.md)
## Training data and license
The checkpoint was trained from scratch with a position-preserving CNN on 997
manually labelled images. For adaptation, use only captcha images from PHPWind
deployments you operate or are authorized to evaluate.
This project is licensed under [GNU AGPL-3.0](LICENSE). Modified or networked
derivative works must meet the license's corresponding-source requirements.
|