crnn-captcha-solver

Solving captcha using CRNN + CTC loss

The model has been trained on 3500 examples which look like this:

example1color

example2color

example3color

They've been binarized to remove background noise:

example1

example2

example3

Augmentations used: random small-angle rotations and piecewise affine transformation - to simulate distortions in captcha images.

The model shows about 76% accuracy on the validation set.

You can download pretrained model:

https://drive.google.com/open?id=1lNa_exTn7C2fZklHfWCyE-7eftVIkHyT

To use:

python inference.py --model_path ./netCRNN_trained.pth --image_path ./image.jpg

Train on your own data

  • Move your data to train and test dirs. To handle the problem of images with the same texts, your files should be named as <captcha_text>_<index>.png, for example veq4n_2949.png
  • Run tool/create_dataset.py for train and test and specify directory for output lmdb dataset
  • You can specify your character set in alphabets.py
  • You can change learning parameters in params.py

Test

Use inference.py to predict your captcha images. Specify plot_needed parameter to visualize output of the model.

For example, for given image:

example4

we can visualize output probability distributions for channels s, 4, d, 7 and - (empty):

example5

Reference

meijieru/crnn.pytorch