-
Notifications
You must be signed in to change notification settings - Fork 35
Training (训练)
需要确保安装了 Composer 以及 PHP 版本大于 7 以及安装了GD扩展
如果需要训练自己的字典,推荐使用 git 拉取的方式,而非使用 composer 引入
- 使用 git 将源文件拉取
git clone https://github.com/Kuri-su/CAPTCHA_Reader.git- 使用Composer生成ClassMap
composer update
# 如果此处运行成功,会在输出 Success 的信息,并 CAPTCHA_Reader 目录下生成一个 verdor 文件夹-
修改配置文件 因为训练过程中分为
训练和测试过程,所以需要配置Config/app.php和Config/training.php两个文件此前,假设你已经写好了四个步骤的类。
GetImageInfo.example.phpPretreatment.example.phpCutting.example.phpIdentify.example.php
并且已经将 学习样本集和测试集分别放到了
sample/StudySamples/example和sample/TestSamples/example/0下此时修改
Config/training.php的studyGroup数组,改成对应的类,按照顺序- GetImageInfo
- Pretreatment
- Cutting
- Identify
<?php 'studyGroup' => [ 'example' => [ [ \CAPTCHAReader\src\App\GetImageInfo\GetImageInfo::class, \CAPTCHAReader\src\App\Pretreatment\Pretreatment::class, \CAPTCHAReader\src\App\Cutting\Cutting::class, \CAPTCHAReader\src\App\Identify\Identify::class, ], ], ],
并指定样本的位置,在
studySampleGroup和testSampleGroup数组中添加我们的样本集位置,键名请保持和方案名一致<?php 'studySampleGroup' => [ ... 'example' => __DIR__ . '/../../sample/StudySamples/example/', ], 'testSampleGroup' => [ ... 'example' => __DIR__ . '/../../sample/TestSamples/example/0/', ],
然后在
Config/app.php中的componentGroup数组中添加一个元素<?php 'componentGroup' => [ 'ZhengFangNormal' => [...], 'QinGuoNormal' => [...], 'TianYiNormal' => [...], 'NeeaNormal' => [...], 'example' => [ 'components' => [ \CAPTCHAReader\src\App\GetImageInfo\GetImageInfo::class, \CAPTCHAReader\src\App\Pretreatment\Pretreatment::class, \CAPTCHAReader\src\App\Cutting\Cutting::class, \CAPTCHAReader\src\App\Identify\Identify::class, ], 'dictionary' => 'GetImageInfo-Pretreatment-Cutting-Identify.json', ], ],
并修改
Config/app.php中的useGroup,使用这个example方案<?php 'useGroup' => 'example',
-
开始训练 执行命令,开始训练
php training/AddSamples/Test.php
这个脚本干的事就是 去获得一个
training/AddSamples/AddSamplesAuto.php类实例,然后运行里面的 run 方法。这个
training/AddSamples/AddSamplesAuto.php类干的事情如下 * 遍历读取我们配置的 训练集和测试集 文件夹内的全部的图片文件路径 * 然后不断的使用 配置的方案去对 训练集中的文件 进行识别,若识别结果和实际结果一致,则通过,若未通过,则记录一段字符串到我们设置的字典文件中去,字典文件的路径在src/Dictionary内 * 然后到了指定的阈值时,会使用测试集开始验证,并返回验证结果。(在 AddSamplesAuto.php 的 109 行修改阈值)当全部的训练文件用完或者识别率达到我们设定的值,则训练结束
- 文档wiki结构
- Get started (detail)
- FAQ
- 文件结构和类结构
- 配置文件介绍
- 按步骤介绍各个类
- 获取文件
- 预处理(降噪)
- 正方
- 青果
- neea
- tianyi
- 切割
- 正方
- 青果
- neea
- tianyi
- 识别
- 正方
- 青果
- neea
- tianyi
- 附录
- 部分毕业论文内容(用于开拓思路)