最新公告
  • 欢迎您光临99源码网,本站秉承服务宗旨 履行“站长”责任,销售只是起点 服务永无止境!立即加入我们
  • python识别4位数字验证码(模型训练)

    python识别4位数字验证码(模型训练) 最后编辑:2021-05-12
    增值服务: 自动发货 使用说明 安装指导 环境配置二次开发BUG修复
    购买后自动跳转百度云,项目自提,轻松方便。
    若有个人部署运行问题,点击右侧客服按钮咨询站长

    项目介绍

    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识别4位数字验证码(模型训练)

    猜你喜欢

    猜你在找

    99源码网专注代写Java程序,php程序,网站建设,毕业设计,课程设计,代写C/C++程序,代写数据结构,代写ios android程序。除外还代做Web开发、Php网站开发、ASP.NET网站作业等。
    99源码网,程序代做,代写程序代码,代写编程,代写Java编程,代写php编程,计算机专业代做,计算机毕业设计,网站建设,网站开发,程序 » python识别4位数字验证码(模型训练)

    常见问题FAQ

    免费下载或者VIP会员专享资源能否直接商用?
    本站所有资源版权均属于原作者所有,这里所提供资源均只能用于参考学习用,请勿直接商用。若由于商用引起版权纠纷,一切责任均由使用者承担。更多说明请参考 VIP介绍。
    提示下载完但解压或打开不了?
    最常见的情况是下载不完整: 可对比下载完压缩包的与网盘上的容量,若小于网盘提示的容量则是这个原因。这是浏览器下载的bug,建议用百度网盘软件或迅雷下载。若排除这种情况,可在对应资源底部留言,或 联络我们.。
    找不到素材资源介绍文章里的示例图片?
    对于PPT,KEY,Mockups,APP,网页模版等类型的素材,文章内用于介绍的图片通常并不包含在对应可供下载素材包内。这些相关商业图片需另外购买,且本站不负责(也没有办法)找到出处。 同样地一些字体文件也是这种情况,但部分素材会在素材包内有一份字体下载链接清单。
    99源码网
    一个专注优质源码分享的平台
    • 2021-05-12Hi,初次和大家见面了,请多关照!

    发表回复

    售后服务:

    • 售后服务范围 1、商业模板使用范围内问题免费咨询
      2、源码安装、模板安装(一般 ¥50-300)服务答疑仅限SVIP用户
      3、单价超过200元的模板免费一次安装,需提供服务器信息。
      付费增值服务 1、提供软件定制、二次开发等服务请详询在线客服
      2、承接系统建站、仿站、开发、定制等服务
      3、服务器环境配置(一般 ¥50-300)
      4、网站中毒处理(需额外付费,500元/次/质保三个月)
      售后服务时间 周一至周日(法定节假日除外) 9:00-23:00
      免责声明 本站所提供的源码等资源仅供学习交流,若使用商业用途,请购买正版授权,否则产生的一切后果将由下载用户自行承担,有部分资源为网上收集或仿制而来,若模板侵犯了您的合法权益,请来信通知我们(Email: 3484724101@qq.com),我们会及时删除,给您带来的不便,我们深表歉意!

    Hi, 如果你对这款软件有疑问,可以跟我联系哦!

    联系作者
    • 5615会员总数(位)
    • 2181资源总数(个)
    • 0本周发布(个)
    • 0 今日发布(个)
    • 1476稳定运行(天)

    提供最优质的资源集合

    立即查看 了解详情