Abstract. E-captcha solver is a text captcha solver written in Python. A PyTorch CRNN reads five-letter E-captcha images and is trained with CTC loss, so the labels are plain strings with no character positions. The README states about 95% accuracy. The repository holds the model, the training script, a synthetic data generator, an ONNX export and three ways to run inference: a Python class, a FastAPI endpoint and a Node.js module. Trained weights are not included.
| No. | Input image, 200 x 50 | Label |
|---|---|---|
| 01 | ![]() | merbc |
| 02 | ![]() | tkcdv |
| 03 | ![]() | rhecf |
| 04 | ![]() | mjufv |
| 05 | ![]() | drguf |
| 06 | ![]() | aefeu |
| 07 | ![]() | fhfsv |
| 08 | ![]() | jebvh |
| 09 | ![]() | btffj |
| 10 | ![]() | zhcab |
samples/. Each label is the ground truth from the file name. No trained weights ship with the repository, so this page shows no predictions. The network in model_ctc.py has three parts. Five convolutional blocks turn a 200 × 50 grayscale image into a strip that is 1 pixel high, 50 wide and 256 channels deep. Each block is two 3 × 3 convolutions with batch normalisation and ReLU, followed by max pooling.
Only the first two blocks pool horizontally. The width stops at 50 while the height keeps shrinking to 1, and those 50 columns become the time steps of a sequence.
A two-layer bidirectional LSTM with 256 hidden units reads the sequence in both directions. A linear layer then scores 20 classes at every step: the 19 letters of the alphabet plus the CTC blank. The whole model has 4,994,676 trainable parameters, counted from the layer definitions.
model_ctc.py, with the output shape of each stage. Feature maps are drawn to scale. The output shown is the label of sample 01. The model makes 50 predictions for a five-letter answer, and CTC decides how they line up. In training, nn.CTCLoss sums over every 50-step path that reduces to the label. At inference greedy_decode takes the top class at each step, merges runs of the same class and removes blanks.
The blank is what lets a doubled letter survive. In btffj the two runs of f have a blank between them, so they stay two letters. Without it they would merge into one.
------bbb-tt--fff-ff--jj---------------------------b-t-f-f-j-btffj| Property | Value | Source |
|---|---|---|
| Accuracy, full string | about 95% | Readme.md, captcha_ctc_colab.ipynb |
| Alphabet | abcdefghjkmnrstuvyz | model_ctc.py |
| Characters per image | 5 | model_ctc.py |
| Model input | 200 × 50 grayscale, scaled to [-1, 1] | model_ctc.py |
| Model output | 50 time steps × 20 classes | model_ctc.py |
| Trainable parameters | 4,994,676 | counted from model_ctc.py |
| Default training run | 400 epochs, batch 64, Adam at 1e-3, cosine schedule | train_ctc.py |
| Training time | 15 to 20 minutes on a Colab GPU | captcha_ctc_colab.ipynb |
| Validation hold-out | 200 images | train_ctc.py |
The notebook adds that a retry or two puts the effective success rate near 100%. Every prediction comes back with a confidence score, so a caller can retry the weak ones. The repository has no benchmark set beyond the ten images in Fig. 1, and this page does not reproduce the accuracy figure.
Put a trained ctc_model.pt in the project root first. The Python class returns the text and a confidence between 0 and 1. The HTTP server and the Node.js module wrap the same model.
from infer import CaptchaSolver
solver = CaptchaSolver("ctc_model.pt")
text, conf = solver.solve("captcha.jpg")
text, conf = solver.solve_bytes(response.content)infer.py.pip install fastapi uvicorn python-multipart
uvicorn server:app --port 8000
curl -F file=@captcha.jpg http://localhost:8000/solve
# {"text":"hvnyf","conf":0.99}server.py.python export_onnx.py --model ctc_model.pt --out ctc_model.onnx
cd node && npm install
node solve.js ../captcha.jpg ../ctc_model.onnx
# hvnyfnode/solve.js. The model only knows the E-captcha alphabet and the five-character length, so it is not a general captcha solver. Other text captchas need their own training run. A different alphabet or length also means changing the constants in model_ctc.py, gen_synthetic.py and node/solve.js.
Challenge widgets such as reCAPTCHA or hCaptcha are out of scope.