FlanChanXwO commited on
Commit
c724c39
·
verified ·
1 Parent(s): 1a4b845

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +132 -3
README.md CHANGED
@@ -1,3 +1,132 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:58f9f4be2cfa3361254938c9729839079d16175ba89ea5fecc497371dc40ee99
3
- size 4286
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - zh
4
+ - en
5
+ license: agpl-3.0
6
+ tags:
7
+ - captcha
8
+ - ocr
9
+ - cnn
10
+ - onnx
11
+ - phpwind
12
+ pipeline_tag: image-to-text
13
+ model_type: phpwind-captcha-ocr
14
+ metrics:
15
+ - name: "validation accuracy"
16
+ type: accuracy
17
+ value: 0.886
18
+ - name: "real login success (per-attempt)"
19
+ type: accuracy
20
+ value: 0.876
21
+ - name: "login success with retries"
22
+ type: accuracy
23
+ value: 0.999997
24
+ ---
25
+
26
+ # PHPWind Captcha OCR
27
+
28
+ **中文**:识别 PHPWind 论坛内置验证码的 OCR 模型(4 位数字)。完全本地推理,无外部 API 依赖,4 MB。
29
+ **English**: An OCR model for the built-in PHPWind forum captcha (4 digits). Fully local inference, no external API, 4 MB.
30
+
31
+ ---
32
+
33
+ ## 识别对象 / What it recognizes
34
+
35
+ **中文**:下面这类 PHPWind 论坛登录验证码(彩色数字 + 干扰线):
36
+ **English**: The PHPWind forum login captcha (colored digits + noise lines):
37
+
38
+ ![example captcha](assets/example_captcha.png)
39
+
40
+ ```
41
+ 示例输入 (example input) → 模型输出 (model output): 9125
42
+ ```
43
+
44
+ **中文**:验证码是 PHPWind 内置组件(`PwVerifyCode` / `PwGDCode`),彩色数字、干扰线、扭曲均为其标准特征。
45
+ **English**: This is PHPWind's built-in captcha component (`PwVerifyCode`/`PwGDCode`) — colored digits, noise lines and distortion are its standard features.
46
+
47
+ ---
48
+
49
+ ## 快速使用 / Quick Start
50
+
51
+ ### Python (onnxruntime)
52
+
53
+ ```bash
54
+ pip install onnxruntime pillow numpy
55
+ ```
56
+
57
+ ```python
58
+ import numpy as np
59
+ import onnxruntime as ort
60
+ from PIL import Image
61
+
62
+ sess = ort.InferenceSession("model.onnx", providers=["CPUExecutionProvider"])
63
+
64
+ def solve(path):
65
+ im = Image.open(path).convert("RGB").resize((160, 64), Image.BILINEAR)
66
+ x = np.asarray(im, dtype=np.float32).transpose(2, 0, 1)[None] / 255.0
67
+ logits = sess.run(None, {"input": x})[0]
68
+ return "".join(str(int(logits[0, p].argmax())) for p in range(4))
69
+
70
+ print(solve("captcha.png")) # e.g. "9125"
71
+ ```
72
+
73
+ ### Go (onnxruntime_go)
74
+
75
+ See [docs/INFERENCE.md](docs/INFERENCE.md).
76
+
77
+ ---
78
+
79
+ ## 输入 / 输出规格 (I/O spec)
80
+
81
+ | 中文 | English |
82
+ |---|---|
83
+ | 输入 `input`:`[batch, 3, 64, 160]` float32 (RGB, [0,1]) | Input `input`: `[batch, 3, 64, 160]` float32 (RGB, [0,1]) |
84
+ | 输出 `logits`:`[batch, 4, 10]`,每位置 argmax → 数字 | Output `logits`: `[batch, 4, 10]`, argmax per position → digit |
85
+ | ONNX opset 18 | ONNX opset 18 |
86
+ | 预处理:RGB → 160x64 (BILINEAR) → /255 | Preprocess: RGB → 160x64 (BILINEAR) → /255 |
87
+
88
+ ---
89
+
90
+ ## 评估结果 / Evaluation
91
+
92
+ **中文**:用真实论坛登录作为 ground truth(登录成功 = 识别正确)。
93
+ **English**: Evaluated against real forum logins (login success = correct recognition).
94
+
95
+ | 指标 / Metric | 数值 / Value |
96
+ |---|---|
97
+ | 验证集精度 / Validation accuracy | 88.6% |
98
+ | 真实登录单次命中 / Per-attempt login success | **87.6%** (85/97) |
99
+ | 带重试登录成功率 / With retries | ≈99.9997% |
100
+
101
+ **中文**:详情见 [docs/EVALUATION.md](docs/EVALUATION.md)。
102
+ **English**: Details in [docs/EVALUATION.md](docs/EVALUATION.md).
103
+
104
+ ---
105
+
106
+ ## 训练 / 微调 (Training & Fine-tuning)
107
+
108
+ **中文**:997 张人工标注验证码,CNN 从零训练(位置保留架构)。
109
+ **English**: 997 manually-labeled captchas, CNN trained from scratch (position-preserving architecture).
110
+
111
+ - 数据 / Data: `data/` (997 labeled images)
112
+ - 脚本 / Scripts: `scripts/train_fixed.py`
113
+ - 指南 / Guide: [docs/TRAINING.md](docs/TRAINING.md)
114
+
115
+ ---
116
+
117
+ ## 说明 / Notes
118
+
119
+ **中文**:
120
+ - 验证码为 PHPWind 内置组件(非站点定制)。
121
+ - 不同 PHPWind 版本参数可能有差异,换站使用前建议对比样例确认风格。
122
+
123
+ **English**:
124
+ - The captcha is PHPWind's built-in component (not site-custom).
125
+ - Different PHPWind versions may differ; compare samples before use on another site.
126
+
127
+ ---
128
+
129
+ ## 许可证 / License
130
+
131
+ **中文**:本模型采用 **GNU AGPL-3.0** 许可 —— 可自由使用、修改、分发(含商用),但修改版/衍生作品必须同样以 AGPL 开源;网络服务使用也需提供源码。详见 [LICENSE](LICENSE)。
132
+ **English**: Licensed under the **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).