--- comments: true --- # Table Cell Detection Module Usage Guide ## I. Overview The table cell detection module is a key component of table recognition tasks, responsible for locating and marking each cell area in table images. The performance of this module directly affects the accuracy and efficiency of the entire table recognition process. The table cell detection module typically outputs bounding boxes for each cell area, which will be passed as input to the table recognition pipeline for subsequent processing. ## II. List of Supported Models
| Model | Model Download Link | mAP(%) | GPU Inference Time (ms) [Normal Mode / High-Performance Mode] |
CPU Inference Time (ms) [Normal Mode / High-Performance Mode] |
Model Storage Size (M) | Introduction |
|---|---|---|---|---|---|---|
| RT-DETR-L_wired_table_cell_det | Inference Model/Training Model | 82.7 | 35.00 / 10.45 | 495.51 / 495.51 | 124M | RT-DETR is the first real-time end-to-end object detection model. The Baidu PaddlePaddle Vision Team, based on RT-DETR-L as the base model, has completed pretraining on a self-built table cell detection dataset, achieving good performance for both wired and wireless table cell detection. |
| RT-DETR-L_wireless_table_cell_det | Inference Model/Training Model |
| Mode | GPU Configuration | CPU Configuration | Acceleration Technology Combination |
|---|---|---|---|
| Normal Mode | FP32 Precision / No TRT Acceleration | FP32 Precision / 8 Threads | PaddleInference |
| High-Performance Mode | Optimal combination of pre-selected precision types and acceleration strategies | FP32 Precision / 8 Threads | Pre-selected optimal backend (Paddle/OpenVINO/TRT, etc.) |
[xmin, ymin, xmax, ymax]
The visualized image is as follows:
| Parameter | Description | Type | Options | Default Value |
|---|---|---|---|---|
model_name |
Name of the model | str |
None | None |
model_dir |
Path to store the model | str |
None | None |
device |
The device used for model inference | str |
It supports specifying specific GPU card numbers, such as "gpu:0", other hardware card numbers, such as "npu:0", or CPU, such as "cpu". | gpu:0 |
use_hpip |
Whether to enable high-performance inference. | bool |
None | False |
img_size |
Size of the input image; if not specified, the default configuration of the PaddleX official model will be used | int/list |
|
None |
threshold |
Threshold to filter out low-confidence predictions; if not specified, the default configuration of the PaddleX official model will be used. In table cell detection tasks, lowering the threshold appropriately may help to obtain more accurate results. | float/dict |
|
None |
| Parameter | Parameter Description | Parameter Type | Optional | Default Value |
|---|---|---|---|---|
input |
Data to be predicted, supporting multiple input types | Python Var/str/list |
|
None |
batch_size |
Batch size | int |
Any integer | 1 |
threshold |
Threshold for filtering out low-confidence prediction results; if not specified, the threshold parameter specified in creat_model will be used by default, and if creat_model also does not specify it, the default PaddleX official model configuration will be used |
float/dict |
|
None |
| Method | Method Description | Parameter | Parameter Type | Parameter Description | Default Value |
|---|---|---|---|---|---|
print() |
Print the result 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, only effective 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 retains the original characters, only effective when format_json is True |
False |
||
save_to_json() |
Save the result as a JSON file | save_path |
str |
The file path to save to, and when it is a directory, the saved file name is consistent with the input file name | None |
indent |
int |
Specify the indentation level to beautify the output JSON data, making it more readable, only effective 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 retains the original characters, only effective when format_json is True |
False |
||
save_to_img() |
Save the result as an image file | save_path |
str |
The file path to save to, and when it is a directory, the saved file name is consistent with the input file name | None |
| Property | Property Description |
|---|---|
json |
Get the prediction result in json format |
img |
Get the visualization image in dict format |
The specific content of the verification result file is as follows:
```json "done_flag": true, "check_pass": true, "attributes": { "num_classes": 1, "train_samples": 230, "train_sample_paths": [ "check_dataset\/demo_img\/img_45_2.png", "check_dataset\/demo_img\/img_69_1.png", "check_dataset\/demo_img\/img_99_1.png", "check_dataset\/demo_img\/img_6_1.png", "check_dataset\/demo_img\/img_47_3.png", "check_dataset\/demo_img\/img_54_2.png", "check_dataset\/demo_img\/img_25_1.png", "check_dataset\/demo_img\/img_73_1.png", "check_dataset\/demo_img\/img_51_2.png", "check_dataset\/demo_img\/img_93_3.png" ], "val_samples": 26, "val_sample_paths": [ "check_dataset\/demo_img\/img_88_2.png", "check_dataset\/demo_img\/img_156_0.png", "check_dataset\/demo_img\/img_43_4.png", "check_dataset\/demo_img\/img_2_4.png", "check_dataset\/demo_img\/img_42_4.png", "check_dataset\/demo_img\/img_49_0.png", "check_dataset\/demo_img\/img_45_1.png", "check_dataset\/demo_img\/img_140_0.png", "check_dataset\/demo_img\/img_5_1.png", "check_dataset\/demo_img\/img_26_3.png" ] }, "analysis": { "histogram": "check_dataset\/histogram.png" }, "dataset_path": "cells_det_coco_examples", "show_type": "image", "dataset_type": "COCODetDataset" ```In the above verification results, check_pass being true indicates that the dataset format meets the requirements. The explanations for other metrics are as follows:
attributes.num_classes: The number of classes in this dataset is 1;attributes.train_samples: The number of training samples in this dataset is 230;attributes.val_samples: The number of validation samples in this dataset is 26;attributes.train_sample_paths: A list of relative paths to the visualization images of the training samples in this dataset;attributes.val_sample_paths: A list of relative paths to the visualization images of the validation samples in this dataset;In addition, the dataset verification has analyzed the distribution of sample counts for all classes in the dataset and plotted a histogram (histogram.png):

(1) Dataset Format Conversion
Table cell detection supports converting datasets in VOC and LabelMe formats to the COCO format.
Parameters related to dataset verification can be set by modifying the fields under CheckDataset in the configuration file. Some example explanations of parameters in the configuration file are as follows:
CheckDataset:convert:enable: Whether to perform dataset format conversion. Table cell detection supports converting datasets in VOC and LabelMe formats to the COCO format. The default is False;src_dataset_type: If performing dataset format conversion, the source dataset format must be set. The default is null, and the available options are VOC, LabelMe, VOCWithUnlabeled, and LabelMeWithUnlabeled. For example, if you want to convert a dataset in LabelMe format to COCO format, using the following LabelMe dataset as an example, you need to modify the configuration as follows:cd /path/to/paddlex
wget https://paddle-model-ecology.bj.bcebos.com/paddlex/data/det_labelme_examples.tar -P ./dataset
tar -xf ./dataset/det_labelme_examples.tar -C ./dataset/
......
CheckDataset:
......
convert:
enable: True
src_dataset_type: LabelMe
......
Then execute the command:
python main.py -c paddlex/configs/modules/table_cells_detection/RT-DETR-L_wired_table_cell_det.yaml \
-o Global.mode=check_dataset \
-o Global.dataset_dir=./dataset/det_labelme_examples
Of course, the above parameters can also be set by adding command-line arguments. For example, for a dataset in LabelMe format:
python main.py -c paddlex/configs/modules/table_cells_detection/RT-DETR-L_wired_table_cell_det.yaml \
-o Global.mode=check_dataset \
-o Global.dataset_dir=./dataset/det_labelme_examples \
-o CheckDataset.convert.enable=True \
-o CheckDataset.convert.src_dataset_type=LabelMe
(2) Dataset Splitting
Parameters for dataset splitting can be set by modifying the fields under CheckDataset in the configuration file. Some example explanations of parameters in the configuration file are as follows:
CheckDataset:split:enable: Whether to re-split the dataset. It is set to True when performing dataset format conversion. The default is False;train_percent: If re-splitting the dataset, you need to set the percentage of the training set. It is an integer between 0 and 100, and it must sum up to 100 with the value of val_percent;val_percent: If re-splitting the dataset, you need to set the percentage of the validation set. It is an integer between 0 and 100, and it must sum up to 100 with the value of train_percent. For example, if you want to re-split the dataset with 90% for training and 10% for validation, you need to modify the configuration file as follows:......
CheckDataset:
......
split:
enable: True
train_percent: 90
val_percent: 10
......
Then execute the command:
python main.py -c paddlex/configs/modules/table_cells_detection/RT-DETR-L_wired_table_cell_det.yaml \
-o Global.mode=check_dataset \
-o Global.dataset_dir=./dataset/cells_det_coco_examples
After the dataset splitting is executed, the original annotation files will be renamed to xxx.bak in the original path.
The above parameters can also be set by adding command-line arguments:
python main.py -c paddlex/configs/modules/table_cells_detection/RT-DETR-L_wired_table_cell_det.yaml \
-o Global.mode=check_dataset \
-o Global.dataset_dir=./dataset/cells_det_coco_examples \
-o CheckDataset.split.enable=True \
-o CheckDataset.split.train_percent=90 \
-o CheckDataset.split.val_percent=10
output. If you need to specify a different save path, you can set it through the -o Global.output field in the configuration file.After model training is completed, all outputs are saved in the specified output directory (default is ./output/), and typically include the following:
train_result.json: The training result record file, which logs whether the training task was completed normally, as well as the metrics of the generated weights and related file paths;
train.log: The training log file, which records changes in model metrics and loss during the training process;config.yaml: The training configuration file, which logs the hyperparameter settings for this training session;.pdparams, .pdema, .pdopt.pdstate, .pdiparams, .pdmodel: These are model weight-related files, including network parameters, optimizer, EMA, static graph network parameters, and static graph network structure, etc.When evaluating the model, the path to the model weights file needs to be specified. Each configuration file has a default weight save path built-in. If you need to change it, you can simply set it by appending a command-line parameter, such as -o Evaluate.weight_path=./output/best_model/best_model.pdparams.
After the model evaluation is completed, an evaluate_result.json file will be generated, which records the evaluation results. Specifically, it records whether the evaluation task was completed normally and the model's evaluation metrics, including AP.