Loading…
Loading…
Model artifacts for a compact five-character CAPTCHA recognizer.
Training and inference code is maintained separately on GitHub:
https://github.com/nakasyou/capsolve-spInstall the CPU inference dependencies:
pip install huggingface-hub onnxruntime pillow numpy
Run the calibrated INT8 model on a 175x60 CAPTCHA image:
from huggingface_hub import hf_hub_download
from PIL import Image
import numpy as np
import onnxruntime as ort
REPO_ID = "nakasyou/capsolve-sp"
CHARSET = "0123456789abcdefghijklmnopqrstuvwxyz"
model_path = hf_hub_download(REPO_ID, "model.onnx")
session = ort.InferenceSession(
model_path,
providers=["CPUExecutionProvider"],
)
with Image.open("captcha.png") as source:
image = source.convert("L")
if image.size != (175, 60):
raise ValueError("captcha image must be 175x60 pixels")
pixels = np.asarray(image, dtype=np.float32)
# The model expects white background as 0 and dark ink as 1.
input_tensor = ((255.0 - pixels) / 255.0)[None, None, :, :]
logits = session.run(["logits"], {"image": input_tensor})[0]
text = "".join(CHARSET[index] for index in logits[0].argmax(axis=-1))
print(text)
To use the FP32 model instead, change model.onnx to model-fp32.onnx.
model.onnx: calibrated INT8 ONNX, recommended for fast CPU inferencemodel-fp32.onnx: FP32 ONNXmodel.safetensors: PyTorch architecture weightsconfig.json: architecture and preprocessing configurationmetadata.json: training and evaluation metadata0 and ink is 10123456789abcdefghijklmnopqrstuvwxyzThe model was fine-tuned on 13,231 frames from 11,754 CAPTCHA groups. Validation used 3,355 frames from 2,938 disjoint groups.
| Validation metric | Result |
|---|---|
| Character accuracy | 96.94% |
| Exact five-character accuracy | 87.00% |
Across all 14,332 valid labeled 0.png images:
| Runtime model | Exact accuracy |
|---|---|
| FP32 ONNX | 85.047% (12,189 / 14,332) |
| INT8 ONNX | 85.033% (12,187 / 14,332) |
FP32 and INT8 predictions agreed on 99.874% of images. On an AMD Ryzen AI 7 PRO 350, INT8 reached a median of approximately 1,573 images/second at batch size 8 and eight threads.
The model artifacts are licensed under the MIT License. See LICENSE.