Code Monkey home page Code Monkey logo

paddlewebocr's Introduction

PaddleWebOCR

开源的中英文离线 OCR,使用 PaddleOCR 实现,提供了简单的 Web 页面及接口。

An opensource offline multi-languages OCR system shipped with RESTful api and web page.

介绍

使用了开源的 PaddleOCR 并内置了多个模型,可以在离线环境下运行,并且相关资料丰富便于自行训练模型。PaddleOCR 本身支持中文简体繁体,英文,韩文等等多种语言,本项目只内置了中英文(简体中文和繁体中文)的模型,如需要识别其它语言,可以参考本项目调整模型。

web页面

特性

  • 中文简体/繁体,英语等多语种识别

安装需求

运行平台

  • ✔ Python 3.7+
  • ✔ Windows 10/11
  • ✔ CentOS 7
  • ✔ MacOS Big Sur
  • ✔ Docker

Windows、CentOS 和 MacOS 系统下在安装好依赖之后可以直接运行,目前只构建了 paddlepaddle 的 CPU 版本,不支持 GPU。也过通过构建 Docker 镜像或者直接从 DockerHub 拉去镜像来使用。

最低配置要求

  • CPU: 2 核
  • 内存: 4GB

安装说明

服务器部署

  1. 安装好 nodejs 之后进入 webui 目录
cd webui
npm install
npm run build
  1. 安装 python 3.7

  2. 安装依赖包

pip install -r requirements.txt
  1. 运行,项目默认运行在 8080 端口:
uvicorn paddlewebocr.main:app --host 0.0.0.0 --port 8080


#或者

PYTHONPATH="${PYTHONPATH}:." python paddlewebocr/main.py [--port=8080]

Docker 部署

推荐从 DockerHub pull 运行镜像

docker run -d -p 8080:8080 -v ${PWD}/logs:/app/logs --name paddlewebocr lewangdev/paddlewebocr:latest

使用脚本构建本地镜像(因为要编译 GCC,整个构建过程非常漫长)

# Dockerfile 构建
./build-docker-image.sh

# 运行镜像
docker run -d -p 8080:8080 -v ${PWD}/logs:/app/logs --name paddlewebocr paddlewebocr:latest 

接口调用示例

  • Python 使用 File 上传文件
import requests
url = 'http://127.0.0.1:8080/api/ocr'
img1_file = {
    'img_upload': open('img1.png', 'rb')
}
res = requests.post(url=url, data={'compress': 0}, files=img1_file)
  • Python 使用 Base64
import requests
import base64


def img_to_base64(img_path):
    with open(img_path, 'rb')as read:
        b64 = base64.b64encode(read.read())
    return b64


url = 'http://127.0.0.1:8080/api/ocr'
img_b64 = img_to_base64('./img1.png')
res = requests.post(url=url, data={'img_b64': img_b64})

效果展示

英文文档识别

中文文档识别

验证码识别

验证码识别

火车票

火车票

发票

身份证

海报

更新记录

查看更新记录

致谢

本项目参考了 TrWebOCR,由于 TrWebOCR 启动时需要联网并且它使用的 Tr 相关的资料比较少,故而尝试使用 paddlepaddlepaddleocr 来替换 Tr, 从而有了本项目。

License

Apache 2.0

paddlewebocr's People

Contributors

lewangdev 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.