CaptchaCracker
CaptchaCracker is an open source Python library that provides functions to create and apply deep learning models for Captcha Image recognition. You can create a deep learning model that recognizes numbers in the Captcha Image as shown below and outputs a string of numbers, or you can try the model yourself.
Input
Output
023062
Web Demo
Integrated into Huggingface Spaces 🤗 using Gradio. Try out the Web Demo:
Installation
pip install CaptchaCracker
Dependency
pip install numpy==1.19.5 tensorflow==2.5.0
Examples
Train and save the model
Before executing model training, training data image files in which the actual value of the Captcha image is indicated in the file name should be prepared as shown below.
import glob
import CaptchaCracker as cc
train_img_path_list = glob.glob("../data/train_numbers_only/*.png")
img_width = 200
img_height = 50
CM = cc.CreateModel(train_img_path_list, img_width, img_height)
model = CM.train_model(epochs=100)
model.save_weights("../model/weights.h5")
Load a saved model to make predictions
import CaptchaCracker as cc
img_width = 200
img_height = 50
max_length = 6
characters = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'}
weights_path = "../model/weights.h5"
AM = cc.ApplyModel(weights_path, img_width, img_height, max_length, characters)
target_img_path = "../data/target.png"
pred = AM.predict(target_img_path)
print(pred)
References
Contributors