- 资源介绍
- 更新记录
- 安装教程
若有个人部署运行问题,点击右侧客服按钮咨询站长
项目介绍
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 Django连锁炸鸡店管理系统的设计与实现+第一稿+中期检查表+ppt+开题+任务书+申请表+文献综述+查重报告+安装视频+讲解视频(已降重)
2023-05-30 -
python离线CNN车牌识别源码+演讲稿
2021-05-11 -
基于深度学习的文本信息提取方法研究(pytorch python textcnn框架)+第七稿+创新点+问题及解答+ppt+指导工作记录本+文献翻译+工作日志+开题报告及评审表+任务书
2024-11-19 -
Python红色旅游景点特征提取与交互
2023-06-21 -
Vue前台python后台 开发的在线教育网站及后台管理
2021-08-02 -
python scrapy Django weui基于网络爬虫的新闻采集和订阅系统的设计与实现
2021-07-16 -
资产管理系统python django sqlite
2021-09-09 -
基于深度学习的车牌检测系统的设计与实现(安卓、YOLOV、CRNNLPRNet)第三稿+任务书+开题报告+题目申报
2024-11-18 -
基于大数据的电子产品需求数据分析系统的设计与实现(Python Vue Flask Mysql)+第二稿+开题+任务书+选题申请表+指导记录+中期检查表+周进展+创新点+答辩相关问题解答+安装视频
2024-09-22 -
python基于django企业内部绩效管理系统源码
2021-05-16
-
基于深度学习的数字识别系统的设计与实现(python、yolov、PyQt5)+第一稿+开题+任务书+安装视频
2024-09-24 -
基于Python学生成绩管理系统设计与实现+论文第五版+开题报告+ppt+任务书+修改的问题文档+安装视频+代码讲解视频(已降重,包安装)
2022-07-07 -
Python个性化电影推荐系统的设计与实现+第九稿+安装视频+讲解视频(echarts图表)
2024-07-15 -
python+小程序大学生兼职 微信小程序
2021-07-22 -
python影视数据爬虫sqlite源码+论文(完整版和简洁版)
2021-09-14 -
python识别4位数字验证码(单个数字提取识别)
2021-05-12 -
Python Django纪念馆线上平台的设计与实现+第二稿+中期检查表+ppt+开题+任务书+申请表+文献综述+查重报告+安装视频+讲解视频(已降重)
2023-05-30 -
python sqlite知网爬虫源码+论文(原订做1.2k)
2021-05-23 -
Python vue在线考试系统-大学毕业设计-基于Django+Django -Rest-Framework+vue(保远程安装配置)
2021-07-16 -
python在线教育项目
2021-08-02
猜你在找
99源码网,程序代做,代写程序代码,代写编程,代写Java编程,代写php编程,计算机专业代做,计算机毕业设计,网站建设,网站开发,程序 » python识别4位数字验证码(模型训练)
常见问题FAQ
- 免费下载或者VIP会员专享资源能否直接商用?
- 本站所有资源版权均属于原作者所有,这里所提供资源均只能用于参考学习用,请勿直接商用。若由于商用引起版权纠纷,一切责任均由使用者承担。更多说明请参考 VIP介绍。
- 提示下载完但解压或打开不了?
- 找不到素材资源介绍文章里的示例图片?
- 99源码网
- 2021-05-12Hi,初次和大家见面了,请多关照!