--- comments: true --- # General Table Recognition V2 Pipeline Usage Tutorial ## 1. Introduction to General Table Recognition v2 pipeline Table recognition is a technology that automatically identifies and extracts table content and its structure from documents or images. It is widely used in fields such as data entry, information retrieval, and document analysis. By using computer vision and machine learning algorithms, table recognition can convert complex table information into an editable format, making it easier for users to further process and analyze data. The General Table Recognition v2 pipeline (PP-TableMagic) is designed to tackle table recognition tasks, identifying tables in images and outputting them in HTML format. Unlike the original General Table Recognition pipeline, this version introduces two new modules: table classification and table cell detection. By adopting a multi-model pipeline combining "table classification + table structure recognition + cell detection", it achieves better end-to-end table recognition performance compared to the previous version. Based on this, the General Table Recognition v2 pipeline natively supports targeted model fine-tuning, allowing developers to customize it to varying degrees for satisfactory performance in different application scenarios. Furthermore, the General Table Recognition v2 pipeline also supports end-to-end table structure recognition models (e.g., SLANet, SLANet_plus, etc.) and allows independent configuration for wired and wireless table recognition methods, enabling developers to freely select and combine the best table recognition solutions. This pipeline is applicable in a variety of fields, including general, manufacturing, finance, and transportation. It also provides flexible service deployment options, supporting multiple programming languages on various hardware. Additionally, it offers capabilities for secondary development, allowing you to train and fine-tune your own datasets based on this pipeline, with the trained models seamlessly integrated. The General Table Recognition Pipeline v2 includes the following 8 modules. Each module can be trained and inferred independently and contains multiple models. For detailed information, please click on the corresponding module to view the documentation. - [Table Structure Recognition Module](../module_usage/table_structure_recognition.md) - [Table Classification Module](../module_usage/table_classification.md) - [Table Cell Detection Module](../module_usage/table_cells_detection.md) - [Text Detection Module](../module_usage/text_detection.md) - [Text Recognition Module](../module_usage/text_recognition.md) - [Layout Region Detection Module](../module_usage/layout_detection.md) (optional) - [Document Image Orientation Classification Module](../module_usage/doc_img_orientation_classification.md) (optional) - [Text Image Unwarping Module](../module_usage/text_image_unwarping.md) (optional) In this pipeline, you can choose the models 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.
Table Structure Recognition Module Models:
ModelModel Download Link Accuracy (%) GPU Inference Time (ms)
[Regular Mode / High-Performance Mode]
CPU Inference Time (ms)
[Regular Mode / High-Performance Mode]
Model Storage Size (MB) Description
SLANet Inference Model/Training Model 59.52 23.96 / 21.75 - / 43.12 6.9 SLANet is a table structure recognition model developed by Baidu PaddlePaddle's vision team. This model significantly improves the accuracy and inference speed of table structure recognition by using a CPU-friendly lightweight backbone network PP-LCNet, a high-low feature fusion module CSP-PAN, and a feature decoding module SLA Head that aligns structure and location information.
SLANet_plus Inference Model/Training Model 63.69 23.43 / 22.16 - / 41.80 6.9 SLANet_plus is an enhanced version of the SLANet table structure recognition model developed by Baidu PaddlePaddle's vision team. Compared to SLANet, SLANet_plus significantly improves the recognition capabilities for wireless tables and complex tables, while reducing the model's sensitivity to table positioning accuracy, allowing for accurate recognition even if the table is slightly misaligned.
SLANeXt_wired Inference Model/Training Model 69.65 85.92 / 85.92 - / 501.66 351 The SLANeXt series is a new generation of table structure recognition models developed by Baidu PaddlePaddle's vision team. Compared to SLANet and SLANet_plus, SLANeXt focuses on recognizing table structures and has been trained with dedicated weights for recognizing wired and wireless tables, significantly enhancing recognition capabilities across both types, especially for wired tables.
SLANeXt_wireless Inference Model/Training Model
Table Classification Module Models:
ModelModel Download Link Top1 Acc (%) GPU Inference Time (ms)
[Regular Mode / High-Performance Mode]
CPU Inference Time (ms)
[Regular Mode / High-Performance Mode]
Model Storage Size (MB)
PP-LCNet_x1_0_table_cls Inference Model/Training Model 94.2 2.62 / 0.60 3.17 / 1.14 6.6
Table Cell Detection Module Models:
ModelModel Download Link mAP (%) GPU Inference Time (ms)
[Regular Mode / High-Performance Mode]
CPU Inference Time (ms)
[Regular Mode / High-Performance Mode]
Model Storage Size (MB) Description
RT-DETR-L_wired_table_cell_det Inference Model/Training Model 82.7 33.47 / 27.02 402.55 / 256.56 124 RT-DETR is the first real-time end-to-end object detection model. The Baidu PaddlePaddle vision team based RT-DETR-L as the base model, completing pre-training on a self-built table cell detection dataset, achieving good performance in detecting both wired and wireless table cells.
RT-DETR-L_wireless_table_cell_det Inference Model/Training Model
Text Detection Module Models:
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-OCRv5_server_det Inference Model/Training Model 83.8 89.55 / 70.19 383.15 / 383.15 84.3 PP-OCRv5 server-side text detection model with higher accuracy, suitable for deployment on high-performance servers
PP-OCRv5_mobile_det Inference Model/Training Model 79.0 10.67 / 6.36 57.77 / 28.15 4.7 PP-OCRv5 mobile-side text detection model with higher efficiency, suitable for deployment on edge devices
PP-OCRv4_server_det Inference Model/Training Model 69.2 127.82 / 98.87 585.95 / 489.77 109 PP-OCRv4 server-side text detection model with higher accuracy, suitable for deployment on high-performance servers
PP-OCRv4_mobile_det Inference Model/Training Model 63.8 9.87 / 4.17 56.60 / 20.79 4.7 PP-OCRv4 mobile-side text detection model with higher efficiency, suitable for deployment on edge devices
Text Recognition Module:
ModelModel Download Links Recognition Avg Accuracy(%) GPU Inference Time (ms)
[Normal Mode / High-Performance Mode]
CPU Inference Time (ms)
[Normal Mode / High-Performance Mode]
Model Storage Size (MB) Introduction
PP-OCRv5_server_rec Inference Model/Pretrained Model 86.38 8.46 / 2.36 31.21 / 31.21 81 PP-OCRv5_rec is a next-generation text recognition model. It aims to efficiently and accurately support the recognition of four major languages—Simplified Chinese, Traditional Chinese, English, and Japanese—as well as complex text scenarios such as handwriting, vertical text, pinyin, and rare characters using a single model. While maintaining recognition performance, it balances inference speed and model robustness, providing efficient and accurate technical support for document understanding in various scenarios.
PP-OCRv5_mobile_rec Inference Model/Pretrained Model 81.29 5.43 / 1.46 21.20 / 5.32 16
PP-OCRv4_server_rec_doc Inference Model/Pretrained Model 86.58 8.69 / 2.78 37.93 / 37.93 182 PP-OCRv4_server_rec_doc is trained on a mixed dataset of more Chinese document data and PP-OCR training data, building upon PP-OCRv4_server_rec. It enhances the recognition capabilities for some Traditional Chinese characters, Japanese characters, and special symbols, supporting over 15,000 characters. In addition to improving document-related text recognition, it also enhances general text recognition capabilities.
PP-OCRv4_mobile_rec Inference Model/Pretrained Model 78.74 5.26 / 1.12 17.48 / 3.61 10.5 A lightweight recognition model of PP-OCRv4 with high inference efficiency, suitable for deployment on various hardware devices, including edge devices.
PP-OCRv4_server_rec Inference Model/Pretrained Model 85.19 8.75 / 2.49 36.93 / 36.93 173 The server-side model of PP-OCRv4, offering high inference accuracy and deployable on various servers.
en_PP-OCRv4_mobile_rec Inference Model/Pretrained 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 numeric character recognition.
> ❗ The above section lists the **6 core models** that are primarily supported by the text recognition module. In total, the module supports **20 comprehensive models**, including multiple multilingual text recognition models. Below is the complete list of models:
👉Details of the Model List * PP-OCRv5 Multi-Scenario Models
ModelModel Download Links Avg Accuracy for Chinese Recognition (%) Avg Accuracy for English Recognition (%) Avg Accuracy for Traditional Chinese Recognition (%) Avg Accuracy for Japanese Recognition (%) GPU Inference Time (ms)
[Normal Mode / High-Performance Mode]
CPU Inference Time (ms)
[Normal Mode / High-Performance Mode]
Model Storage Size (MB) Introduction
PP-OCRv5_server_rec Inference Model/Pretrained Model 86.38 64.70 93.29 60.35 8.46 / 2.36 31.21 / 31.21 81 PP-OCRv5_rec is a next-generation text recognition model. It aims to efficiently and accurately support the recognition of four major languages—Simplified Chinese, Traditional Chinese, English, and Japanese—as well as complex text scenarios such as handwriting, vertical text, pinyin, and rare characters using a single model. While maintaining recognition performance, it balances inference speed and model robustness, providing efficient and accurate technical support for document understanding in various scenarios.
PP-OCRv5_mobile_rec Inference Model/Pretrained Model 81.29 66.00 83.55 54.65 5.43 / 1.46 21.20 / 5.32 16
* Chinese Recognition Models
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 based on PP-OCRv4_server_rec, trained with a mix of more Chinese document data and PP-OCR training data, increasing the recognition capabilities for some Traditional Chinese, Japanese, and special characters, supporting recognition of over 15,000 characters. In addition to improving the document-related text recognition capabilities, 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's lightweight recognition model has high inference efficiency and can be deployed on various hardware, including edge devices.
PP-OCRv4_server_rec Inference Model/Training Model 85.19 8.75 / 2.49 36.93 / 36.93 173 PP-OCRv4's server-side model has high inference accuracy and 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's lightweight recognition model has high inference efficiency and can be deployed on various hardware, 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 at Fudan University's Vision and Learning Laboratory (FVL). It won first place in the PaddleOCR Algorithm Model Challenge - Task 1: OCR End-to-End Recognition Task, achieving a 6% improvement in end-to-end recognition accuracy 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 is a mobile text recognition model based on SVTRv2, which won first place in the PaddleOCR Algorithm Model Challenge - Task 1: OCR End-to-End Recognition Task, achieving a 2.5% improvement in end-to-end recognition accuracy compared to PP-OCRv4, while maintaining the same inference speed.
* English Recognition Models
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 This ultra-lightweight English recognition model is trained based on the PP-OCRv4 recognition model, supporting English and digit recognition.
en_PP-OCRv3_mobile_rec Inference Model/Training Model 70.69 3.56 / 0.78 8.44 / 5.78 17.3 This ultra-lightweight English recognition model is trained based on the PP-OCRv3 recognition model, supporting English and digit recognition.
* Multilingual Recognition Models
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 This ultra-lightweight Korean recognition model is trained based on the PP-OCRv3 recognition model, supporting Korean and digit recognition.
japan_PP-OCRv3_mobile_rec Inference Model/Training Model 45.69 3.86 / 1.01 8.62 / 2.92 9.8 This ultra-lightweight Japanese recognition model is trained based on the PP-OCRv3 recognition model, supporting Japanese and digit recognition.
chinese_cht_PP-OCRv3_mobile_rec Inference Model/Training Model 82.06 3.90 / 1.16 9.24 / 3.18 10.8 This ultra-lightweight Traditional Chinese recognition model is trained based on the PP-OCRv3 recognition model, supporting Traditional Chinese and digit recognition.
te_PP-OCRv3_mobile_rec Inference Model/Training Model 95.88 3.59 / 0.81 8.28 / 6.21 85 M This ultra-lightweight Telugu recognition model is trained based on the PP-OCRv3 recognition model, supporting Telugu and digit recognition.
ka_PP-OCRv3_mobile_rec Inference Model/Training Model 96.96 3.49 / 0.89 8.63 / 2.77 17.4 This ultra-lightweight Kannada recognition model is trained based on the PP-OCRv3 recognition model, supporting Kannada and digit recognition.
ta_PP-OCRv3_mobile_rec Inference Model/Training Model 76.83 3.49 / 0.86 8.35 / 3.41 8.7 This ultra-lightweight Tamil recognition model is trained based on the PP-OCRv3 recognition model, supporting Tamil and digit recognition.
latin_PP-OCRv3_mobile_rec Inference Model/Training Model 76.93 3.53 / 0.78 8.50 / 6.83 8.7 This ultra-lightweight Latin recognition model is trained based on the PP-OCRv3 recognition model, supporting Latin and digit recognition.
arabic_PP-OCRv3_mobile_rec Inference Model/Training Model 73.55 3.60 / 0.83 8.44 / 4.69 17.3 This ultra-lightweight Arabic alphabet recognition model is trained based on the PP-OCRv3 recognition model, supporting Arabic letters and digit recognition.
cyrillic_PP-OCRv3_mobile_rec Inference Model/Training Model 94.28 3.56 / 0.79 8.22 / 2.76 8.7 This ultra-lightweight Slavic alphabet recognition model is trained based on the PP-OCRv3 recognition model, supporting Slavic letters and digit recognition.
devanagari_PP-OCRv3_mobile_rec Inference Model/Training Model 96.44 3.60 / 0.78 6.95 / 2.87 8.7 This ultra-lightweight Devanagari alphabet recognition model is trained based on the PP-OCRv3 recognition model, supporting Devanagari letters and digit recognition.
Layout Region Detection Module Models:
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 This higher-precision layout region localization model is trained based on RT-DETR-L on a self-built dataset that includes Chinese and English papers, multi-column magazines, newspapers, PPTs, contracts, books, exam papers, research reports, ancient texts, Japanese documents, and vertical text documents.
PP-DocLayout-L Inference Model/Training Model 90.4 33.59 / 33.59 503.01 / 251.08 123.76 This high-precision layout region localization model is trained based on RT-DETR-L on a self-built dataset that includes 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 This layout region localization model balances accuracy and efficiency, trained based on PicoDet-L on a self-built dataset that includes 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 This highly efficient layout region localization model is trained based on PicoDet-S on a self-built dataset that includes Chinese and English papers, magazines, contracts, books, exam papers, and research reports.
> ❗ The above lists the 4 core models that are key to the layout detection module. The module supports a total of 12 complete models, including multiple pre-defined models for different categories. The complete model list is as follows:
👉 Model List Details * Table Layout Detection Models
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_layout_1x_table Inference Model/Training Model 97.5 9.57 / 6.63 27.66 / 16.75 7.4 This high-efficiency layout region localization model is trained based on PicoDet-1x on a self-built dataset, capable of locating tables as one type of region.
* 3-Class Layout Detection Models, Including Tables, Images, and Stamps
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 This high-efficiency layout region localization model is trained using a self-built dataset of Chinese and English papers, magazines, and research reports based on the lightweight model PicoDet-S.
PicoDet-L_layout_3cls Inference Model/Training Model 89.0 12.80 / 9.57 45.04 / 23.86 22.6 This layout region localization model balances efficiency and accuracy, trained using a self-built dataset of Chinese and English papers, magazines, and research reports based on the model PicoDet-L.
RT-DETR-H_layout_3cls Inference Model/Training Model 95.8 114.80 / 25.65 924.38 / 924.38 470.1 This high-precision layout region localization model is trained using a self-built dataset of Chinese and English papers, magazines, and research reports based on the model RT-DETR-H.
* 5-Class English Document Region Detection Models, Including Text, Titles, Tables, Images, and Lists
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_layout_1x Inference Model/Training Model 97.8 9.62 / 6.75 26.96 / 12.77 7.4 This high-efficiency English document layout region localization model is trained on the PubLayNet dataset.
* 17-Class Region Detection Models, Including 17 Common Layout Categories: Title, Image, Text, Number, Abstract, Content, Chart Title, Formula, Table, Table Title, References, Document Title, Footnote, Header, Algorithm, Footer, and Stamp
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 This high-efficiency layout region localization model is trained using a self-built dataset of Chinese and English papers, magazines, and research reports based on the lightweight model PicoDet-S.
PicoDet-L_layout_17cls Inference Model/Training Model 89.0 12.60 / 10.27 43.70 / 24.42 22.6 This layout region localization model balances efficiency and accuracy, trained using a self-built dataset of Chinese and English papers, magazines, and research reports based on the model PicoDet-L.
RT-DETR-H_layout_17cls Inference Model/Training Model 98.3 115.29 / 101.18 964.75 / 964.75 470.2 This high-precision layout region localization model is trained using a self-built dataset of Chinese and English papers, magazines, and research reports based on the model RT-DETR-H.
Text Image Unwarping Module Models (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 High-precision text image correction model.
Document Image Orientation Classification Module Models (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 Based on PP-LCNet_x1_0, this document image classification model includes four categories: 0 degrees, 90 degrees, 180 degrees, and 270 degrees.
Testing Environment Information:
Mode GPU Configuration CPU Configuration Acceleration Technology Combination
Regular Mode FP32 Precision / No TRT Acceleration FP32 Precision / 8 Threads PaddleInference
High-Performance Mode Optimal combination of prior precision type and acceleration strategy FP32 Precision / 8 Threads Optimal backend (Paddle/OpenVINO/TRT, etc.) selected based on prior knowledge

If you prioritize model accuracy, please choose models with higher accuracy; if you care more about inference speed, please select models with faster inference speeds; if you focus on model storage size, please choose models with smaller storage volumes. ## 2. Quick Start Before using the table structure recognition V2 pipeline locally, please ensure that you have completed the installation of the wheel package according to the [installation guide](../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. After installation, you can experience it locally using the command line or Python integration. 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 A single command allows you to quickly experience the effects of the table_recognition_v2 pipeline: ```bash paddleocr table_recognition_v2 -i https://paddle-model-ecology.bj.bcebos.com/paddlex/imgs/demo_image/table_recognition_v2.jpg # Specify whether to use the document orientation classification model with --use_doc_orientation_classify paddleocr table_recognition_v2 -i ./table_recognition_v2.jpg --use_doc_orientation_classify True # Specify whether to use the text image unwarping module with --use_doc_unwarping paddleocr table_recognition_v2 -i ./table_recognition_v2.jpg --use_doc_unwarping True # Specify the device to use GPU for model inference with --device paddleocr table_recognition_v2 -i ./table_recognition_v2.jpg --device gpu ```
More command line parameters are supported. Click to expand for detailed descriptions of the command line parameters
Parameter Description Type Default Value
input Meaning:Data to be predicted, required.
Description: Local path to image files or PDF files: /root/data/img.jpg; as URL links, such as network URLs for image files or PDF files: example; as local directories, the directory must contain images to be predicted, such as local path: /root/data/ (currently, predictions do not support directories that contain PDF files; the PDF file must be specified to the specific file path).
str
save_path Meaning:Specify the path to save the inference result file.
Description: If not set, the inference result will not be saved locally.
str
layout_detection_model_name Meaning:Name of the layout detection model.
Description: If not set, the default model of the pipeline will be used.
str
layout_detection_model_dir Directory path of the layout detection model. If not set, the official model will be downloaded. str
table_classification_model_name Meaning:Name of the table classification model.
Description: If not set, the default model of the pipeline will be used.
str
table_classification_model_dir Meaning:Directory path of the table classification model.
Description: If not set, the official model will be downloaded.
str
wired_table_structure_recognition_model_name Meaning:Name of the wired table structure recognition model.
Description: If not set, the default model of the pipeline will be used.
str
wired_table_structure_recognition_model_dir Meaning:Directory path of the wired table structure recognition model.
Description: If not set, the official model will be downloaded.
str
wireless_table_structure_recognition_model_name Meaning:Name of the wireless table structure recognition model.
Description: If not set, the default model of the pipeline will be used.
str
wireless_table_structure_recognition_model_dir Meaning:Directory path of the wireless table structure recognition model.
Description: If not set, the official model will be downloaded.
str
wired_table_cells_detection_model_name Meaning:Name of the wired table cell detection model.
Description: If not set, the default model of the pipeline will be used.
str
wired_table_cells_detection_model_dir Meaning:Directory path of the wired table cell detection model.
Description: If not set, the official model will be downloaded.
str
wireless_table_cells_detection_model_name Meaning:Name of the wireless table cell detection model.
Description: If not set, the default model of the pipeline will be used.
str
wireless_table_cells_detection_model_dir Meaning:Directory path of the wireless table cell detection model.
Description: If not set, the official model will be downloaded.
str
doc_orientation_classify_model_name Meaning:Name of the document orientation classification model.
Description: If not set, the default model of the pipeline will be used.
str
doc_orientation_classify_model_dir Meaning:Directory path of the document orientation classification model.
Description: If not set, the official model will be downloaded.
str
doc_unwarping_model_name Meaning:Name of the text image unwarping model.
Description: If not set, the default model of the pipeline will be used.
str
doc_unwarping_model_dir Meaning:Directory path of the text image unwarping model.
Description: If not set, the official model will be downloaded.
str
text_detection_model_name Meaning:Name of the text detection model.
Description: If not set, the default model of the pipeline will be used.
str
text_detection_model_dir Meaning:Directory path of the text detection model.
Description: If not set, the official model will be downloaded.
str
text_det_limit_side_len Meaning:Image side length limit for text detection.
Description: Any integer greater than 0. If not set, the value initialized by the pipeline will be used, which defaults to 960.
int
text_det_limit_type Meaning:Type of the image side length limit for text detection.
Description: Supports min and max. min ensures that the shortest side of the image is not less than det_limit_side_len, while max ensures that the longest side of the image is not greater than limit_side_len. If not set, the value initialized by the pipeline will be used, which defaults to max.
str
text_det_thresh Meaning:Detection pixel threshold. In the output probability map, only pixels with a score greater than this threshold will be considered text pixels.
Description: Any floating-point number greater than 0. If not set, the value initialized by the pipeline will be used, which defaults to 0.3.
float
text_det_box_thresh Meaning:Detection box threshold. When the average score of all pixels within the detection result box is greater than this threshold, the result is considered a text area.
Description: Any floating-point number greater than 0. If not set, the value initialized by the pipeline will be used, which defaults to 0.6.
float
text_det_unclip_ratio Meaning:Text detection expansion coefficient. This method expands the text area; the larger this value, the larger the expanded area.
Description: Any floating-point number greater than 0. If not set, the value initialized by the pipeline will be used, which defaults to 2.0.
float
text_recognition_model_name Meaning:Name of the text recognition model.
Description: If not set, the default model of the pipeline will be 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, the default batch size will be set to 1.
int
text_rec_score_thresh Meaning:Text recognition threshold. Text results with a score greater than this threshold will be retained.
Description: Any floating-point number greater than 0. If not set, the value initialized by the pipeline will be used, which defaults to 0.0. That is, no threshold is set.
float
use_doc_orientation_classify Meaning:Whether to load and use the document orientation classification module.
Description: If not set, the value initialized by the pipeline will be used, which defaults to True.
bool
use_doc_unwarping Meaning:Whether to load and use the text image unwarping module.
Description: If not set, the value initialized by the pipeline will be used, which defaults to True.
bool
use_layout_detection Meaning:Whether to load and use the layout detection module.
Description: If not set, the value initialized by the pipeline will be used, which defaults to True.
bool
use_ocr_model Meaning:Whether to load and use the OCR module.
Description: If not set, the value initialized by the pipeline will be used, which defaults to True.
bool
device Meaning:The device used for inference.
Description: Supports specifying a specific card number:
  • CPU: For example, cpu indicates using 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
enable_hpi Meaning:Whether to enable high-performance inference. bool False
use_tensorrt Meaning:Whether to use the Paddle Inference TensorRT subgraph engine.
Description: If the model does not support acceleration through TensorRT, setting this flag will not enable acceleration.
For Paddle with CUDA version 11.8, the compatible TensorRT version is 8.x (x>=6), and it is recommended to install TensorRT 8.6.1.6.
bool False
precision Meaning:Computation precision, such as fp32, fp16. str fp32
enable_mkldnn Meaning:Whether to enable MKL-DNN acceleration for inference.
Description: If MKL-DNN is unavailable or the model does not support it, 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 to use for inference on the CPU. int 8
paddlex_config Meaning:Path to PaddleX pipeline configuration file. str

To run inference on the [example image](https://paddle-model-ecology.bj.bcebos.com/paddlex/imgs/demo_image/table_recognition_v2.jpg), you can use the following command: ```bash paddleocr table_recognition_v2 -i ./table_recognition_v2.jpg --use_doc_orientation_classify False --use_doc_unwarping False ``` The running results will be printed to the terminal. The default configuration of the table_recognition_v2 pipeline's running results is as follows: ``` {'res': {'input_path': 'table_recognition_v2.jpg', 'page_index': None, 'model_settings': {'use_doc_preprocessor': False, 'use_layout_detection': True, 'use_ocr_model': True}, 'layout_det_res': {'input_path': None, 'page_index': None, 'boxes': [{'cls_id': 8, 'label': 'table', 'score': 0.86655592918396, 'coordinate': [0.0125130415, 0.41920784, 1281.3737, 585.3884]}]}, 'overall_ocr_res': {'input_path': None, 'page_index': None, 'model_settings': {'use_doc_preprocessor': False, 'use_textline_orientation': False}, 'dt_polys': array([[[ 9, 21], ..., [ 9, 59]], ..., [[1046, 536], ..., [1046, 573]]], dtype=int16), 'text_det_params': {'limit_side_len': 960, 'limit_type': 'max', 'thresh': 0.3, 'box_thresh': 0.6, 'unclip_ratio': 2.0}, 'text_type': 'general', 'textline_orientation_angles': array([-1, ..., -1]), 'text_rec_score_thresh': 0, 'rec_texts': ['部门', '报销人', '报销事由', '批准人:', '单据', '张', '合计金额', '元', '车费票', '其', '火车费票', '飞机票', '中', '旅住宿费', '其他', '补贴'], 'rec_scores': array([0.99958128, ..., 0.99317062]), 'rec_polys': array([[[ 9, 21], ..., [ 9, 59]], ..., [[1046, 536], ..., [1046, 573]]], dtype=int16), 'rec_boxes': array([[ 9, ..., 59], ..., [1046, ..., 573]], dtype=int16)}, 'table_res_list': [{'cell_box_list': [array([ 0.13052222, ..., 73.08310249]), array([104.43082511, ..., 73.27777413]), array([319.39041221, ..., 73.30439308]), array([424.2436837 , ..., 73.44736794]), array([580.75836265, ..., 73.24003914]), array([723.04370201, ..., 73.22717598]), array([984.67315757, ..., 73.20420387]), array([1.25130415e-02, ..., 5.85419208e+02]), array([984.37072837, ..., 137.02281502]), array([984.26586998, ..., 201.22290352]), array([984.24017417, ..., 585.30775765]), array([1039.90606773, ..., 265.44664314]), array([1039.69549644, ..., 329.30540779]), array([1039.66546714, ..., 393.57319954]), array([1039.5122689 , ..., 457.74644783]), array([1039.55535972, ..., 521.73030403]), array([1039.58612144, ..., 585.09468392])], 'pred_html': '
部门报销人报销事由批准人:
单据 张
合计金额 元
其 中车费票
火车费票
飞机票
旅住宿费
其他
补贴
', 'table_ocr_pred': {'rec_polys': array([[[ 9, 21], ..., [ 9, 59]], ..., [[1046, 536], ..., [1046, 573]]], dtype=int16), 'rec_texts': ['部门', '报销人', '报销事由', '批准人:', '单据', '张', '合计金额', '元', '车费票', '其', '火车费票', '飞机票', '中', '旅住宿费', '其他', '补贴'], 'rec_scores': array([0.99958128, ..., 0.99317062]), 'rec_boxes': array([[ 9, ..., 59], ..., [1046, ..., 573]], dtype=int16)}}]}} ``` The visualization results are saved under save_path, and the visualization results are as follows: ### 2.2 Python Script Integration The command line method is designed for quick experience and viewing effects. Generally, in a project, it is often necessary to integrate through code. You can complete quick inference of the pipeline with just a few lines of code. The inference code is as follows: ```python from paddleocr import TableRecognitionPipelineV2 pipeline = TableRecognitionPipelineV2() # ocr = TableRecognitionPipelineV2(use_doc_orientation_classify=True) # Specify whether to use the document orientation classification model with use_doc_orientation_classify # ocr = TableRecognitionPipelineV2(use_doc_unwarping=True) # Specify whether to use the text image unwarping module with use_doc_unwarping # ocr = TableRecognitionPipelineV2(device="gpu") # Specify the device to use GPU for model inference output = pipeline.predict("./table_recognition_v2.jpg") for res in output: res.print() ## Print the predicted structured output res.save_to_img("./output/") res.save_to_xlsx("./output/") res.save_to_html("./output/") res.save_to_json("./output/") ``` In the above Python script, the following steps are performed: (1) Instantiate the general table recognition V2 pipeline object using TableRecognitionPipelineV2(). The specific parameter descriptions are as follows:
Parameter Description Type Default Value
layout_detection_model_name Meaning:Name of the layout detection model.
Description: If set to None, the default model of the pipeline will be 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
table_classification_model_name Meaning:Name of the table classification model.
Description: If set to None, the default model of the pipeline will be used.
str|None None
table_classification_model_dir Meaning:Directory path of the table classification model.
Description: If set to None, the official model will be downloaded.
str|None None
wired_table_structure_recognition_model_name Meaning:Name of the wired table structure recognition model.
Description: If set to None, the default model of the pipeline will be used.
str|None None
wired_table_structure_recognition_model_dir Meaning:Directory path of the wired table structure recognition model.
Description: If set to None, the official model will be downloaded.
str|None None
wireless_table_structure_recognition_model_name Meaning:Name of the wireless table structure recognition model.
Description: If set to None, the default model of the pipeline will be used.
str|None None
wireless_table_structure_recognition_model_dir Meaning:Directory path of the wireless table structure recognition model.
Description: If set to None, the official model will be downloaded.
str|None None
wired_table_cells_detection_model_name Name of the wired table cell detection model. Meaning:Name of the wired table cell detection model.
Description: If set to None, the default model of the pipeline will be used.
str|None None
wired_table_cells_detection_model_dir Directory path of the wired table cell detection model. Meaning:Directory path of the wired table cell detection model.
Description: If set to None, the official model will be downloaded.
str|None None
wireless_table_cells_detection_model_name Name of the wireless table cell detection model. Meaning:Name of the wireless table cell detection model.
Description: If set to None, the default model of the pipeline will be used.
str|None None
wireless_table_cells_detection_model_dir Directory path of the wireless table cell detection model. Meaning:Directory path of the wireless table cell detection model.
Description: If set to None, the official model will be downloaded.
str|None None
doc_orientation_classify_model_name Name of the document orientation classification model. Meaning:Name of the document orientation classification model.
Description: If set to None, the default model of the pipeline will be used.
str|None None
doc_orientation_classify_model_dir Directory path of the document orientation classification model. 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 Name of the text image unwarping model. Meaning:Name of the text image unwarping model.
Description: If set to None, the default model of the pipeline will be used.
str|None None
doc_unwarping_model_dir Directory path of the text image unwarping model. Meaning:Directory path of the text image unwarping model.
Description: If set to None, the official model will be downloaded.
str|None None
text_detection_model_name Name of the text detection model. Meaning:Name of the text detection model.
Description: If set to None, the default model of the pipeline will be used.
str|None None
text_detection_model_dir Directory path of the text detection model. Meaning:Directory path of the text detection model.
Description: If set to None, the official model will be downloaded.
str|None None
text_det_limit_side_len Meaning:Image side length limit for text detection.
Description:
  • int: Any integer greater than 0;
  • None: If set to None, the value initialized by the pipeline will be used, which defaults to 960.
int|None None
text_det_limit_type Meaning:Type of the image side length limit for text detection.
Description:
  • str: Supports min and max. min ensures that the shortest side of the image is not less than det_limit_side_len, while max ensures that the longest side of the image is not greater than limit_side_len;
  • None: If set to None, the value initialized by the pipeline will be used, which defaults to max.
str|None None
text_det_thresh Meaning:Detection pixel threshold. In the output probability map, only pixels with a score greater than this threshold will be considered text pixels.
Description:
  • float: Any floating-point number greater than 0;
  • None: If set to None, the value initialized by the pipeline will be used, which defaults to 0.3.
float|None None
text_det_box_thresh Meaning:Detection box threshold. When the average score of all pixels within the detection result box is greater than this threshold, the result is considered a text area.
Description:
  • float: Any floating-point number greater than 0;
  • None: If set to None, the value initialized by the pipeline will be used, which defaults to 0.6.
float|None None
text_det_unclip_ratio Meaning:Text detection expansion coefficient. This method expands the text area; the larger this value, the larger the expanded area.
Description:
  • float: Any floating-point number greater than 0;
  • None: If set to None, the value initialized by the pipeline will be used, which defaults to 2.0.
float|None None
text_recognition_model_name Meaning:Name of the text recognition model.
Description: If set to None, the default model of the pipeline will be used.
str|None None
text_recognition_model_dir Directory path of the text recognition model. 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 Batch size for the text recognition model. Meaning:Batch size for the text recognition model.
Description: If set to None, the default batch size will be set to 1.
int|None None
text_rec_score_thresh Meaning:Text recognition threshold. Text results with a score greater than this threshold will be retained.
Description:
  • float: Any floating-point number greater than 0;
  • None: If set to None, the value initialized by the pipeline will be used, which defaults to 0.0. That is, no threshold is set.
float|None None
use_doc_orientation_classify Meaning:Whether to load and use the document orientation classification module.
Description: If set to None, the value initialized by the pipeline will be used, which defaults to True.
bool|None None
use_doc_unwarping Whether to load and use the text image unwarping module. Meaning:Whether to load and use the text image unwarping module.
Description: If set to None, the value initialized by the pipeline will be used, which defaults to True.
bool|None None
use_layout_detection Whether to load and use the layout detection module. Meaning:Whether to load and use the layout detection module.
Description: If set to None, the value initialized by the pipeline will be used, which defaults to True.
bool|None None
use_ocr_model Whether to load and use the OCR module. Meaning:Whether to load and use the OCR module.
Description: If set to None, the value initialized by the pipeline will be used, which defaults to True.
bool|None None
device Meaning:The device used for inference.
Description: Supports specifying a specific card number:
  • CPU: For example, cpu indicates using 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;
  • 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
enable_hpi Meaning:Whether to enable high-performance inference. bool False
use_tensorrt Meaning:Whether to use the Paddle Inference TensorRT subgraph engine. If the model does not support acceleration through TensorRT, setting this flag will not enable acceleration.
Description: For Paddle with CUDA version 11.8, the compatible TensorRT version is 8.x (x>=6), and it is recommended to install TensorRT 8.6.1.6.
bool False
precision Meaning:Computation precision, such as fp32, fp16. str "fp32"
enable_mkldnn Meaning:Whether to enable MKL-DNN acceleration for inference.
Description: If MKL-DNN is unavailable or the model does not support it, 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 to use for inference on the CPU. int 8
paddlex_config Meaning:Path to PaddleX pipeline configuration file. str|None None
(2) Call the predict() method of the general table recognition V2 pipeline object to perform inference prediction, which returns a result list. Additionally, the pipeline also provides the predict_iter() method. Both methods accept the same parameters and return results in the same way; the difference is that predict_iter() returns a generator, allowing for gradual processing and retrieval of prediction results, suitable for handling large datasets or for scenarios where memory savings are desired. You can choose to use either method based on your actual needs. The parameters and descriptions of the predict() method are as follows:
Parameter Description Type Default Value
input Meaning:Data to be predicted, supports multiple input types, required.
Description:
  • Python Var: For example, image data represented as numpy.ndarray;
  • str: Local path to image files or PDF files: /root/data/img.jpg; as URL links, such as network URLs for image files or PDF files: example; as local directories, the directory must contain images to be predicted, such as local path: /root/data/ (currently, predictions do not support directories that contain PDF files; the PDF file must be specified to the specific file path);
  • list: The elements of the list must be of the above types, such as [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 unwarping module during inference. bool|None None
use_layout_detection Meaning:Whether to use the layout detection module during inference. bool|None None
use_ocr_model Meaning:Whether to use the ocr model during inference. bool|None None
text_det_limit_side_len Meaning:Same meaning as the instantiation parameters.
Description: If set to None, the instantiation value is used; otherwise, this parameter takes precedence.
int|None None
text_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
text_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
text_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
text_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
text_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
use_e2e_wired_table_rec_model Meaning:Whether to use the wired end-to-end table recognition mode during inference. bool False
use_e2e_wireless_table_rec_model Meaning:Whether to use the wireless end-to-end table recognition mode during inference. bool False
use_wired_table_cells_trans_to_html Meaning:Whether to use the wired table cell detection result direct-to-HTML mode during inference.
Description: If enabled, it directly constructs the HTML based on the geometric relationships of the wired table cell detection results.
bool False
use_wireless_table_cells_trans_to_html Meaning:Whether to use the wireless table cell detection result direct-to-HTML mode during inference.
Description: If enabled, it directly constructs the HTML based on the geometric relationships of the wireless table cell detection results.
bool False
use_table_orientation_classify Meaning:Whether to use the table orientation classification mode during inference.
Description: If enabled, it can correct the direction and correctly complete table recognition when the table in the image has 90/180/270-degree rotation.
bool True
use_ocr_results_with_table_cells Meaning:Whether to use the cell-split OCR mode during inference.
Description: If enabled, it will split and re-recognize OCR detection results based on the cell prediction results to avoid missing text.
bool True
(3) Process the prediction results. The prediction result for each sample is a corresponding Result object, which supports printing, saving as an image, saving as an xlsx file, saving as an HTML file, and saving as a json file:
Method Description 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, making it more readable. 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 keeps the original characters. Effective only when format_json is True. False
save_to_json() Save results as a json format file save_path str The path to save the file. When it is a directory, the saved file will be named the same as the input file type. None
indent int Specify the indentation level to beautify the output JSON data, making it more readable. 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 keeps the original characters. Effective only when format_json is True. False
save_to_img() Save results as an image format file save_path str The path to save the file, supporting directory or file path. None
save_to_xlsx() Save results as an xlsx format file save_path str The path to save the file, supporting directory or file path. None
save_to_html() Save results as an html format file save_path str The path to save the file, supporting directory or file path. None