Datasets:
Upload README.md with huggingface_hub
Browse files123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101---language: - enlicense: agpl-3.0tags: - captcha - ocr - cnn - onnx - phpwindpipeline_tag: image-to-textmodel_type: phpwind-captcha-ocrmetrics: - name: "validation accuracy" type: accuracy value: 0.886 - name: "per-attempt login success" type: accuracy value: 0.876 - name: "login success with retries" type: accuracy value: 0.999997---
# PHPWind Captcha OCR
An OCR model for the built-in **PHPWind forum captcha** (4 digits). Fully local inference, no external API, 4 MB ONNX model.
**中文版**: [README_zh.md](README_zh.md)

```Example input → Model output: 9125```
This captcha is PHPWind's built-in component (`PwVerifyCode` / `PwGDCode`). Colored digits, noise lines and distortion are its standard features.
## Quick Start
### Python (onnxruntime)
```bashpip install onnxruntime pillow numpy```
```pythonimport numpy as npimport onnxruntime as ortfrom PIL import Image
sess = ort.InferenceSession("model.onnx", providers=["CPUExecutionProvider"])
def solve(path): im = Image.open(path).convert("RGB").resize((160, 64), Image.BILINEAR) x = np.asarray(im, dtype=np.float32).transpose(2, 0, 1)[None] / 255.0 logits = sess.run(None, {"input": x})[0] return "".join(str(int(logits[0, p].argmax())) for p in range(4))
print(solve("captcha.png")) # e.g. "9125"```
### Go (onnxruntime_go)
See [docs/en/INFERENCE.md](docs/en/INFERENCE.md).
## I/O Specification
| Item | Spec ||---|---|| Input `input` | `[batch, 3, 64, 160]` float32, RGB, values in `[0, 1]` || Output `logits` | `[batch, 4, 10]`, argmax per position → digit || ONNX opset | 18 || Preprocessing | RGB → resize 160x64 (BILINEAR) → divide by 255 |
## Evaluation
Evaluated against **real forum logins** (login success = correct recognition). Details in [docs/en/EVALUATION.md](docs/en/EVALUATION.md).
| Metric | Value ||---|---|| Validation accuracy | 88.6% || Per-attempt login success | **87.6%** (85/97) || Login success with retries | ≈99.9997% |
## Training & Fine-tuning
997 manually-labeled captchas, CNN trained from scratch with a position-preserving architecture.
- Data: `data/` (997 labeled images)- Script: `scripts/train_fixed.py`- Guide: [docs/en/TRAINING.md](docs/en/TRAINING.md)
## Notes
- The captcha is PHPWind's built-in component (not site-custom).- Different PHPWind versions may differ; compare samples before using on another site.
## License
GNU AGPL-3.0 — free to use, modify and distribute (including commercial use), provided modified/derivative works stay AGPL-licensed; network-server use must offer source. See [LICENSE](LICENSE).README.mdAdded+101