---
comments: true
---
# Table Cell Detection Module Usage Tutorial
## I. Overview
The Table Cell Detection Module is a key component of the table recognition task, responsible for locating and marking each cell region 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 region, which are then passed as input to the table recognition pipeline for further processing.
## II. Supported Model List
Parameter |
Description |
Type |
Options |
Default Value |
model_name |
Model Name |
str |
None |
None |
model_dir |
Model Storage Path |
str |
None |
None |
device |
Model Inference Device |
str |
Supports specifying specific GPU card numbers, such as “gpu:0”, specific hardware card numbers, such as “npu:0”, CPU as “cpu”. |
gpu:0 |
use_hpip |
Whether to enable high-performance inference plugin |
bool |
None |
False |
hpi_config |
High-Performance Inference Configuration |
dict | None |
None |
None |
img_size |
Input image size; if not specified, the PaddleX official model configuration will be used by default |
int/list |
- int, e.g., 640, indicates resizing the input image to 640x640
- list, e.g., [640, 512], indicates resizing the input image to a width of 640 and a height of 512
|
None |
threshold |
Threshold for filtering out low-confidence prediction results; if not specified, the PaddleX official model configuration will be used by default. In table cell detection tasks, appropriately lowering the threshold may help achieve more accurate results |
float/dict |
- float, e.g., 0.2, indicates filtering out all bounding boxes with confidence lower than 0.2
- dictionary, where the key is of type int representing
cls_id , and the value is of type float representing the threshold. For example, {0: 0.45, 2: 0.48, 7: 0.4} applies a threshold of 0.45 for category cls_id 0, 0.48 for category cls_id 1, and 0.4 for category cls_id 7
|
None |
* Among them, `model_name` must be specified. After specifying `model_name`, the default model parameters built into PaddleX are used. When `model_dir` is specified, the user-defined model is used.
* Call the `predict()` method of the table cell detection model for inference prediction. This method will return a result list. Additionally, this module also provides a `predict_iter()` method. Both methods are consistent in terms of parameter acceptance and result return. The difference is that `predict_iter()` returns a `generator`, which can process and obtain prediction results step by step, suitable for handling large datasets or scenarios where memory saving is desired. You can choose to use either of these methods according to your actual needs. The `predict()` method has parameters `input`, `batch_size`, and `threshold`, with specific explanations as follows:
Parameter |
Description |
Type |
Options |
Default Value |
input |
Data to be predicted, supports multiple input types |
Python Var /str /list |
- Python Variable, such as
numpy.ndarray representing image data
- File Path, such as the local path of an image file:
/root/data/img.jpg
- URL Link, such as the network URL of an image file: Example
- Local Directory, which should contain data files to be predicted, such as the local path:
/root/data/
- List, where list elements must be of the above types, such as
[numpy.ndarray, numpy.ndarray] , ["/root/data/img1.jpg", "/root/data/img2.jpg"] , ["/root/data1", "/root/data2"]
|
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 create_model will be used by default, and if create_model is not specified, the PaddleX official model configuration will be used |
float/dict |
- float, e.g., 0.2, indicates filtering out all bounding boxes with confidence lower than 0.2
- dictionary, where the key is of type int representing
cls_id , and the value is of type float representing the threshold. For example, {0: 0.45, 2: 0.48, 7: 0.4} applies a threshold of 0.45 for category cls_id 0, 0.48 for category cls_id 1, and 0.4 for category cls_id 7
|
None |
* Process the prediction results. The prediction result for each sample is a corresponding Result object, which supports printing, saving as an image, and saving as a `json` file:
Method |
Description |
Parameter |
Type |
Parameter Description |
Default Value |
print() |
Print result to terminal |
format_json |
bool |
Whether to format the output content using JSON indentation |
True |
indent |
int |
Specifies the indentation level to beautify the output JSON data, making it more readable, effective only when format_json is True |
4 |
ensure_ascii |
bool |
Controls whether to escape non-ASCII characters into 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 the result as a json format file |
save_path |
str |
The path to save the file. When specified as a directory, the saved file is named consistent with the input file type. |
None |
indent |
int |
Specifies the indentation level to beautify the output JSON data, making it more readable, effective only when format_json is True |
4 |
ensure_ascii |
bool |
Controls whether to escape non-ASCII characters into 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 the result as an image format file |
save_path |
str |
The path to save the file. When specified as a directory, the saved file is named consistent with the input file type. |
None |
* Additionally, the result can be obtained through attributes that provide the visualized images with results and the prediction results, as follows: