Code Monkey home page Code Monkey logo

hyperlpr-train's Introduction

注意

由于本人不再从事相关工作,所以这个脚本我不再维护。提的 Issue 我也不再处理。

Hyperlpr端到端车牌识别训练脚本

该脚本用于训练HyperLPR的端到端识别模型。

依赖

Python3.5+

  • keras
  • tensorflow
  • opencv-python
  • h5py
  • numpy

使用方法

显示帮助文档:

python main.py --help

将模型导出为h5文件:

python main.py [-num_channels 3] export -m model.h5

训练:

usage: main.py train [-h] -ti TI -tl TL -vi VI -vl VL -b B -img-size IMG_SIZE
                     IMG_SIZE [-pre PRE] [-start-epoch START_EPOCH] -n N
                     [-label-len LABEL_LEN] -c C [-log LOG]

optional arguments:
  -h, --help            show this help message and exit
  -ti TI                训练图片目录
  -tl TL                训练标签文件
  -vi VI                验证图片目录
  -vl VL                验证标签文件
  -b B                  batch size
  -img-size IMG_SIZE IMG_SIZE
                        训练图片宽和高
  -pre PRE              pre trained weight file
  -start-epoch START_EPOCH
  -n N                  number of epochs
  -label-len LABEL_LEN  标签长度
  -c C                  checkpoints format string
  -log LOG              tensorboard 日志目录, 默认为空

训练用法示例:

python main.py train -ti train_imgs -tl train_labels.txt -vi val_imgs -vl val_labels.txt -b 16 -img-size 250 40 -n 100 -c checkpoints/'weights.{epoch:02d}-{val_loss:.2f}.h5' -log log

表示训练图片位于train_imgs目录下, 训练标签在train_labels.txt中。 验证图片位于val_imgs目录下, 训练标签在val_labels.txt中。 Batch size为16, 图片尺寸为250x40, 到100个epochs时结束训练。 Cehckpoints在checkpoints目录下, tensorboard的log目录为log

注意: 如果没有修改CNN结构和参数, 训练图片的高度(也就是命令行参数-img-size中的第二个参数)必须是40. 如果修改了,需要给出相应高度。

训练数据格式

训练需要准备训练数据集和验证数据集, 每种数据集都包括图片和标签两部分。

图片

图片为包含真实车牌的图片(如下图), 所有图片大小必须与命令行参数中指定的相同。

示例图片

注意:1. 车牌不必恰好包含在图片中,最好左右留出一些区域,如上图所示;左右留出区域长度不必相同。 2. 实际上在一定范围内,任意放置(只要倾斜角不太大,长度差异不是过大)的车牌都可以识别,但前提是训练数据集要准备得当。

标签

标签为UTF-8编码的纯文本文件, 每行的格式如下

filename:label

其中filename是图片名称, 不包含顶级目录1; label是真实车牌号, 英文字母必须大写,label的长度必须与命令行中的参数-label-len相同。

1 顶级目录在命令行参数中以-ti给出

hyperlpr-train's People

Contributors

armaab avatar

Watchers

James Cloos 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.