# 12306-captcha [![Author](https://img.shields.io/badge/Author-%E4%B8%AD%E9%BE%84%E7%A8%8B%E5%BA%8F%E5%91%98-blue.svg)](https://www.shanruifeng.win) [![License](https://img.shields.io/badge/license-Apache%202-blue.svg)](LICENSE) [![Stars](https://img.shields.io/github/stars/aaronshan/12306-captcha.svg?label=Stars&style=social)](https://github.com/aaronshan/12306-captcha)
12306验证码识别
## 1. 训练
### 1.1 准备工作
* 下载caffe并编译, 具体可参考官方文档, 此处不再赘述.
* 修改`src/config.py`中的caffe根目录和项目根目录.
* pip安装easydict, skimage等.
### 1.2 数据
* 通过运行`src/tools/download_image.py`, 会将12306验证码下载至`data/download/all`目录.
* 下载完成后, 通过运行`src/tools/cut_image.py`, 会将其裁剪为图片和文字两部分, 分别放在`data/download/image`目录和`data/download/words`目录.
* 修改`src/image/scripts/words.py`文件main方法中cut方法的参数(其参数为`data/download/words`中子目录的`words_*`中的数字), 它的目的是处理`data/download/words`中的所有子文件, 对多个词语进行分割并调整大小为固定值.
* 然后手工对其进行分类, 分别放至`data/image`和`data/words`目录. 可以将其分为两部分,分别放在对应的train和test目录.比如,一个示例目录如下:
```
-image
--test
---蜡烛
----1-1.jpg
---沙漠
----2-1.jpg
--train
---蜡烛
----1-2.jpg
---沙漠
----2-2.jpg
```
#### 图片部分
* 运行`src/image/scripts/create_data.py`, 将会生成图片部分对应的train.txt和test.txt, 里面包含着训练和测试文件及其类别列表.
* 运行`src/image/scripts/create_lmdb.sh`, 将会生成图片部分对应的lmdb文件.
#### 文字部分
* 运行`src/words/scripts/create_data.py`, 将会生成文字部分对应的train.txt和test.txt, 里面包含着训练和测试文件及其类别列表.
* 运行`src/words/scripts/create_lmdb.sh`, 将会生成文字部分对应的lmdb文件.
### 1.3 参数
可以根据实际情况对`src/image/model/image_solver.prototxt`和`src/words/model/words_solver.prototxt`文件进行修改.具体修改方法可参考其他模型.
### 1.4 开始训练
`src/image/scripts/image_train.sh`和`src/image/scripts/image_finetune_train.sh`脚本分别用来进行从头训练/微调训练, 训练方法可参考caffe模型训练方法.
同理:
`src/words/scripts/words_train.sh`和`src/words/scripts/words_finetune_train.sh`脚本分别用来进行从头训练/微调训练, 训练方法可参考caffe模型训练方法.
## 测试
`src/web`提供了一个web测试界面, 运行index.py即可. 运行前, 可以更改对应的模型文件名称. 一个简单示例如下:
![web-demo](https://github.com/aaronshan/12306-captcha/blob/master/web-demo.png)
## 其他
1. 在实际应用中, 会使用从百度/搜狗/谷歌等图片搜索引擎中爬取图片并做处理的方式来完成图片分类收集工作. 比如爬取关键词为档案袋的图片, 再进一步做处理. 以解决从12306下载并裁剪-手工分类效率太低及样本量不足的问题, 提升效率。
2. 此外, 项目里对文字部分的分割也不是很完美. 对图片的分类也是裁剪并逐个进行的, 这样的响应效率不会很高. 可以使用目标检测的方式, 对整个验证码图片做目标检测, 同时检测8个图片及文字部分. 以加快检测速度.
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
基于深度学习的12306验证码识别.zip (65个子文件)
12306-captcha-master
web-demo.png 406KB
src
__init__.py 207B
tools
__init__.py 0B
download_image.py 2KB
words.py 17KB
remove_noisy.py 2KB
cut_image.py 3KB
words
model
words_train_val.prototxt 7KB
words_deploy.prototxt 6KB
words_solver.prototxt 264B
scripts
words_train.sh 353B
create_data.py 2KB
create_lmdb.sh 518B
words_finetune_train.sh 665B
calc_mean.sh 199B
image
image-classify.py 3KB
model
image_train_val.prototxt 7KB
image_solver.prototxt 277B
image_deploy.prototxt 6KB
scripts
create_data.py 2KB
create_lmdb.sh 519B
calc_mean.sh 200B
image_finetune_train.sh 660B
image_train.sh 353B
web
__init__.py 0B
index.py 5KB
utils
__init__.py 0B
Img12306.py 3KB
templates
12306.html 2KB
static
js
jquery-2.1.1.min.js 127KB
index.js 2KB
bootstrap
js
bootstrap.js 62KB
bootstrap-datetimepicker.js 77KB
bootstrap2-typeahead.min.js 7KB
locales
bootstrap-datetimepicker.zh-CN.js 861B
bootstrap.min.js 37KB
bootstrap-datetimepicker.min.js 66KB
css
bootstrap-datetimepicker.css 13KB
bootstrap.min.css 122KB
bootstrap-theme.css 17KB
bootstrap-datetimepicker.min.css 25KB
bootstrap.css 124KB
bootstrap-theme.min.css 17KB
fonts
glyphicons-halflings-regular.svg 62KB
glyphicons-halflings-regular.ttf 29KB
glyphicons-halflings-regular.woff 16KB
glyphicons-halflings-regular.eot 14KB
tmp
.gitignore 56B
css
index.css 207B
README.md 0B
classify_demo.py 5KB
config.py 516B
data
words
train
.gitignore 56B
test
.gitignore 56B
image
train
.gitignore 56B
test
.gitignore 56B
download
words
.gitignore 56B
image
.gitignore 56B
all
.gitignore 56B
LICENSE 11KB
model
words
.gitignore 56B
image
.gitignore 56B
label
synset 5KB
.gitignore 1KB
README.md 3KB
共 65 条
- 1
资源评论
Nowl
- 粉丝: 1w+
- 资源: 3678
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 基于matlab 概率神经网络的分类预测-基于PNN的变压器故障诊断源代码+详细教程
- IMG_2779.PNG
- 基于matlab Elman神经网络的数据预测-电力负荷预测模型研究源代码+详细教程
- 架构师软考知识点整理2
- 基于matlab SOM神经网络的数据分类-柴油机故障诊断源代码+详细教程
- 2023.cpp
- 基于matlab 自组织竞争网络在模式分类中的应用-患者癌症发病预测源代码+详细教程
- 在线考试系统 JAVA+Spring+SpringMVC+MyBatis
- 毕业设计基于Python卷积神经网络CNN的图像分类系统源码+模型+说明文档+全部数据资料.zip
- matlab 基于SVM的手写字体识别源代码+详细教程
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功