17 Star 78 Fork 24

张勇建 / chineseocr

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

本项目基于yolo3crnn 实现中文自然场景文字检测及识别

master分支将保留一周,后续app分支将替换为master

实现功能

  • 文字方向检测 0、90、180、270度检测(支持dnn/tensorflow)
  • 支持(darknet/opencv dnn /keras)文字检测,支持darknet/keras训练
  • 不定长OCR训练(英文、中英文) crnn\dense ocr 识别及训练 ,新增pytorch转keras模型代码(tools/pytorch_to_keras.py)
  • 支持darknet 转keras, keras转darknet, pytorch 转keras模型
  • 新增对身份证/火车票结构化数据识别
  • 新增语音模型修正OCR识别结果
  • 新增CNN+ctc模型,支持DNN模块调用OCR,单行图像平均时间为0.02秒以下
  • 优化CPU调用,识别速度与GPU接近(近期更新)

环境部署

GPU部署 参考:setup.md
CPU部署 参考:setup-cpu.md

下载编译darknet(如果直接运用opencv dnn或者keras yolo3 可忽略darknet的编译)

git clone https://github.com/pjreddie/darknet.git 
mv darknet chineseocr/
##编译对GPU、cudnn的支持 修改 Makefile
#GPU=1
#CUDNN=1
#OPENCV=0
#OPENMP=0
make 

修改 darknet/python/darknet.py line 48
root = '/root/'##chineseocr所在目录
lib = CDLL(root+"chineseocr/darknet/libdarknet.so", RTLD_GLOBAL)

下载模型文件

模型文件地址:

复制文件夹中的所有文件到models目录

模型转换

pytorch ocr 转keras ocr

python tools/pytorch_to_keras.py  -weights_path models/ocr-dense.pth -output_path models/ocr-dense-keras.h5

darknet 转keras

python tools/darknet_to_keras.py -cfg_path models/text.cfg -weights_path models/text.weights -output_path models/text.h5

keras 转darknet

python tools/keras_to_darknet.py -cfg_path models/text.cfg -weights_path models/text.h5 -output_path models/text.weights

编译语言模型

git clone --recursive https://github.com/parlance/ctcdecode.git   
cd ctcdecode   
pip install .  

下载语言模型

wget https://deepspeech.bj.bcebos.com/zh_lm/zh_giga.no_cna_cmn.prune01244.klm
mv zh_giga.no_cna_cmn.prune01244.klm chineseocr/models/

web服务启动

cd chineseocr## 进入chineseocr目录
ipython app.py 8080 ##8080端口号,可以设置任意端口

构建docker镜像

##下载Anaconda3 python 环境安装包(https://repo.anaconda.com/archive/Anaconda3-2019.03-Linux-x86_64.sh) 放置在chineseocr目录下   
##建立镜像   
docker build -t chineseocr .   
##启动服务   
docker run -d -p 8080:8080 chineseocr /root/anaconda3/bin/python app.py

识别结果展示

访问服务

http://127.0.0.1:8080/ocr

参考

  1. yolo3 https://github.com/pjreddie/darknet.git
  2. crnn https://github.com/meijieru/crnn.pytorch.git
  3. ctpn https://github.com/eragonruan/text-detection-ctpn
  4. CTPN https://github.com/tianzhi0549/CTPN
  5. keras yolo3 https://github.com/qqwweee/keras-yolo3.git
  6. darknet keras 模型转换参考 参考:https://www.cnblogs.com/shouhuxianjian/p/10567201.html
  7. 语言模型实现 https://github.com/lukhy/masr
MIT License Copyright (c) 2018 chineseocr Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

基于yolo3 与crnn 实现中文自然场景文字检测及识别 展开 收起
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Python
1
https://gitee.com/Petrichor_cyj/chineseocr_darknet.git
git@gitee.com:Petrichor_cyj/chineseocr_darknet.git
Petrichor_cyj
chineseocr_darknet
chineseocr
master

搜索帮助

14c37bed 8189591 565d56ea 8189591