← all repositories
dee1024/pytorch-captcha-recognition

Teaching neural networks to read CAPTCHAs so you don't have to

A PyTorch CNN that learns to crack its own homework—synthetic CAPTCHAs—without hand-holding through character segmentation or feature engineering.

1.2k stars Python Computer VisionML Frameworks
pytorch-captcha-recognition
Velocity · 7d
+0.4
★ / day
Trend
steady
star history

What it does

Trains a convolutional neural network to recognize 4-character CAPTCHAs end-to-end. You generate synthetic training data with ImageCaptcha, run the training script, and get a model.pkl that predicts digits, uppercase, or lowercase letters from raw images. No manual cropping, no resizing rituals, no hand-labeling individual characters.

The interesting bit

The project treats CAPTCHA breaking as multi-label classification with one-hot encoded positions—each of the four slots gets its own softmax head. The synthetic-data loop is the practical core: since ImageCaptcha generates the labels automatically, you can mint 10,000+ training examples in minutes rather than paying for mechanical turk or dark-web CAPTCHA-solving APIs.

Key highlights

  • Claims 99.9999% accuracy on pure 4-digit CAPTCHAs, ~96% on digits plus uppercase letters (per README; no independent verification shown)
  • End-to-end pipeline: captcha_gen.pycaptcha_train.pycaptcha_test.pycaptcha_predict.py
  • Uses standard PyTorch + ImageCaptcha stack; Python 2.7+ supported
  • One-hot encoding per character position, trained for ~15 epochs to reach reported 96%+ accuracy
  • Explicitly framed as educational/demonstration use only

Caveats

  • Only tested against synthetically generated CAPTCHAs from ImageCaptcha; real-world CAPTCHA systems with distortion, noise lines, or variable fonts will likely break it
  • Python 2.7 baseline is dated; modern environments will need compatibility tweaks
  • No code-level documentation of the CNN architecture depth, regularization, or training hyperparameters beyond “multi-layer” and “about 15 epochs”

Verdict

Worth a look if you’re teaching or learning how CNNs handle structured multi-character recognition, or if you need a quick baseline for a very specific, weak CAPTCHA variant. Skip it if you need production-grade CAPTCHA solving or want battle-tested code against modern anti-bot systems.

heatdrop uses Google Analytics to see which pages get read — nothing else. Your call. How we handle data.