Coder Social home page Coder Social logo

opweiyi / chineseocr_lite Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 1.0 438.29 MB

License: GNU General Public License v2.0

Dockerfile 0.02% Java 0.37% CMake 0.27% C++ 91.09% C 4.68% Objective-C 0.16% Python 2.17% Makefile 0.01% CSS 0.19% JavaScript 0.94% HTML 0.09%

chineseocr_lite's Introduction

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

环境

  • pytorch 1.2.0

  • python3

  • linux/macos/windows


  • windows环境配置参考热心网友的文章Python构建快速高效的中文文字识别OCR 👍
  • windows环境运行需要手动编译psenet/pse目录下的pse.cpp为DLL,为了方便新增支持python3.5和python3.6的pyd文件,在windows平台运行 的时候需要根据自己环境的python版本更改对应的pyd文件为pse.pyd即可

Docker 环境

  • 重写Dockerfile,资源占用更小,可在1C 1G的学生服务器编译成功
  • 容器环境是python3.6 + pytorch-cpu1.2
  • 编译方式:在项目根目录下运行 docker build -t chineseocr:v1 .
  • Flask-RESTful API运行方式: docker run --name ocr_api -p5000:5000 -d <Image ID> 请求方式详见下方
  • web app运行方式:docker run --name ocr_ui -p8000:8000 -d <Image ID> python3 app.py 8000

PSENET 编译

cd psenet/pse
rm -rf pse.so 
make 

实现功能

  • 提供轻量的backone检测模型psenet(8.5M),crnn_lstm_lite(9.5M) 和行文本方向分类网络(1.5M)
  • 任意方向文字检测,识别时判断行文本方向
  • crnn\crnn_lite lstm\dense识别(ocr-dense和ocr-lstm是搬运chineseocr的)
  • 支持竖排文本识别
  • ncnn 实现 (支持lstm) nihui大佬实现的crnn_lstm推理 具体操作详解: 详细记录超轻量中文OCR LSTM模型ncnn实现
  • 提供竖排文字样例以及字体库(旋转90度的字体)
  • dbnet ncnn 实现 (感谢 @zhengqicl 的实现)

2020.07.02更新

  • 提供dbnet模型,dbnet.onnx(3.7M) dbnet_lite.onnx(1.7M)

2020.03.16更新

2020.03.12更新

  • 升级crnn_lite_lstm_dw.pth模型crnn_lite_lstm_dw_v2.pth , 精度更高

竖排字体样式:

竖排生成的竖排文本样例:

web服务启动

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

访问服务

http://127.0.0.1:8080/ocr

Flask-RESTful API demo

cd chineseocr_lite && python flask_app.py

- 请求url: http://ip:port/api/v1/ocr
- 请求方式:POST
- 请求参数
    - ImgString:图片转base64后的字符串, str
- 返回实例
{
    "code": "SUCCESS",
    "text": "不配图我总觉得不舒服不完整不专业"
}

识别结果展示

ncnn检测识别展示(x86 cpu 单进程)

flask-restful api 内存测试(dbnet)

200张图片测试稳定在1-1.5G左右的内存

参考

  1. ncnn https://github.com/Tencent/ncnn
  2. crnn https://github.com/meijieru/crnn.pytorch.git
  3. chineseocr https://github.com/chineseocr/chineseocr
  4. Psenet https://github.com/WenmuZhou/PSENet.pytorch
  5. 语言模型实现 https://github.com/lukhy/masr

chineseocr_lite's People

Contributors

daybreak-u avatar pad0y avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Forkers

lem89757

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.