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.

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.py→captcha_train.py→captcha_test.py→captcha_predict.py - Uses standard PyTorch +
ImageCaptchastack; 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.