---
comments: true
---
# Seal Text Detection Module Tutorial
## I. Overview
The seal text detection module typically outputs multi-point bounding boxes around text regions, which are then passed as inputs to the distortion correction and text recognition modules for subsequent processing to identify the textual content of the seal. Recognizing seal text is an integral part of document processing and finds applications in various scenarios such as contract comparison, inventory access auditing, and invoice reimbursement verification. The seal text detection module serves as a subtask within OCR (Optical Character Recognition), responsible for locating and marking the regions containing seal text within an image. The performance of this module directly impacts the accuracy and efficiency of the entire seal text OCR system.
## II. Supported Model List
Parameter |
Parameter Description |
Parameter Type |
Options |
Default Value |
model_name |
Name of the model |
str |
All model names supported by PaddleX for seal text detection |
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 |
limit_side_len |
Limit on the side length of the image for detection |
int/None |
- int: Any integer greater than 0
- None: If set to None, the default value from the official PaddleX model configuration will be used
|
None |
limit_type |
Type of side length limit for detection |
str/None |
- str: Supports min and max. min ensures the shortest side of the image is not less than det_limit_side_len, max ensures the longest side is not greater than limit_side_len
- None: If set to None, the default value from the official PaddleX model configuration will be used
|
None |
thresh |
In the output probability map, pixels with scores greater than this threshold will be considered as text pixels |
float/None |
- float: Any float greater than 0
- None: If set to None, the default value from the official PaddleX model configuration will be used
|
None |
box_thresh |
If the average score of all pixels within a detection result box is greater than this threshold, the result will be considered as a text region |
float/None |
- float: Any float greater than 0
- None: If set to None, the default value from the official PaddleX model configuration will be used
|
None |
max_candidates |
Maximum number of text boxes to output |
int/None |
- int: Any integer greater than 0
- None: If set to None, the default value from the official PaddleX model configuration will be used
|
None |
unclip_ratio |
Expansion ratio for the Vatti clipping algorithm, used to expand the text region |
float/None |
- float: Any float greater than 0
- None: If set to None, the default value from the official PaddleX model configuration will be used
|
None |
use_dilation |
Whether to dilate the segmentation result |
bool/None |
True/False/None |
None |
use_hpip |
Whether to enable the high-performance inference plugin |
bool |
None |
False |
hpi_config |
High-performance inference configuration |
dict | None |
None |
None |
* The `model_name` must be specified. After specifying `model_name`, the built-in model parameters of PaddleX will be used by default. On this basis, if `model_dir` is specified, the user-defined model will be used.
* The `predict()` method of the seal text detection model is called for inference prediction. The parameters of the `predict()` method include `input`, `batch_size`, `limit_side_len`, `limit_type`, `thresh`, `box_thresh`, `max_candidates`, `unclip_ratio`, and `use_dilation`. The specific descriptions are as follows:
Parameter |
Parameter Description |
Parameter Type |
Options |
Default Value |
input |
Data to be predicted, supporting multiple input types |
Python Var /str /dict /list |
- Python Variable, such as image data represented by
numpy.ndarray
- File Path, such as the local path of an image file:
/root/data/img.jpg
- URL Link, such as the web URL of an image file: Example
- Local Directory, the directory should contain the data files to be predicted, such as the local path:
/root/data/
- List, the elements of the list should be of the above-mentioned data 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 greater than 0 |
1 |
limit_side_len |
Side length limit for detection |
int/None |
- int: Any integer greater than 0
- None: If set to None, the parameter value initialized by the model will be used by default
|
None |
limit_type |
Type of side length limit for detection |
str/None |
- str: Supports min and max. min indicates that the shortest side of the image is not less than det_limit_side_len, max indicates that the longest side of the image is not greater than limit_side_len
- None: If set to None, the parameter value initialized by the model will be used by default
|
None |
thresh |
In the output probability map, pixels with scores greater than this threshold will be considered as text pixels |
float/None |
- float: Any float greater than 0
- None: If set to None, the parameter value initialized by the model will be used by default
|
None |
box_thresh |
If the average score of all pixels within the detection result box is greater than this threshold, the result will be considered as a text area |
float/None |
- float: Any float greater than 0
- None: If set to None, the parameter value initialized by the model will be used by default
|
None |
max_candidates |
Maximum number of text boxes to be output |
int/None |
- int: Any integer greater than 0
- None: If set to None, the parameter value initialized by the model will be used by default
|
None |
unclip_ratio |
Expansion coefficient of the Vatti clipping algorithm, used to expand the text area |
float/None |
- float: Any float greater than 0
- None: If set to None, the parameter value initialized by the model will be used by default
|
None |
use_dilation |
Whether to dilate the segmentation result |
bool/None |
True/False/None |
None |
* Process the prediction results. Each sample's prediction result is a corresponding Result object, and it supports operations such as printing, saving as an image, and saving as a `json` file:
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. This is 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. This is only effective when format_json is True |
False |
save_to_json() |
Save the result as a file in JSON format |
save_path |
str |
The file path for saving. When it is a directory, the saved file name will be consistent with the input file name |
None |
indent |
int |
Specify the indentation level to beautify the output JSON data, making it more readable. This is 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. This is only effective when format_json is True |
False |
save_to_img() |
Save the result as a file in image format |
save_path |
str |
The file path for saving. When it is a directory, the saved file name will be consistent with the input file name |
None |
* In addition, it also supports obtaining visual images with results and prediction results through attributes, as follows: