Skip to content

Valdert-13/captcha

Repository files navigation

What is the capthca

Captcha is image generated by chars randomly and proper voice to avoid the attack from the robot. Example captcha: 1STSD_4 37825_53_

Generate the captcha to train

We can easily generate the captcha by the python package captcha.See the captcha_generator.py in details.

Downloading and processing captcha from Rosreestr

We can download the captcha from the Rosreestr website and process it using the rename_captcha function in rosreestr.py

201136

Build the cnn model

I build the network with TensorFlow. We increase the neural network with each following symbol

# 3 conv layer
    input_img = tf.keras.layers.Input(shape=IMG_SHAPE)
    output_code = []

    out = tf.keras.layers.Convolution2D(16, (3, 3), padding='same', activation='relu')(input_img)
    out = tf.keras.layers.MaxPooling2D(padding='same')(out)
    out = tf.keras.layers.Convolution2D(32, (3, 3), padding='same', activation='relu')(out)
    out = tf.keras.layers.Convolution2D(32, (3, 3), padding='same', activation='relu')(out)
    out = tf.keras.layers.MaxPooling2D(padding='same')(out)
    out = tf.keras.layers.Convolution2D(64, (3, 3), padding='same', activation='relu')(out)
    out = tf.keras.layers.Convolution2D(64, (3, 3), padding='same', activation='relu')(out)
    out = tf.keras.layers.BatchNormalization()(out)
    out = tf.keras.layers.MaxPooling2D(padding='same')(out)
    out = tf.keras.layers.Flatten()(out)


    for _ in range(NUM_CODE_CHARACTERS):
        dense = tf.keras.layers.Dense(64, activation='relu')(out)
        dropout = tf.keras.layers.Dropout(0.4)(dense)
        prediction = tf.keras.layers.Dense(ALL_CHARS_LEN, activation='sigmoid')(dropout)

        output_code.append(prediction)

The training result

For python captcha, i use 100 000 training samples and 5 000 test samples. After 150 epochs of training, the model obtains the correct rate of 75.62% on the test data.
1RF0L 0F6KK

For Rosreestr, i use 3 000 training samples and 200 test samples. After 60 epochs of training, the model obtains the correct rate of 88% on the test data.

37825_54 56845_2_

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages