đ latin_PP-OCRv3_mobile_rec
latin_PP-OCRv3_mobile_rec is a text line recognition model developed by the PaddleOCR team. It's part of the PP-OCRv3_rec series, specifically trained for Latin recognition based on the PP-OCRv3_mobile_rec model. This model offers high accuracy and efficiency for Latin text recognition tasks.
đ Quick Start
đĻ Installation
-
PaddlePaddle
Install PaddlePaddle using pip with the following commands:
python -m pip install paddlepaddle-gpu==3.0.0 -i https://www.paddlepaddle.org.cn/packages/stable/cu118/
python -m pip install paddlepaddle-gpu==3.0.0 -i https://www.paddlepaddle.org.cn/packages/stable/cu126/
python -m pip install paddlepaddle==3.0.0 -i https://www.paddlepaddle.org.cn/packages/stable/cpu/
For more details on PaddlePaddle installation, refer to the PaddlePaddle official website.
-
PaddleOCR
Install the latest version of the PaddleOCR inference package from PyPI:
python -m pip install paddleocr
đģ Usage Examples
đ Basic Usage
You can quickly test the model's functionality with a single command:
paddleocr text_recognition \
--model_name latin_PP-OCRv3_mobile_rec \
-i https://cdn-uploads.huggingface.co/production/uploads/681c1ecd9539bdde5ae1733c/az8vEPS1Q3718b3D0ehNj.png
You can also integrate the model into your project. First, download the sample image to your local machine. Then run the following code:
from paddleocr import TextRecognition
model = TextRecognition(model_name="latin_PP-OCRv3_mobile_rec")
output = model.predict(input="az8vEPS1Q3718b3D0ehNj.png", batch_size=1)
for res in output:
res.print()
res.save_to_img(save_path="./output/")
res.save_to_json(save_path="./output/res.json")
After running, the result is as follows:
{'res': {'input_path': '/root/.paddlex/predict_input/az8vEPS1Q3718b3D0ehNj.png', 'page_index': None, 'rec_text': 'Latini multilinearis', 'rec_score': 0.9983808398246765}}
For more details on usage commands and parameter descriptions, refer to the Document.
đ Advanced Usage - Pipeline Usage
The ability of a single model is limited. However, a pipeline consisting of several models can handle more complex real - world scenarios.
PP-OCRv3 Pipeline
The general OCR pipeline extracts text information from images and outputs it in string format. It consists of 5 modules:
- Document Image Orientation Classification Module (Optional)
- Text Image Unwarping Module (Optional)
- Text Line Orientation Classification Module (Optional)
- Text Detection Module
- Text Recognition Module
Run the following command to quickly experience the OCR pipeline:
paddleocr ocr -i https://cdn-uploads.huggingface.co/production/uploads/681c1ecd9539bdde5ae1733c/E-CtmA3e9B1yfBqLJOXMj.png \
--text_recognition_model_name latin_PP-OCRv3_mobile_rec \
--use_doc_orientation_classify False \
--use_doc_unwarping False \
--use_textline_orientation True \
--save_path ./output \
--device gpu:0
The result will be printed to the terminal:
{'res': {'input_path': '/root/.paddlex/predict_input/E-CtmA3e9B1yfBqLJOXMj.png', 'page_index': None, 'model_settings': {'use_doc_preprocessor': True, 'use_textline_orientation': True}, 'doc_preprocessor_res': {'input_path': None, 'page_index': None, 'model_settings': {'use_doc_orientation_classify': False, 'use_doc_unwarping': False}, 'angle': -1}, 'dt_polys': array([[[ 11, 5],
...,
[ 11, 33]],
...,
[[ 11, 78],
...,
[ 11, 102]]], dtype=int16), 'text_det_params': {'limit_side_len': 64, 'limit_type': 'min', 'thresh': 0.3, 'max_side_limit': 4000, 'box_thresh': 0.6, 'unclip_ratio': 1.5}, 'text_type': 'general', 'textline_orientation_angles': array([0, ..., 0]), 'text_rec_score_thresh': 0.0, 'rec_texts': ['Exemplum', 'probationis textus', 'Latini multilinearis'], 'rec_scores': array([0.99786115, ..., 0.99657601]), 'rec_polys': array([[[ 11, 5],
...,
[ 11, 33]],
...,
[[ 11, 78],
...,
[ 11, 102]]], dtype=int16), 'rec_boxes': array([[ 11, ..., 33],
...,
[ 11, ..., 102]], dtype=int16)}}
For project integration, you can use the following code:
from paddleocr import PaddleOCR
ocr = PaddleOCR(
text_recognition_model_name="latin_PP-OCRv3_mobile_rec",
use_doc_orientation_classify=False,
use_doc_unwarping=False,
use_textline_orientation=True,
device="gpu:0",
)
result = ocr.predict("https://cdn-uploads.huggingface.co/production/uploads/681c1ecd9539bdde5ae1733c/E-CtmA3e9B1yfBqLJOXMj.png")
for res in result:
res.print()
res.save_to_img("output")
res.save_to_json("output")
The default model in the pipeline is PP-OCRv5_server_rec
. You can specify latin_PP-OCRv3_mobile_rec
using the text_recognition_model_name
argument. You can also use a local model file with the text_recognition_model_dir
argument. For more details, refer to the Document.
⨠Features
The latin_PP-OCRv3_mobile_rec model has the following features:
Property |
Details |
Model Type |
An ultra - lightweight Latin recognition model based on PP-OCRv3 |
Recognition Avg Accuracy(%) |
76.93 |
Model Storage Size (M) |
7.8 M |
Function |
Supports Latin and numeric character recognition |
â ī¸ Important Note
If any character (including punctuation) in a line was incorrect, the entire line was marked as wrong. This ensures higher accuracy in practical applications.
đ Documentation
đ License
This project is licensed under the Apache-2.0 license.