Sign inSign up

blazordevlab/paddleocrapi

By blazordevlab

•Updated over 1 year ago

A simple way to deploy PaddleOCR based on FastAPI.

Image
API management
Web servers
2

7.6K

blazordevlab/paddleocrapi repository overview

⁠PaddleOCRFastAPI

GitHub⁠

A simple way to deploy PaddleOCR based on FastAPI.

⁠Support Version

PaddleOCRBranch
v2.7.3paddleocr-v2.7.3⁠

⁠Features

  • Local path image recognition
  • Base64 data recognition
  • Upload file recognition

⁠Deployment Methods

⁠Deploy Directly
  1. Copy the project to the deployment path

    git clone https://github.com/neozhu/PaddleOCRFastAPI
    

    The master branch is the most recent version of PaddleOCR supported by the project. To install a specific version, clone the branch with the corresponding version number.

  2. (Optional) Create new virtual environment to avoid dependency conflicts

  3. Install required dependencies

    pip3 install -r requirements.txt
    
  4. Run FastAPI

    uvicorn main:app --host 0.0.0.0
    
⁠Docker Deployment

Test completed in Centos 7, Ubuntu 20.04, Ubuntu 22.04, Windows 10, Windows 11, requires Docker to be installed.

  1. Copy the project to the deployment path

    git clone https://github.com/cgcel/PaddleOCRFastAPI.git
    

    The master branch is the most recent version of PaddleOCR supported by the project. To install a specific version, clone the branch with the corresponding version number.

  2. Building a Docker Image

    docker build -t paddleocrfastapi:<your_tag> .
    
  3. Edit docker-compose.yml

    version: "3.8"
    
    services:
    
       paddleocr:
         container_name: paddle_ocr_api # 自定义容器名
         image: blazordevlab/paddleocrapi:latest # 第2步自定义的镜像名与标签
         environment:
           - TZ=Asia/Hong_Kong
           - OCR_LANGUAGE=ch
         ports:
          - 8000:8000 # 自定义服务暴露端口, 8000为FastAPI默认端口, 不做修改
        restart: unless-stopped
    
  4. Create the Docker container and run

    docker compose up -d
    
  5. Swagger Page at localhost:<port>/docs

⁠Change language

  1. Clone this repo to localhost.

  2. Edit routers/ocr.py, modify the parameter "lang":

    ocr = PaddleOCR(use_angle_cls=True, lang="ch")
    

    Before modify, read the supported language list⁠.

  3. Rebuild the docker image, or run the main.py directly.

⁠Screenshots

Swagger

⁠Todo

  • support ppocr v4
  • GPU mode
  • Image url recognition

⁠License

PaddleOCRFastAPI is licensed under the MIT license. Refer to LICENSE⁠ for more information.

Tag summary

Content type

Image

Digest

sha256:c004a5a1d…

Size

988.3 MB

Last updated

over 1 year ago

docker pull blazordevlab/paddleocrapi