Skip to content

huangxiao1234/SHU-CAPTCHA-solver-based-on-CNN

 
 

Repository files navigation

SHU-CAPTCHA-solver-based-on-CNN

SHU CAPTCHA solver based on CNN, need python3.5, keras ,numpy and PIL as dependencies.
You can simplely use command "pip3 -r requirements.txt" to install them.
A pretty old version of tensorflow is used and is not included in requirements.txt, please install it with "pip install http://mirrors.shuosc.org/tensorflow/linux/cpu/tensorflow-0.10.0-cp27-none-linux_x86_64.whl".

structure

The network is composed of two convolution layers and one max pooling layer. Drop-out and softmax are also used.
If you intend to change the structure of the network, check train.py.
The structure and parameters of the trained network are stored in shu_captcha_CNN_structure.json and shu_captcha_CNN_weights.h5.

dataset

The pictures in the datasets are from the curricula-variable system of ShangHai University. The raw picture is a 60x22 captcha image of 4 English letters or numbers.
We devide the images averagely into 4 parts and mannually labeled it, totaled 6284 samples.
As the images are RBG format, they're stored in X_train.npy as a numpy array with the shape of (6284, 22, 15, 3).
Each result is a 62 demension one-hot vecotr, as 10 digits, 26 capital letters and 26 lower-case letters, they're stored in Y_train.py as a (6284, 62).
If you intend to append any data to the dataset, check these files.

usage

Run train.py and it will load the training set and train the network. Afterwords it will stored the network using keras's model.save_weights and model.to_json functions to save the data.
Also, you can simplely import CaptchaSolver into your script and use the solve method by passing it a loaded Image object(from PIL). See test.py.
Be aware each time that CaptchaSolver.py starts, it loads the network from the json and h5 files above, so if you want to make it a service of some type(eg web api), it's better to keep the proccess as a resident one.

About

SHU CAPTCHA solver based on CNN, need kears as dependency.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages

  • Python 100.0%