[AI PaddleOCR] PaddleOCR: Awesome multilingual Optical Character Recognition (OCR) toolkits based on PaddlePaddle
PaddleOCR
PaddleOCR aims to create multilingual, awesome, leading, and practical OCR tools that help users train better models and apply them into practice.
PaddleOCR is the awesome multilingual OCR toolkits based on PaddlePaddle (practical ultra lightweight OCR system, support 80+ languages recognition, provide data annotation and synthesis tools, support training and deployment among server, mobile, embedded and IoT devices).
Features
-
PPOCR series of high-quality pre-trained models, comparable to commercial effects
-
Ultra lightweight ppocr_mobile series models: detection (3.0M) + direction classifier (1.4M) + recognition (5.0M) = 9.4M
-
General ppocr_server series models: detection (47.1M) + direction classifier (1.4M) + recognition (94.9M) = 143.4M
-
Support Chinese, English, and digit recognition, vertical text recognition, and long text recognition
-
Support multi-language recognition: Korean, Japanese, German, French
-
-
Rich toolkits related to the OCR areas
-
Semi-automatic data annotation tool, i.e., PPOCRLabel: support fast and efficient data annotation
-
Data synthesis tool, i.e., Style-Text: easy to synthesize a large number of images which are similar to the target scene image
-
-
Support user-defined training, provides rich predictive inference deployment solutions
-
Support PIP installation, easy to use
-
Support Linux, Windows, MacOS and other systems
Visualization
The above pictures are the visualizations of the general ppocr_server model. For more effect pictures, please see More visualizations - https://github.com/PaddlePaddle/PaddleOCR/blob/release/2.1/doc/doc_en/visualization_en.md.
Installation
Install PaddlePaddle
PaddleOCR working environment:
-
PaddlePaddle 2.0.0
-
python3.7
-
glibc 2.23
It is recommended to use the docker provided by us to run PaddleOCR, please refer to the use of Docker - https://docs.docker.com/get-started/.
If you want to directly run the prediction code on mac or windows, you can start from step 2.
-
- (Recommended) Prepare a docker environment. The first time you use this docker image, it will be downloaded automatically. Please be patient.
1 | Switch to the working directory |
If using CUDA10, please run the following command to create a container. It is recommended to set a shared memory greater than or equal to 32G through the --shm-size parameter:
1 | sudo nvidia-docker run --name ppocr -v $PWD:/paddle --shm-size=64G --network=host -it paddlepaddle/paddle:latest-dev-cuda10.1-cudnn7-gcc82 /bin/bash |
You can also visit DockerHub to get the image that fits your machine.
1 | ctrl+P+Q to exit docker, to re-enter docker using the following command: |
-
- Install PaddlePaddle 2.0
1 | pip3 install --upgrade pip |
For more software version requirements, please refer to the instructions in Installation Document for operation.
- Clone PaddleOCR repo
1 | git clone https://github.com/PaddlePaddle/PaddleOCR |
-
- Install third-party libraries
1 | cd PaddleOCR |
Install PaddleOCR
(Quickly) Install paddleocr package via pip
1 | pip install "paddleocr>=2.0.1" # Recommend to use version 2.0.1+ |
Or build own whl package and install
1 | python3 setup.py bdist_wheel |
Usage
The paddleocr whl package will automatically download the ppocr lightweight model as the default model, which can be customized and replaced according to the section 3 Custom Model - https://github.com/PaddlePaddle/PaddleOCR/blob/release/2.1/doc/doc_en/whl_en.md#3-use-custom-model.
detection angle classification and recognition
1 | from paddleocr import PaddleOCR,draw_ocr |
Output will be a list, each item contains bounding box, text and recognition confidence
1 | [[[442.0, 173.0], [1169.0, 173.0], [1169.0, 225.0], [442.0, 225.0]], ['ACKNOWLEDGEMENTS', 0.99283075]] |
Visualization of results
See PaddleOCR Use - https://github.com/PaddlePaddle/PaddleOCR/blob/release/2.1/doc/doc_en/whl_en.md#2-use to learn more usages.
FAQs
No matching distribution found for opencv-contrib-python==4.2.0.32
1 | pip3 install -r requirements.txt |
PaddleOCR currently only supports python 3.7. Please check python version.