CaptchaCracker驗(yàn)證碼識(shí)別
CaptchaCracker 是一個(gè)開(kāi)源的 Python 庫(kù),它提供了創(chuàng)建和應(yīng)用深度學(xué)習(xí)模型來(lái)識(shí)別 Captcha 圖像的功能。你可以創(chuàng)建一個(gè)深度學(xué)習(xí)模型,如下圖所示識(shí)別 Captcha 圖像中的數(shù)字,并輸出一串?dāng)?shù)字,或者你可以自己嘗試這個(gè)模型。
Input
Output
023062
Examples
訓(xùn)練和保存模型
在執(zhí)行模型訓(xùn)練之前,應(yīng)準(zhǔn)備好訓(xùn)練數(shù)據(jù)圖像文件,在文件名中注明驗(yàn)證碼圖像的實(shí)際值,如下圖所示。
import glob import CaptchaCracker as cc # Training image data path train_img_path_list = glob.glob("../data/train_numbers_only/*.png") # Training image data size img_width = 200 img_height = 50 # Creating an instance that creates a model CM = cc.CreateModel(train_img_path_list, img_width, img_height) # Performing model training model = CM.train_model(epochs=100) # Saving the weights learned by the model to a file model.save_weights("../model/weights.h5")
加載一個(gè)已保存的模型來(lái)進(jìn)行預(yù)測(cè)
import CaptchaCracker as cc # Target image data size img_width = 200 img_height = 50 # Target image label length max_length = 6 # Target image label component characters = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'} # Model weight file path weights_path = "../model/weights.h5" # Creating a model application instance AM = cc.ApplyModel(weights_path, img_width, img_height, max_length, characters) # Target image path target_img_path = "../data/target.png" # Predicted value pred = AM.predict(target_img_path) print(pred)
評(píng)論
圖片
表情
