--- comments: true --- # Seal Text Recognition Pipeline Usage Tutorial ## 1. Introduction to Seal Text Recognition Pipeline Seal text recognition is a technology that automatically extracts and recognizes the content of seals from documents or images. The recognition of seal text is part of document processing and has many applications in various scenarios, such as contract comparison, warehouse entry and exit review, and invoice reimbursement review. The seal text recognition pipeline is used to recognize the text content of seals, extracting the text information from seal images and outputting it in text form. This pipeline integrates the industry-renowned end-to-end OCR system PP-OCRv4, supporting the detection and recognition of curved seal text. Additionally, this pipeline integrates an optional layout region localization module, which can accurately locate the layout position of the seal within the entire document. It also includes optional document image orientation correction and distortion correction functions. Based on this pipeline, millisecond-level accurate text content prediction can be achieved on a CPU. This pipeline also provides flexible service deployment methods, supporting the use of multiple programming languages on various hardware. Moreover, it offers custom development capabilities, allowing you to train and fine-tune on your own dataset based on this pipeline, and the trained model can be seamlessly integrated. The seal text recognition pipeline includes a seal text detection module and a text recognition module, as well as optional layout detection module, document image orientation classification module, and text image correction module. - [Seal Text Detection Module](../module_usage/seal_text_detection.en.md) - [Text Recognition Module](../module_usage/text_recognition.en.md) - [Layout Detection Module](../module_usage/layout_detection.en.md) (Optional) - [Document Image Orientation Classification Module](../module_usage/doc_img_orientation_classification.en.md) (Optional) - [Text Image Unwarping Module](../module_usage/text_image_unwarping.en.md) (Optional) In this pipeline, you can choose the model to use based on the benchmark data below. > The inference time only includes the model inference time and does not include the time for pre- or post-processing. > In the inference time columns labeled [Regular Mode / High-Performance Mode], the Regular Mode values correspond to the local `paddle_static` inference engine.
Layout Region Detection Module (Optional): * Layout detection model, including 20 common categories: document title, paragraph title, text, page number, abstract, table of contents, references, footnotes, header, footer, algorithm, formula, formula number, image, table, figure and table title (figure title, table title, and chart title), seal, chart, sidebar text, and reference content
ModelModel Download Link mAP(0.5) (%) GPU Inference Time (ms)
[Regular Mode / High-Performance Mode]
CPU Inference Time (ms)
[Regular Mode / High-Performance Mode]
Model Storage Size (MB) Description
PP-DocLayout_plus-L Inference Model/Training Model 83.2 53.03 / 17.23 634.62 / 378.32 126.01 A higher precision layout region localization model based on RT-DETR-L trained on a self-built dataset including Chinese and English papers, multi-column magazines, newspapers, PPTs, contracts, books, exam papers, research reports, ancient books, Japanese documents, and vertical text documents
* Layout detection model, including 23 common categories: document title, paragraph title, text, page number, abstract, table of contents, references, footnotes, header, footer, algorithm, formula, formula number, image, chart title, table, table title, seal, chart title, chart, header image, footer image, sidebar text
ModelModel Download Link mAP(0.5) (%) GPU Inference Time (ms)
[Regular Mode / High-Performance Mode]
CPU Inference Time (ms)
[Regular Mode / High-Performance Mode]
Model Storage Size (MB) Description
PP-DocLayout-L Inference Model/Training Model 90.4 33.59 / 33.59 503.01 / 251.08 123.76 A high precision layout region localization model based on RT-DETR-L trained on a self-built dataset including Chinese and English papers, magazines, contracts, books, exam papers, and research reports
PP-DocLayout-M Inference Model/Training Model 75.2 13.03 / 4.72 43.39 / 24.44 22.578 A balanced model of accuracy and efficiency based on PicoDet-L trained on a self-built dataset including Chinese and English papers, magazines, contracts, books, exam papers, and research reports
PP-DocLayout-S Inference Model/Training Model 70.9 11.54 / 3.86 18.53 / 6.29 4.834 A highly efficient layout region localization model based on PicoDet-S trained on a self-built dataset including Chinese and English papers, magazines, contracts, books, exam papers, and research reports
>❗ Listed above are the 4 core models that are the focus of the layout detection module, which supports a total of 13 full models, including multiple models with pre-defined different categories, among which 9 models include the seal category. Apart from the 3 core models mentioned above, the remaining models are as follows:
👉Details of the Model List * 3-class layout detection model, including table, image, seal
ModelModel Download Link mAP(0.5) (%) GPU Inference Time (ms)
[Regular Mode / High-Performance Mode]
CPU Inference Time (ms)
[Regular Mode / High-Performance Mode]
Model Storage Size (MB) Description
PicoDet-S_layout_3cls Inference Model/Training Model 88.2 8.43 / 3.44 17.60 / 6.51 4.8 A highly efficient layout region localization model based on the lightweight PicoDet-S model trained on a self-built dataset including Chinese and English papers, magazines, and research reports
PicoDet-L_layout_3cls Inference Model/Training Model 89.0 12.80 / 9.57 45.04 / 23.86 22.6 An efficiency-accuracy balanced layout region localization model based on PicoDet-L trained on a self-built dataset including Chinese and English papers, magazines, and research reports
RT-DETR-H_layout_3cls Inference Model/Training Model 95.8 114.80 / 25.65 924.38 / 924.38 470.1 A high precision layout region localization model based on RT-DETR-H trained on a self-built dataset including Chinese and English papers, magazines, and research reports
* 17-class region detection model, including 17 common layout categories: paragraph title, image, text, number, abstract, content, chart title, formula, table, table title, references, document title, footnote, header, algorithm, footer, seal
ModelModel Download Link mAP(0.5) (%) GPU Inference Time (ms)
[Regular Mode / High-Performance Mode]
CPU Inference Time (ms)
[Regular Mode / High-Performance Mode]
Model Storage Size (MB) Description
PicoDet-S_layout_17cls Inference Model/Training Model 87.4 8.80 / 3.62 17.51 / 6.35 4.8 A highly efficient layout region localization model based on the lightweight PicoDet-S model trained on a self-built dataset including Chinese and English papers, magazines, and research reports
PicoDet-L_layout_17cls Inference Model/Training Model 89.0 12.60 / 10.27 43.70 / 24.42 22.6 An efficiency-accuracy balanced layout region localization model based on PicoDet-L trained on a self-built dataset including Chinese and English papers, magazines, and research reports
RT-DETR-H_layout_17cls Inference Model/Training Model 98.3 115.29 / 101.18 964.75 / 964.75 470.2 A high precision layout region localization model based on RT-DETR-H trained on a self-built dataset including Chinese and English papers, magazines, and research reports
Document Image Orientation Classification Module (Optional):
ModelModel Download Link Top-1 Acc (%) GPU Inference Time (ms)
[Regular Mode / High-Performance Mode]
CPU Inference Time (ms)
[Regular Mode / High-Performance Mode]
Model Storage Size (MB) Description
PP-LCNet_x1_0_doc_ori Inference Model/Training Model 99.06 2.62 / 0.59 3.24 / 1.19 7 A document image classification model based on PP-LCNet_x1_0, containing four categories: 0 degrees, 90 degrees, 180 degrees, and 270 degrees
Text Image Correction Module (Optional):
ModelModel Download Link CER GPU Inference Time (ms)
[Normal Mode / High-Performance Mode]
CPU Inference Time (ms)
[Normal Mode / High-Performance Mode]
Model Storage Size (MB) Description
UVDoc Inference Model/Training Model 0.179 19.05 / 19.05 - / 869.82 30.3 A high precision text image correction model
Seal Text Detection Module:
ModelModel Download Link Detection Hmean (%) GPU Inference Time (ms)
[Regular Mode / High-Performance Mode]
CPU Inference Time (ms)
[Regular Mode / High-Performance Mode]
Model Storage Size (MB) Description
PP-OCRv4_server_seal_det Inference Model/Training Model 98.40 124.64 / 91.57 545.68 / 439.86 109 PP-OCRv4 server-side seal text detection model, with higher accuracy, suitable for deployment on better servers
PP-OCRv4_mobile_seal_det Inference Model/Training Model 96.36 9.70 / 3.56 50.38 / 19.64 4.7 PP-OCRv4 mobile-side seal text detection model, with higher efficiency, suitable for deployment on the edge
Text Recognition Module:
ModelModel Download Link Recognition Avg Accuracy(%) GPU Inference Time (ms)
[Regular Mode / High-Performance Mode]
CPU Inference Time (ms)
[Regular Mode / High-Performance Mode]
Model Storage Size (MB) Description
PP-OCRv5_server_rec Inference Model/Training Model 86.38 8.46 / 2.36 31.21 / 31.21 81 PP-OCRv5_rec is a new generation text recognition model. This model aims to efficiently and accurately support the recognition of four major languages: Simplified Chinese, Traditional Chinese, English, and Japanese, as well as complex text scenes like handwriting, vertical text, pinyin, and rare characters with a single model. It balances recognition effectiveness, inference speed, and model robustness, providing efficient and accurate technical support for document understanding in various scenarios.
PP-OCRv5_mobile_rec Inference Model/Training Model 81.29 5.43 / 1.46 21.20 / 5.32 16
PP-OCRv4_server_rec_doc Inference Model/Training Model 86.58 8.69 / 2.78 37.93 / 37.93 182 PP-OCRv4_server_rec_doc is trained on a mix of more Chinese document data and PP-OCR training data based on PP-OCRv4_server_rec, enhancing recognition capabilities for some traditional Chinese characters, Japanese, and special characters, supporting over 15,000+ characters. Besides improving document-related text recognition, it also enhances general text recognition capabilities
PP-OCRv4_mobile_rec Inference Model/Training Model 78.74 5.26 / 1.12 17.48 / 3.61 10.5 PP-OCRv4 lightweight recognition model, with high inference efficiency, can be deployed on multiple hardware devices, including edge devices
PP-OCRv4_server_rec Inference Model/Training Model 85.19 8.75 / 2.49 36.93 / 36.93 173 PP-OCRv4 server-side model, with high inference accuracy, can be deployed on various servers
en_PP-OCRv4_mobile_rec Inference Model/Training Model 70.39 4.81 / 1.23 17.20 / 4.18 7.5 An ultra-lightweight English recognition model trained based on the PP-OCRv4 recognition model, supporting English and number recognition
> ❗ Listed above are the 6 core models that are the focus of the text recognition module, which supports a total of 20 full models, including multiple multi-language text recognition models, with the complete model list as follows:
👉Details of the Model List * PP-OCRv5 Multi-Scene Model
ModelModel Download Link Chinese Recognition Avg Accuracy(%) English Recognition Avg Accuracy(%) Traditional Chinese Recognition Avg Accuracy(%) Japanese Recognition Avg Accuracy(%) GPU Inference Time (ms)
[Regular Mode / High-Performance Mode]
CPU Inference Time (ms)
[Regular Mode / High-Performance Mode]
Model Storage Size (MB) Description
PP-OCRv5_server_rec Inference Model/Training Model 86.38 64.70 93.29 60.35 8.46 / 2.36 31.21 / 31.21 81 PP-OCRv5_rec is a new generation text recognition model. This model aims to efficiently and accurately support the recognition of four major languages: Simplified Chinese, Traditional Chinese, English, and Japanese, as well as complex text scenes like handwriting, vertical text, pinyin, and rare characters with a single model. It balances recognition effectiveness, inference speed, and model robustness, providing efficient and accurate technical support for document understanding in various scenarios.
PP-OCRv5_mobile_rec Inference Model/Training Model 81.29 66.00 83.55 54.65 5.43 / 1.46 21.20 / 5.32 16
* Chinese Recognition Model
ModelModel Download Link Recognition Avg Accuracy(%) GPU Inference Time (ms)
[Regular Mode / High-Performance Mode]
CPU Inference Time (ms)
[Regular Mode / High-Performance Mode]
Model Storage Size (MB) Description
PP-OCRv4_server_rec_doc Inference Model/Training Model 86.58 8.69 / 2.78 37.93 / 37.93 182 PP-OCRv4_server_rec_doc is trained on a mix of more Chinese document data and PP-OCR training data based on PP-OCRv4_server_rec, enhancing recognition capabilities for some traditional Chinese characters, Japanese, and special characters, supporting over 15,000+ characters. Besides improving document-related text recognition, it also enhances general text recognition capabilities
PP-OCRv4_mobile_rec Inference Model/Training Model 78.74 5.26 / 1.12 17.48 / 3.61 10.5 PP-OCRv4 lightweight recognition model, with high inference efficiency, can be deployed on multiple hardware devices, including edge devices
PP-OCRv4_server_rec Inference Model/Training Model 85.19 8.75 / 2.49 36.93 / 36.93 173 PP-OCRv4 server-side model, with high inference accuracy, can be deployed on various servers
PP-OCRv3_mobile_rec Inference Model/Training Model 72.96 3.89 / 1.16 8.72 / 3.56 10.3 PP-OCRv3 lightweight recognition model, with high inference efficiency, can be deployed on multiple hardware devices, including edge devices
ModelModel Download Link Recognition Avg Accuracy(%) GPU Inference Time (ms)
[Regular Mode / High-Performance Mode]
CPU Inference Time (ms)
[Regular Mode / High-Performance Mode]
Model Storage Size (MB) Description
ch_SVTRv2_rec Inference Model/Training Model 68.81 10.38 / 8.31 66.52 / 30.83 80.5 SVTRv2 is a server-side text recognition model developed by the OpenOCR team from Fudan University's Visual and Learning Lab (FVL), which won first place in the PaddleOCR Algorithm Model Challenge - Task 1: OCR End-to-End Recognition, improving the end-to-end recognition accuracy on the A leaderboard by 6% compared to PP-OCRv4.
ModelModel Download Link Recognition Avg Accuracy(%) GPU Inference Time (ms)
[Regular Mode / High-Performance Mode]
CPU Inference Time (ms)
[Regular Mode / High-Performance Mode]
Model Storage Size (MB) Description
ch_RepSVTR_rec Inference Model/Training Model 65.07 6.29 / 1.57 20.64 / 5.40 48.8 RepSVTR text recognition model is a mobile-side text recognition model based on SVTRv2, which won first place in the PaddleOCR Algorithm Model Challenge - Task 1: OCR End-to-End Recognition, improving the end-to-end recognition accuracy on the B leaderboard by 2.5% compared to PP-OCRv4, with comparable inference speed.
* English Recognition Model
ModelModel Download Link Recognition Avg Accuracy(%) GPU Inference Time (ms)
[Regular Mode / High-Performance Mode]
CPU Inference Time (ms)
[Regular Mode / High-Performance Mode]
Model Storage Size (MB) Description
en_PP-OCRv4_mobile_rec Inference Model/Training Model 70.39 4.81 / 1.23 17.20 / 4.18 7.5 An ultra-lightweight English recognition model trained based on the PP-OCRv4 recognition model, supporting English and number recognition
en_PP-OCRv3_mobile_rec Inference Model/Training Model 70.69 3.56 / 0.78 8.44 / 5.78 17.3 An ultra-lightweight English recognition model trained based on the PP-OCRv3 recognition model, supporting English and number recognition
* Multilingual Recognition Model
ModelModel Download Link Recognition Avg Accuracy(%) GPU Inference Time (ms)
[Regular Mode / High-Performance Mode]
CPU Inference Time (ms)
[Regular Mode / High-Performance Mode]
Model Storage Size (MB) Description
korean_PP-OCRv3_mobile_rec Inference Model/Training Model 60.21 3.73 / 0.98 8.76 / 2.91 9.6 An ultra-lightweight Korean recognition model trained based on the PP-OCRv3 recognition model, supporting Korean and number recognition
japan_PP-OCRv3_mobile_rec Inference Model/Training Model 45.69 3.86 / 1.01 8.62 / 2.92 9.8 An ultra-lightweight Japanese recognition model trained based on the PP-OCRv3 recognition model, supporting Japanese and number recognition
chinese_cht_PP-OCRv3_mobile_rec Inference Model/Training Model 82.06 3.90 / 1.16 9.24 / 3.18 10.8 An ultra-lightweight Traditional Chinese recognition model trained based on the PP-OCRv3 recognition model, supporting Traditional Chinese and number recognition
te_PP-OCRv3_mobile_rec Inference Model/Training Model 95.88 3.59 / 0.81 8.28 / 6.21 8.7 An ultra-lightweight Telugu recognition model trained based on the PP-OCRv3 recognition model, supporting Telugu and number recognition
ka_PP-OCRv3_mobile_rec Inference Model/Training Model 96.96 3.49 / 0.89 8.63 / 2.77 17.4 An ultra-lightweight Kannada recognition model trained based on the PP-OCRv3 recognition model, supporting Kannada and number recognition
ta_PP-OCRv3_mobile_rec Inference Model/Training Model 76.83 3.49 / 0.86 8.35 / 3.41 8.7 An ultra-lightweight Tamil recognition model trained based on the PP-OCRv3 recognition model, supporting Tamil and number recognition
latin_PP-OCRv3_mobile_rec Inference Model/Training Model 76.93 3.53 / 0.78 8.50 / 6.83 8.7 An ultra-lightweight Latin recognition model trained based on the PP-OCRv3 recognition model, supporting Latin and number recognition
arabic_PP-OCRv3_mobile_rec Inference Model/Training Model 73.55 3.60 / 0.83 8.44 / 4.69 17.3 An ultra-lightweight Arabic letter recognition model trained based on the PP-OCRv3 recognition model, supporting Arabic letters and number recognition
cyrillic_PP-OCRv3_mobile_rec Inference Model/Training Model 94.28 3.56 / 0.79 8.22 / 2.76 8.7 An ultra-lightweight Cyrillic letter recognition model trained based on the PP-OCRv3 recognition model, supporting Cyrillic letters and number recognition
devanagari_PP-OCRv3_mobile_rec Inference Model/Training Model 96.44 3.60 / 0.78 6.95 / 2.87 8.7 An ultra-lightweight Devanagari letter recognition model trained based on the PP-OCRv3 recognition model, supporting Devanagari letters and number recognition
Test Environment Description:
Mode GPU Configuration CPU Configuration Acceleration Technology Combination
Regular Mode FP32 Precision / No TRT Acceleration FP32 Precision / 8 Threads paddle_static
High-Performance Mode Optimal combination of prior precision type and acceleration strategy FP32 Precision / 8 Threads Select optimal prior backend (Paddle/OpenVINO/TRT, etc.)

If you are more concerned with model accuracy, please choose a model with higher accuracy. If you are more concerned with inference speed, please choose a model with faster inference speed. If you are more concerned with model storage size, please choose a model with smaller storage size. ## 2. Quick Start Before using the seal text recognition pipeline locally, please ensure that you have completed the installation of the wheel package according to the [installation tutorial](../installation.md). If you prefer to install dependencies selectively, please refer to the relevant instructions in the installation documentation. The corresponding dependency group for this pipeline is `doc-parser`. Once the installation is complete, you can experience it locally via the command line or integrate it with Python. Please note: If you encounter issues such as the program becoming unresponsive, unexpected program termination, running out of memory resources, or extremely slow inference during execution, please try adjusting the configuration according to the documentation, such as disabling unnecessary features or using lighter-weight models. ### 2.1 Command Line Experience You can quickly experience the seal_recognition pipeline effect with a single command: ```bash paddleocr seal_recognition -i https://paddle-model-ecology.bj.bcebos.com/paddlex/imgs/demo_image/seal_text_det.png \ --use_doc_orientation_classify False \ --use_doc_unwarping False # Use --device to specify the use of GPU for model inference. paddleocr seal_recognition -i ./seal_text_det.png --device gpu ``` The examples above use the local `paddle_static` inference engine by default. To run them, first install PaddlePaddle by following [PaddlePaddle Framework Installation](../paddlepaddle_installation.en.md). If you choose `transformers` as the inference engine, make sure the Transformers environment is configured by following [Inference Engine and Configuration](../inference_deployment/local_inference/inference_engine.en.md), and then run the following command: ```bash # Use the transformers engine for inference paddleocr seal_recognition -i https://paddle-model-ecology.bj.bcebos.com/paddlex/imgs/demo_image/seal_text_det.png \ --use_doc_orientation_classify False \ --use_doc_unwarping False \ --engine transformers ``` In most scenarios, the default `paddle_static` inference engine delivers better inference performance and is the recommended first choice.
The command line supports more parameter settings. Click to expand for detailed explanations of command line parameters.
Parameter Description Parameter Type Default Value
input Meaning:Data to be predicted, required.
Description: Local path of image or PDF file, e.g., /root/data/img.jpg; URL link, e.g., network URL of image or PDF file: Example; Local directory, the directory should contain images to be predicted, e.g., local path: /root/data/ (currently does not support prediction of PDF files in directories; PDF files must be specified with a specific file path).
str
save_path Meaning:Specify the path to save the inference results file.
Description: If not set, the inference results will not be saved locally.
str
doc_orientation_classify_model_name Meaning:The name of the document orientation classification model.
Description: If not set, the default model in pipeline will be used.
str
doc_orientation_classify_model_dir Meaning:The directory path of the document orientation classification model.
Description: If not set, the official model will be downloaded.
str
doc_unwarping_model_name Meaning:The name of the text image unwarping model.
Description: If not set, the default model in pipeline will be used.
str
doc_unwarping_model_dir Meaning:The directory path of the text image unwarping model.
Description: If not set, the official model will be downloaded.
str
layout_detection_model_name Meaning:The name of the layout detection model.
Description: If not set, the default model in pipeline will be used.
str
layout_detection_model_dir Meaning:The directory path of the layout detection model.
Description: If not set, the official model will be downloaded.
str
seal_text_detection_model_name Meaning:The name of the seal text detection model.
Description: If not set, the pipeline's default model will be used.
str
seal_text_detection_model_dir Meaning:The directory path of the seal text detection model.
Description: If not set, the official model will be downloaded.
str
text_recognition_model_name Meaning:Name of the text recognition model.
Description: If not set, the default pipeline model is used.
str
text_recognition_model_dir Meaning:Directory path of the text recognition model.
Description: If not set, the official model will be downloaded.
str
text_recognition_batch_size Meaning:Batch size for the text recognition model.
Description: If not set, defaults to 1.
int
use_doc_orientation_classify Meaning:Whether to load and use document orientation classification module.
Description: If not set, defaults to pipeline initialization value (True).
bool
use_doc_unwarping Meaning:Whether to load and use text image correction module.
Description: If not set, defaults to pipeline initialization value (True).
bool
use_layout_detection Meaning:Whether to load and use the layout detection module.
Description: If not set, the parameter will be set to the value initialized in the pipeline, which is True by default.
bool
layout_threshold Meaning:Score threshold for the layout model.
Description: Any value between 0-1. If not set, the default value is used, which is 0.5.
float
layout_nms Meaning:Whether to use Non-Maximum Suppression (NMS) as post-processing for layout detection.
Description: If not set, the parameter will be set to the value initialized in the pipeline, which is set to True by default.
bool
layout_unclip_ratio Meaning:Unclip ratio for detected boxes in layout detection model.
Description: Any float > 0. If not set, the default is 1.0.
float
layout_merge_bboxes_mode Meaning:The merging mode for the detection boxes output by the model in layout region detection.
Description:
  • large: When set to "large", only the largest outer bounding box will be retained for overlapping bounding boxes, and the inner overlapping boxes will be removed;
  • small: When set to "small", only the smallest inner bounding boxes will be retained for overlapping bounding boxes, and the outer overlapping boxes will be removed;
  • union: No filtering of bounding boxes will be performed, and both inner and outer boxes will be retained;
If not set, the default is large.
str
seal_det_limit_side_len Meaning:Image side length limit for seal text detection.
Description: Any integer > 0. If not set, the default is 736.
int
seal_det_limit_type Meaning:Limit type for image side in seal text detection.
Description: Supports min and max; min ensures shortest side ≥ det_limit_side_len, max ensures longest side ≤ limit_side_len. If not set, the default is min.
str
seal_det_thresh Meaning:Pixel threshold. Pixels with scores above this value in the probability map are considered text.
Description: Any float > 0. If not set, the default is 0.2.
float
seal_det_box_thresh Meaning:Box threshold. Boxes with average pixel scores above this value are considered text regions.
Description: Any float > 0. If not set, the default is 0.6.
float
seal_det_unclip_ratio Meaning:Expansion ratio for seal text detection. Higher value means larger expansion area.
Description: Any float > 0. If not set, the default is 0.5.
float
seal_rec_score_thresh Meaning:Recognition score threshold. Text results above this value will be kept.
Description: Any float > 0. If not set, the default is 0.0 (no threshold).
float
device Meaning:The device used for inference.
Description: Support for specifying specific card numbers:
  • CPU: For example, cpu indicates using the CPU for inference.
  • GPU: For example, gpu:0 indicates using the first GPU for inference.
  • NPU: For example, npu:0 indicates using the first NPU for inference.
  • XPU: For example, xpu:0 indicates using the first XPU for inference.
  • MLU: For example, mlu:0 indicates using the first MLU for inference.
  • DCU: For example, dcu:0 indicates using the first DCU for inference.
  • MetaX GPU: For example, metax_gpu:0 indicates using the first MetaX GPU for inference.
  • Iluvatar GPU: For example, iluvatar_gpu:0 indicates using the first Iluvatar GPU for inference.
If not set, the pipeline initialized value for this parameter will be used. During initialization, the local GPU device 0 will be preferred; if unavailable, the CPU device will be used.
str
engine Meaning: Inference engine.
Description: Supports None (the default), paddle, paddle_static, paddle_dynamic, and transformers. When left as None, PaddleOCR preserves the behavior of earlier versions, which in most configurations is equivalent to paddle. For detailed descriptions, supported values, compatibility rules, and examples, see Inference Engine and Configuration.
str|None None
enable_hpi Meaning: Whether to enable high-performance inference. bool None
use_tensorrt Meaning: Whether to enable the TensorRT subgraph engine of Paddle Inference.
Description: If the model does not support TensorRT acceleration, acceleration will not be used even if this flag is set.
For CUDA 11.8 versions of PaddlePaddle, the compatible TensorRT version is 8.x (x>=6). TensorRT 8.6.1.6 is recommended.
bool False
precision Meaning: Computation precision, such as fp32 or fp16. str fp32
enable_mkldnn Meaning: Whether to enable MKL-DNN accelerated inference.
Description: If MKL-DNN is unavailable or the model does not support MKL-DNN acceleration, acceleration will not be used even if this flag is set.
bool True
mkldnn_cache_capacity Meaning: MKL-DNN cache capacity. int 10
cpu_threads Meaning: Number of threads used for inference on CPU. int 10
paddlex_config Meaning: Path to the PaddleX pipeline configuration file. str

After running, the results will be printed to the terminal, as follows: ```bash {'res': {'input_path': './seal_text_det.png', 'model_settings': {'use_doc_preprocessor': True, 'use_layout_detection': True}, 'doc_preprocessor_res': {'input_path': None, 'page_index': None, 'model_settings': {'use_doc_orientation_classify': False, 'use_doc_unwarping': False}, 'angle': -1}, 'layout_det_res': {'input_path': None, 'page_index': None, 'boxes': [{'cls_id': 16, 'label': 'seal', 'score': 0.975529670715332, 'coordinate': [6.191284, 0.16680908, 634.39325, 628.85345]}]}, 'seal_res_list': [{'input_path': None, 'page_index': None, 'model_settings': {'use_doc_preprocessor': False, 'use_textline_orientation': False}, 'dt_polys': [array([[320, 38], ..., [315, 38]]), array([[461, 347], ..., [456, 346]]), array([[439, 445], ..., [434, 444]]), array([[158, 468], ..., [154, 466]])], 'text_det_params': {'limit_side_len': 736, 'limit_type': 'min', 'thresh': 0.2, 'max_side_limit': 4000, 'box_thresh': 0.6, 'unclip_ratio': 0.5}, 'text_type': 'seal', 'textline_orientation_angles': array([-1, ..., -1]), 'text_rec_score_thresh': 0, 'rec_texts': ['天津君和缘商贸有限公司', '发票专用章', '吗繁物', '5263647368706'], 'rec_scores': array([0.99340463, ..., 0.9916274 ]), 'rec_polys': [array([[320, 38], ..., [315, 38]]), array([[461, 347], ..., [456, 346]]), array([[439, 445], ..., [434, 444]]), array([[158, 468], ..., [154, 466]])], 'rec_boxes': array([], dtype=float64)}]}} ``` The visualized results are saved under `save_path`, and the visualized result of seal OCR is as follows: ### 2.2 Python Script Integration * The above command line is for quickly experiencing and viewing the effect. Generally, in a project, you often need to integrate through code. You can complete the quick inference of the pipeline with just a few lines of code. The inference code is as follows: ```python from paddleocr import SealRecognition pipeline = SealRecognition( use_doc_orientation_classify=False, # Set whether to use document orientation classification model use_doc_unwarping=False, # Set whether to use document image unwarping module ) # ocr = SealRecognition(device="gpu") # Specify GPU for model inference output = pipeline.predict("./seal_text_det.png") for res in output: res.print() ## Print structured prediction results res.save_to_img("./output/") res.save_to_json("./output/") ``` The example above uses the local `paddle_static` inference engine by default. To run it, first install PaddlePaddle by following [PaddlePaddle Framework Installation](../paddlepaddle_installation.en.md). If you choose `transformers` as the inference engine, make sure the Transformers environment is configured by following [Inference Engine and Configuration](../inference_deployment/local_inference/inference_engine.en.md), and then run the following code: ```python from paddleocr import SealRecognition pipeline = SealRecognition( engine="transformers", ) # ocr = SealRecognition(device="gpu") # Specify GPU for model inference output = pipeline.predict("./seal_text_det.png") for res in output: res.print() ## Print structured prediction results res.save_to_img("./output/") res.save_to_json("./output/") ``` In most scenarios, the default `paddle_static` inference engine delivers better inference performance and is the recommended first choice. In the above Python script, the following steps were executed: (1) Instantiate a pipeline object for seal text recognition using the SealRecognition() class, with specific parameter descriptions as follows:
Parameter Description Type Default Value
doc_orientation_classify_model_name Meaning:Name of the document orientation classification model.
Description: If set to None, the pipeline default model is used.
str|None None
doc_orientation_classify_model_dir Meaning:Directory path of the document orientation classification model.
Description: If set to None, the official model will be downloaded.
str|None None
doc_unwarping_model_name Meaning:Name of the document unwarping model.
Description: If set to None, the pipeline default model is used.
str|None None
doc_unwarping_model_dir Meaning:Directory path of the document unwarping model.
Description: If set to None, the official model will be downloaded.
str|None None
layout_detection_model_name Meaning:Name of the layout detection model.
Description: If set to None, the pipeline default model is used.
str|None None
layout_detection_model_dir Meaning:Directory path of the layout detection model.
Description: If set to None, the official model will be downloaded.
str|None None
seal_text_detection_model_name Meaning:Name of the seal text detection model.
Description: If set to None, the default model will be used.
str
seal_text_detection_model_dir Meaning:Directory of the seal text detection model.
Description: If set to None, the official model will be downloaded.
str
text_recognition_model_name Meaning:Name of the text recognition model.
Description: If set to None, the pipeline default model is used.
str|None None
text_recognition_model_dir Meaning:Directory path of the text recognition model.
Description: If set to None, the official model will be downloaded.
str|None None
text_recognition_batch_size Meaning:Batch size for the text recognition model.
Description: If set to None, the default batch size is 1.
int|None None
use_doc_orientation_classify Meaning:Whether to enable the document orientation classification module.
Description: If set to None, the default value is True.
bool|None None
use_doc_unwarping Meaning:Whether to enable the document image unwarping module.
Description: If set to None, the default value is True.
bool|None None
use_layout_detection Meaning:Whether to load and use the layout detection module.
Description: If set to None, the parameter will be set to the value initialized in the pipeline, which is True by default.
bool|None None
layout_threshold Meaning:Score threshold for the layout model.
Description:
  • float: Any float between 0-1;
  • dict: {0:0.1} where the key is the class ID and the value is the threshold for that class;
  • None: If set to None, uses the pipeline default of 0.5.
float|dict|None None
layout_nms Meaning:Whether to use Non-Maximum Suppression (NMS) as post-processing for layout detection.
Description: If set to None, the parameter will be set to the value initialized in the pipeline, which is set to True by default.
bool|None None
layout_unclip_ratio Meaning:Expansion ratio for the bounding boxes from the layout detection model.
Description:
  • float: Any float greater than 0;
  • Tuple[float,float]: Expansion ratios in horizontal and vertical directions;
  • dict: A dictionary with int keys representing cls_id, and tuple values, e.g., {0: (1.1, 2.0)} means width is expanded 1.1× and height 2.0× for class 0 boxes;
  • None: If set to None, uses the pipeline default of 1.0.
float|Tuple[float,float]|dict|None None
layout_merge_bboxes_mode Meaning:Filtering method for overlapping boxes in layout detection.
Description:
  • str: Options include large, small, and union to retain the larger box, smaller box, or both;
  • dict: A dictionary with int keys representing cls_id, and str values, e.g., {0: "large", 2: "small"} means using different modes for different classes;
  • None: If set to None, uses the pipeline default value large.
str|dict|None None
seal_det_limit_side_len Meaning:Image side length limit for seal text detection.
Description:
  • int: Any integer greater than 0;
  • None: If set to None, the default value is 736.
int|None None
seal_det_limit_type Meaning:Limit type for seal text detection image side length.
Description:
  • str: Supports min and max. min ensures the shortest side is no less than det_limit_side_len, while max ensures the longest side is no greater than limit_side_len;
  • None: If set to None, the default value is min.
str|None None
seal_det_thresh Meaning:Pixel threshold for detection. Pixels with scores greater than this value in the probability map are considered text pixels.
Description:
  • float: Any float greater than 0;
  • None: If set to None, the default value is 0.2.
float|None None
seal_det_box_thresh Meaning:Bounding box threshold. If the average score of all pixels inside a detection box exceeds this threshold, it is considered a text region.
Description:
  • float: Any float greater than 0;
  • None: If set to None, the default value is 0.6.
float|None None
seal_det_unclip_ratio Meaning:Expansion ratio for seal text detection. The larger the value, the larger the expanded area.
Description:
  • float: Any float greater than 0;
  • None: If set to None, the default value is 0.5.
float|None None
seal_rec_score_thresh Meaning:Score threshold for seal text recognition. Text results with scores above this threshold will be retained.
Description:
  • float: Any float greater than 0;
  • None: If set to None, the default value is 0.0 (no threshold).
float|None None
device Meaning:Device used for inference.
Description: Supports specifying device ID:
  • CPU: e.g., cpu means using CPU for inference;
  • GPU: e.g., gpu:0 means using GPU 0;
  • NPU: e.g., npu:0 means using NPU 0;
  • XPU: e.g., xpu:0 means using XPU 0;
  • MLU: e.g., mlu:0 means using MLU 0;
  • DCU: e.g., dcu:0 means using DCU 0;
  • MetaX GPU: e.g., metax_gpu:0 means using MetaX GPU 0;
  • Iluvatar GPU: e.g., iluvatar_gpu:0 means using Iluvatar GPU 0;
  • None: If set to None, the pipeline initialized value for this parameter will be used. During initialization, the local GPU device 0 will be preferred; if unavailable, the CPU device will be used.
str|None None
engine Meaning: Inference engine.
Description: Supports None (the default), paddle, paddle_static, paddle_dynamic, and transformers. When left as None, PaddleOCR preserves the behavior of earlier versions, which in most configurations is equivalent to paddle. For detailed descriptions, supported values, compatibility rules, and examples, see Inference Engine and Configuration.
str|None None
engine_config Meaning: Inference-engine configuration.
Description: Recommended together with engine. For supported fields, compatibility rules, and examples, see Inference Engine and Configuration.
dict|None None
enable_hpi Meaning: Whether to enable high-performance inference. bool None
use_tensorrt Meaning: Whether to enable the TensorRT subgraph engine of Paddle Inference.
Description: If the model does not support TensorRT acceleration, acceleration will not be used even if this flag is set.
For CUDA 11.8 versions of PaddlePaddle, the compatible TensorRT version is 8.x (x>=6). TensorRT 8.6.1.6 is recommended.
bool False
precision Meaning: Computation precision, such as "fp32" or "fp16". str "fp32"
enable_mkldnn Meaning: Whether to enable MKL-DNN accelerated inference.
Description: If MKL-DNN is unavailable or the model does not support MKL-DNN acceleration, acceleration will not be used even if this flag is set.
bool True
mkldnn_cache_capacity Meaning: MKL-DNN cache capacity. int 10
cpu_threads Meaning: Number of threads used for inference on CPU. int 10
paddlex_config Meaning: Path to the PaddleX pipeline configuration file. str|None None
(2) Call the predict() method of the Seal Text Recognition pipeline object for inference prediction. This method will return a generator. Below are the parameters and their descriptions for the predict() method:
Parameter Parameter Description Parameter Type Default Value
input Meaning:Input data to be predicted. Required.
Description: Supports multiple types:
  • Python Var: Image data represented by numpy.ndarray;
  • str: Local path of an image or PDF file, e.g., /root/data/img.jpg; URL link, e.g., the network URL of an image or PDF file: Example; Local directory, containing images to be predicted, e.g., /root/data/ (currently does not support prediction of PDF files in directories; PDF files must be specified with an exact file path);
  • list: Elements of the list must be of the above types, e.g., [numpy.ndarray, numpy.ndarray], [\"/root/data/img1.jpg\", \"/root/data/img2.jpg\"], [\"/root/data1\", \"/root/data2\"].
Python Var|str|list
use_doc_orientation_classify Meaning:Whether to use the document orientation classification module during inference. bool|None None
use_doc_unwarping Meaning:Whether to use the text image correction module during inference. bool|None None
use_layout_detection Meaning:Whether to use the layout detection module during inference. bool|None None
layout_threshold Meaning:Same meaning as the instantiation parameters.
Description: If set to None, the instantiation value is used; otherwise, this parameter takes precedence.
float|dict|None None
layout_nms Meaning:Same meaning as the instantiation parameters.
Description: If set to None, the instantiation value is used; otherwise, this parameter takes precedence.
bool|None None
layout_unclip_ratio Meaning:Same meaning as the instantiation parameters.
Description: If set to None, the instantiation value is used; otherwise, this parameter takes precedence.
float|Tuple[float,float]|dict|None None
layout_merge_bboxes_mode Meaning:Same meaning as the instantiation parameters.
Description: If set to None, the instantiation value is used; otherwise, this parameter takes precedence.
str|dict|None None
seal_det_limit_side_len Same meaning as the instantiation parameters. If set to None, the instantiation value is used; otherwise, this parameter takes precedence. int|None None
seal_det_limit_type Meaning:Same meaning as the instantiation parameters.
Description: If set to None, the instantiation value is used; otherwise, this parameter takes precedence.
str|None None
seal_det_thresh Meaning:Same meaning as the instantiation parameters.
Description: If set to None, the instantiation value is used; otherwise, this parameter takes precedence.
float|None None
seal_det_box_thresh Meaning:Same meaning as the instantiation parameters.
Description: If set to None, the instantiation value is used; otherwise, this parameter takes precedence.
float|None None
seal_det_unclip_ratio Meaning:Same meaning as the instantiation parameters.
Description: If set to None, the instantiation value is used; otherwise, this parameter takes precedence.
float|None None
seal_rec_score_thresh Meaning:Same meaning as the instantiation parameters.
Description: If set to None, the instantiation value is used; otherwise, this parameter takes precedence.
float|None None
(3) Process the prediction results. The prediction result for each sample is of dict type and supports operations such as printing, saving as an image, and saving as a json file:
Method Description Parameter Parameter Type Parameter Description Default Value
print() Print results to the terminal format_json bool Whether to format the output content using JSON indentation. True
indent int Specify the indentation level to beautify the output JSON data for better readability, effective only when format_json is True. 4
ensure_ascii bool Control whether to escape non-ASCII characters to Unicode. When set to True, all non-ASCII characters will be escaped; False will retain the original characters, effective only when format_json is True. False
save_to_json() Save results as a json file save_path str The file path to save the results. When it is a directory, the saved file name will be consistent with the input file type. None
indent int Specify the indentation level to beautify the output JSON data for better readability, effective only when format_json is True. 4
ensure_ascii bool Control whether to escape non-ASCII characters to Unicode. When set to True, all non-ASCII characters will be escaped; False will retain the original characters, effective only when format_json is True. False
save_to_img() Save results as an image file save_path str The file path to save the results, supports directory or file path. None