| Model | FP32 | Task |
|---|---|---|
| PP-DocLayout_plus-L | pp-docLayout_plus-l.onnx, pp-docLayout_plus-l.onnx_data | layout detection |
| PP-FormulaNet_plus-L | pp-formulaNet_plus-l_encoder.onnx, pp-formulaNet_plus-l_encoder.onnx_data, pp-formulaNet_plus-l_decoder.onnx, pp-formulaNet_plus-l_decoder.onnx_data | formula recognition (LaTeX) |
| PP-LCNet_x1_0_doc_ori | pp-lcNet_x1_0_doc_ori.onnx, pp-lcNet_x1_0_doc_ori.onnx_data | page orientation (0 / 90 / 180 / 270) |
| PP-LCNet_x1_0_table_cls | pp-lcNet_x1_0_table_cls.onnx, pp-lcNet_x1_0_table_cls.onnx_data | table classification (wired / wireless) |
| PP-OCRv6_medium_det | pp-ocrV6_medium_det.onnx, pp-ocrV6_medium_det.onnx_data | text line detection |
| PP-OCRv6_medium_rec | pp-ocrV6_medium_rec.onnx, pp-ocrV6_medium_rec.onnx_data | text recognition |
| RT-DETR-L_wired_table_cell_det | rt-detr-l_wired_table_cell_det.onnx, rt-detr-l_wired_table_cell_det.onnx_data | table cell detection (wired) |
| RT-DETR-L_wireless_table_cell_det | rt-detr-l_wireless_table_cell_det.onnx, rt-detr-l_wireless_table_cell_det.onnx_data | table cell detection (wireless) |
# onnxruntime-gpu for run it on GPU
pip install onnxruntime opencv-python numpy pyclipper tokenizers
Every model folder has the same layout:
src/helper.py = onnx session builder (provider selection, threads, memory options)src/example.py = full pipeline: image preprocess, inference, postprocessonnx/ = the model files: xxx.onnx (structure) and xxx.onnx_data (weight), keep them in the same folderRun the commands from the repository root.
Test images used by the examples:
python3 PP-DocLayout_plus-L/src/example.py jp_1.jpg
0.936555 | header | [530, 62, 1213, 104]
0.910084 | table | [1066, 176, 1692, 260]
0.891657 | footer | [1066, 1157, 1198, 1175]
0.886924 | table | [54, 395, 1694, 799]
0.827543 | text | [55, 804, 1029, 959]
Note:
image, im_shape (800, 800), scale_factor (800 / height, 800 / width).[classId, score, x1, y1, x2, y2] with coordinates already in the original image space,python3 PP-FormulaNet_plus-L/src/example.py formula_1.jpg
x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}
Note:
formula boxes from PP-DocLayout_plus-L.pp-formulaNet_plus-l_encoder.onnx = feed image [1, 3, 768, 768], output memory [1, 144, 512];pp-formulaNet_plus-l_decoder.onnx = one token per call, feed token [1], position (scalar), memorybuffer [8, 1024, 512], output logit [1, 50000] and state [8, 512].</s> (id 2), write state in buffer[:, position] after every call, stop at </s>tokenizers library.$ ... $ or $$ ... $$ on your side.python3 PP-LCNet_x1_0_doc_ori/src/example.py jp_1.jpg
0.925804 | 0
Note:
x, the only input, shape [batch, 3, 224, 224].[batch, 4] already softmaxed, index 0..3 = page rotated by 0, 90, 180, 270 degrees clockwise.cv2.ROTATE_90_COUNTERCLOCKWISE, 180 = cv2.ROTATE_180, 270 = cv2.ROTATE_90_CLOCKWISE).python3 PP-LCNet_x1_0_table_cls/src/example.py Table_1.jpg
0.843585 | wired
Note:
table boxes from PP-DocLayout_plus-L.x, the only input, fixed shape [1, 3, 224, 224].[1, 2] already softmaxed, index 0 is wired (ruled table), index 1 is wireless (no ruling lines).python3 PP-OCRv6_medium_det/src/example.py jp_1.jpg
0.965487 | [[60, 1158], [850, 1158], [850, 1176], [60, 1176]]
0.827508 | [[1069, 1156], [1200, 1156], [1200, 1176], [1069, 1176]]
0.916008 | [[64, 1128], [837, 1128], [837, 1149], [64, 1149]]
Note:
cv2.imread, no channel swap) normalized with the ImageNet mean / std,x, the only input, with a fully dynamic shape.[1, 1, height, width], the DB postprocess is on your side:cv2.findContours, minimum area box, score as the mean probability inside the box,[score, [4 corner points]] clockwise from the top-left corner, already in the originalpython3 PP-OCRv6_medium_rec/src/example.py det_box_0294.jpg
0.953031 | (別表十(一)「15」若しくは別表十(二)「10」又は別表十(一)「16」若しくは別表十(二)「11」)
Note:
cv2.imread, no channel swap) resized to height 48 keeping the aspect ratio,x, the only input, with a dynamic width (minimum 320, capped at 3200).[1, timeStep, 18710] already softmaxed, decoded with a greedy CTC: drop the repeats first,python3 RT-DETR-L_wired_table_cell_det/src/example.py Table_1.jpg
0.953868 | [467, 189, 1012, 216]
0.953357 | [467, 162, 1012, 189]
0.953275 | [467, 216, 1012, 243]
0.951546 | [467, 243, 1012, 270]
0.950149 | [467, 135, 1012, 162]
Note:
wired by PP-LCNet_x1_0_table_cls.image, im_shape (640, 640), scale_factor (640 / height, 640 / width).[classId, score, x1, y1, x2, y2] with coordinates already in the original image space,cell).python3 RT-DETR-L_wireless_table_cell_det/src/example.py Table_1.jpg
0.951309 | [464, 162, 1009, 189]
0.950602 | [464, 189, 1010, 216]
0.950491 | [464, 216, 1010, 243]
0.950054 | [464, 243, 1010, 270]
0.949992 | [464, 297, 1010, 324]
Note:
wireless by PP-LCNet_x1_0_table_cls.RT-DETR-L_wireless_table_cell_det/onnx/rt-detr-l_wireless_table_cell_det.onnx 648.3 KiBRT-DETR-L_wired_table_cell_det/onnx/rt-detr-l_wired_table_cell_det.onnx 646.8 KiBPP-DocLayout_plus-L/onnx/pp-docLayout_plus-l.onnx 641.3 KiBPP-FormulaNet_plus-L/onnx/pp-formulaNet_plus-l_encoder.onnx 287.2 KiBPP-OCRv6_medium_rec/onnx/pp-ocrV6_medium_rec.onnx 126.6 KiBPP-OCRv6_medium_det/onnx/pp-ocrV6_medium_det.onnx 110.1 KiBPP-FormulaNet_plus-L/onnx/pp-formulaNet_plus-l_decoder.onnx 93 KiBPP-LCNet_x1_0_table_cls/onnx/pp-lcNet_x1_0_table_cls.onnx 58.8 KiBPP-LCNet_x1_0_doc_ori/onnx/pp-lcNet_x1_0_doc_ori.onnx 58.6 KiB