Table structure recognition is an important component of table recognition systems, capable of converting non-editable table images into editable table formats (such as HTML). The goal of table structure recognition is to identify the positions of rows, columns, and cells in tables. The performance of this module directly affects the accuracy and efficiency of the entire table recognition system. The table structure recognition module usually outputs HTML code for the table area, which is then passed as input to the tabl recognition pipeline for further processing.
Model
Accuracy (%)
GPU Inference Time (ms)
[Normal Mode / High Performance Mode]
CPU Inference Time (ms)
[Normal Mode / High Performance Mode]
Model Storage Size (M)
SLANet
59.52
103.08 / 103.08
197.99 / 197.99
6.9 M
Installation
PaddlePaddle
Please refer to the following commands to install PaddlePaddle using pip:
# for CUDA11.8
python -m pip install paddlepaddle-gpu==3.0.0 -i https://www.paddlepaddle.org.cn/packages/stable/cu118/
# for CUDA12.6
python -m pip install paddlepaddle-gpu==3.0.0 -i https://www.paddlepaddle.org.cn/packages/stable/cu126/
# for CPU
python -m pip install paddlepaddle==3.0.0 -i https://www.paddlepaddle.org.cn/packages/stable/cpu/
You can also integrate the model inference of the table classification module into your project. Before running the following code, please download the sample image to your local machine.
from paddleocr import TableStructureRecognition
model = TableStructureRecognition(model_name="SLANet")
output = model.predict(input="6rfhb-CXOHowonjpBsaUJ.png", batch_size=1)
for res in output:
res.print(json_format=False)
res.save_to_json("./output/res.json")
For details about usage command and descriptions of parameters, please refer to the
Document
.
Pipeline Usage
The ability of a single model is limited. But the pipeline consists of several models can provide more capacity to resolve difficult problems in real-world scenarios.
General Table Recognition V2 Pipeline
The general table recognition V2 pipeline is used to solve table recognition tasks by extracting information from images and outputting it in HTML or Excel format. And there are 8 modules in the pipeline:
If save_path is specified, the visualization results will be saved under
save_path
. The visualization output is shown below:
The command-line method is for quick experience. For project integration, also only a few codes are needed as well:
from paddleocr import TableRecognitionPipelineV2
pipeline = TableRecognitionPipelineV2(
use_doc_orientation_classify=False, # Use use_doc_orientation_classify to enable/disable document orientation classification model
use_doc_unwarping=False, # Use use_doc_unwarping to enable/disable document unwarping module
)
# pipeline = TableRecognitionPipelineV2(use_doc_orientation_classify=True) # Specify whether to use the document orientation classification model with use_doc_orientation_classify# pipeline = TableRecognitionPipelineV2(use_doc_unwarping=True) # Specify whether to use the text image unwarping module with use_doc_unwarping# pipeline = TableRecognitionPipelineV2(device="gpu") # Specify the device to use GPU for model inference
output = pipeline.predict("https://cdn-uploads.huggingface.co/production/uploads/681c1ecd9539bdde5ae1733c/mabagznApI1k9R8qFoTLc.png")
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/")
Then, if you want to use the SLANet model for table recognition, just change the model name and use the end-to-end prediction mode as below:
Results would be printed to the terminal. If save_path is specified, the results will be saved under
save_path
.
Just a few lines of code can experience the inference of the pipeline. Taking the PP-StructureV3 pipeline as an example:
from paddleocr import PPStructureV3
pipeline = PPStructureV3(
wired_table_structure_recognition_model_name=SLANet, ## for wired table recognition
wireless_table_structure_recognition_model_name=SLANet, ## for wireless table recognition
use_doc_orientation_classify=False, # Use use_doc_orientation_classify to enable/disable document orientation classification model
use_doc_unwarping=False, # Use use_doc_unwarping to enable/disable document unwarping module
use_textline_orientation=False, # Use use_textline_orientation to enable/disable textline orientation classification model
device="gpu:0", # Use device to specify GPU for model inference
)
output = pipeline.predict(
"mG4tnwfrvECoFMu-S9mxo.png",
use_e2e_wired_table_rec_model=True, ## for wired table recognition
use_e2e_wireless_table_rec_model=True, ## for wireless table recognition
)
for res in output:
res.print() # Print the structured prediction output
res.save_to_json(save_path="output") ## Save the current image's structured result in JSON format
res.save_to_markdown(save_path="output") ## Save the current image's result in Markdown format
The default model used in pipeline is
SLANeXt_wired
and
SLANeXt_wireless
, so it is needed that specifing to
SLANet
by argument. For details about usage command and descriptions of parameters, please refer to the
Document
.
SLANet huggingface.co is an AI model on huggingface.co that provides SLANet's model effect (), which can be used instantly with this PaddlePaddle SLANet model. huggingface.co supports a free trial of the SLANet model, and also provides paid use of the SLANet. Support call SLANet model through api, including Node.js, Python, http.
SLANet huggingface.co is an online trial and call api platform, which integrates SLANet's modeling effects, including api services, and provides a free online trial of SLANet, you can try SLANet online for free by clicking the link below.
PaddlePaddle SLANet online free url in huggingface.co:
SLANet is an open source model from GitHub that offers a free installation service, and any user can find SLANet on GitHub to install. At the same time, huggingface.co provides the effect of SLANet install, users can directly use SLANet installed effect in huggingface.co for debugging and trial. It also supports api for free installation.