- 资源介绍
- 更新记录
- 安装教程
若有个人部署运行问题,点击右侧客服按钮咨询站长
项目介绍
python识别4位数字验证码(模型训练)
适用场景:
运行截图
# captcha_identification
[《使用 Keras 搭建模型识别四位数字字母验证码》](https://xiaosheng.run/2019/09/12/article167/)的代码示例
## 说明
参考图片分类任务中经典的 VGG 模型,采用 3 个块 (Block) 共计 6 个卷积层来识别 4 位数字字母验证码。
“`python
pic_in = Input(shape=(32, 90, 1))
# Block 1
cnn_features = Conv2D(32, (3,3), activation=’relu’, padding=’same’)(pic_in)
cnn_features = Conv2D(32, (3,3), activation=’relu’)(cnn_features)
cnn_features = MaxPooling2D((2, 2))(cnn_features)
cnn_features = Dropout(0.25)(cnn_features)
# Block 2
cnn_features = Conv2D(64, (3,3), activation=’relu’,padding=’same’)(cnn_features)
cnn_features = Conv2D(64, (3,3), activation=’relu’)(cnn_features)
cnn_features = MaxPooling2D((2, 2))(cnn_features)
cnn_features = Dropout(0.25)(cnn_features)
# Block 3
cnn_features = Conv2D(128, (3,3), activation=’relu’,padding=’same’)(cnn_features)
cnn_features = Conv2D(128, (3,3), activation=’relu’)(cnn_features)
cnn_features = MaxPooling2D((2, 2))(cnn_features)
cnn_features = Dropout(0.25)(cnn_features)
cnn_features = Flatten()(cnn_features)
# classifier 1
output_l1 = Dense(128, activation=’relu’)(cnn_features)
output_l1 = Dropout(0.5)(output_l1)
output_l1 = Dense(36, activation=’softmax’)(output_l1)
# classifier 2
output_l2 = Dense(128, activation=’relu’)(cnn_features)
output_l2 = Dropout(0.5)(output_l2)
output_l2 = Dense(36, activation=’softmax’)(output_l2)
# classifier 3
output_l3 = Dense(128, activation=’relu’)(cnn_features)
output_l3 = Dropout(0.5)(output_l3)
output_l3 = Dense(36, activation=’softmax’)(output_l3)
# classifier 4
output_l4 = Dense(128, activation=’relu’)(cnn_features)
output_l4 = Dropout(0.5)(output_l4)
output_l4 = Dense(36, activation=’softmax’)(output_l4)
model = Model(inputs=pic_in, outputs=[output_l1, output_l2, output_l3, output_l4])
“`
## 使用
下载最新训练好的 [model-45.hdf5](https://github.com/jsksxs360/captcha_identification/blob/master/model/model-45.hdf5) 模型(该模型在包含 4 万图片的测试集上取得 99.88% 的准确率)。
通过以下代码调用模型识别验证码:
“`python
from skimage import io
from skimage import color
import numpy as np
import os
from keras.models import Model
from keras.models import load_model
# 构建映射字典
labels = [‘a’,’b’,’c’,’d’,’e’,’f’,’g’,
‘h’,’i’,’j’,’k’,’l’,’m’,’n’,
‘u’,’p’,’q’,’r’,’s’,’t’,’o’,
‘v’,’w’,’x’,’y’,’z’,’0′,’1′,
‘2’,’3′,’4′,’5′,’6′,’7′,’8′,’9′]
label2id = {}
id2label = {}
for label in labels:
label2id[label] = len(label2id)
for label, id in label2id.items():
id2label[id] = label
def decode(y):
y = np.argmax(np.array(y), axis=-1)
return ”.join([id2label[x] for x in y])
im = io.imread(‘1a8m.png’)
im3 = color.rgb2gray(im)
pic = np.asarray([np.expand_dims(im3, axis=2)])
model = load_model(‘../model/model-45.hdf5’)
py = np.squeeze(model.predict(pic))
print(decode(py))
“`
> **环境**
>
> 测试环境为 Python3,Tensorflow 建议 1.14+,Keras 2.3.1。
>
> 其他 Python 包依赖:scikit-image, numpy, flask, gevent, uuid
关注【程序代做 源码分享】公众号获取更多免费源码!!!

猜你喜欢
-
基于深度学习的数字识别系统的设计与实现(python、yolov、PyQt5)+第一稿+开题+任务书+安装视频
2024-09-24 -
python mysql图书爬虫可视化源码+论文(原价1.3k)
2021-05-22 -
python web Django京东华为手机商品信息采集爬虫与数据分析
2022-10-12 -
python+小程序大学生兼职 微信小程序
2021-07-22 -
Python个性化电影推荐系统的设计与实现+第九稿+安装视频+讲解视频(echarts图表)
2024-07-15 -
基于Python的旅游管理系统微信小程序设计与实现毕业论文+项目源码及数据库
2022-06-05 -
python基于django企业内部绩效管理系统源码
2021-05-16 -
基于Android和深度学习的手势识别的设计与实现(Yolov)+第四稿+申报表+开题报告+任务书+安装视频
2024-11-19 -
python flask mysql学校管理系统源码
2021-07-02 -
基于机器学习的海洋生物识别系统的设计与实现(Yolov)+一稿+任务书+选题审题表+开题报告+查重报告
2024-11-17
-
python基于Django框架在线教育平台的开发与设计源码+毕业论文+答辩ppt+开题报告+任务书+包安装配置
2022-01-18 -
python爬取中庸词诗词保存mysql数据库源码
2021-05-11 -
Python Django MySQL的教务系统的设计与实现+第六稿+中期检查表+ppt+周进展+开题+任务书+申请表+查重报告+安装视频+讲解视频(已降重)
2023-07-10 -
Python vue在线考试系统-大学毕业设计-基于Django+Django -Rest-Framework+vue(保远程安装配置)
2021-07-16 -
python sqlite知网爬虫源码+论文(原订做1.2k)
2021-05-23 -
大数据专题-spark mysql python爬虫携程景点爬取(含虚拟机镜像)
2022-10-10 -
密码保护:(智联爬虫、推荐算法)基于文本挖掘的IT类人才招聘画像数据可视化分析系统的设计与实现(python mysql flask vue)+第一稿+开题+任务书+选题申请表+指导记录+中期检查表+周进展+创新点+答辩相关问题解答+查重报告+安装视频(12w数据)
2024-09-20 -
资产管理系统python django sqlite
2021-09-09 -
Python Django纪念馆线上平台的设计与实现+第二稿+中期检查表+ppt+开题+任务书+申请表+文献综述+查重报告+安装视频+讲解视频(已降重)
2023-05-30 -
人员跌倒检测系统的设计与实现(Yolov Python38 深度学习)第五稿+ppt+目前进度+开题报告+问题回答+预答辩ppt+安装视频+相关问题及解答+运行步骤
2024-10-14
猜你在找
99源码网 » python识别4位数字验证码(模型训练)
常见问题FAQ
- 免费下载或者VIP会员专享资源能否直接商用?
- 本站所有资源版权均属于原作者所有,这里所提供资源均只能用于参考学习用,请勿直接商用。若由于商用引起版权纠纷,一切责任均由使用者承担。更多说明请参考 VIP介绍。
- 提示下载完但解压或打开不了?
- 找不到素材资源介绍文章里的示例图片?
- 99源码网
- 2021-05-12Hi,初次和大家见面了,请多关照!