Giter Club home page Giter Club logo

pytorch-captcha-recognition's Introduction

深度学习识别验证码

本项目致力于使用神经网络来识别各种验证码。

特性

  • 端到端,不需要做更多的图片预处理(比如图片字符切割、图片尺寸归一化、图片字符标记、字符图片特征提取)
  • 验证码包括数字、大写字母、小写
  • 采用自己生成的验证码来作为神经网络的训练集合、测试集合、预测集合
  • 纯四位数字,验证码识别率高达 99.9999 %
  • 四位数字 + 大写字符,验证码识别率约 96 %
  • 深度学习框架pytorch + 验证码生成器ImageCaptcha

原理

  • 训练集合生成

    使用常用的 Python 验证码生成库 ImageCaptcha,生成 10w 个验证码,并且都自动标记好; 如果需要识别其他的验证码也同样的道理,寻找对应的验证码生成算法自动生成已经标记好的训练集合或者手动对标记,需要上万级别的数量,纯手工需要一定的时间,再或者可以借助一些网络的打码平台进行标记

  • 训练卷积神经网络 构建一个多层的卷积网络,进行多标签分类模型的训练 标记的每个字符都做 one-hot 编码 批量输入图片集合和标记数据,大概15个Epoch后,准确率已经达到 96% 以上

验证码识别率展示

快速开始

  • 步骤一:10分钟环境安装

    Python2.7+ 、ImageCaptcha库(pip install captcha)、 Pytorch(参考官网http://pytorch.org)

  • 步骤二:生成验证码

    python captcha_gen.py

    执行以上命令,会在目录 dataset/train/ 下生成多张验证码图片,图片已经标注好,数量可以是 1w、5w、10w,通过 captcha-gen.py 内的 count 参数设定

  • 步骤三:训练模型

    python captcha_train.py

    使用步骤一生成的验证码图集合用CNN模型(在 catcha_cnn_model 中定义)进行训练,训练完成会生成文件 model.pkl

  • 步骤四:测试模型

    python captcha_test.py

    可以在控制台,看到模型的准确率(如 95%) ,如果准确率较低,回到步骤一,生成更多的图片集合再次训练

  • 步骤五:使用模型做预测

    python captcha_predict.py

    可以在控制台,看到预测输出的结果

贡献

我们期待你的 pull requests !

作者

其它

  • Github项目交流QQ群 570997546

声明

本项目仅用于交流学习

pytorch-captcha-recognition's People

Contributors

dee1024 avatar kenvifire avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.