update
Browse files123459 unmodified lines15161718192021222324252627282930313233343536373839404142434445464721 unmodified lines69707172737443 unmodified lines11811912012112212312412512612712812913013113213313413513613713813914014114214314411 unmodified lines15615715815916016116216316416516616716816917017112 unmodified lines184185186187188189---license: mitbase_model: PaddlePaddlepipeline_tag: image-to-textlibrary_name: onnx9 unmodified lines| Model | FP32 | Task || --- | --- | --- || PP-DocLayout_plus-L | pp-docLayout_plus-l.onnx | layout detection || PP-OCRv6_medium_det | pp-ocrV6_medium_det.onnx | text line detection || PP-OCRv6_medium_rec | pp-ocrV6_medium_rec.onnx | text recognition || PP-LCNet_x1_0_table_cls | pp-lcNet_x1_0_table_cls.onnx | table classification || RT-DETR-L_wired_table_cell_det | rt-detr-l_wired_table_cell_det.onnx | table cell detection (wired) || RT-DETR-L_wireless_table_cell_det | rt-detr-l_wireless_table_cell_det.onnx | table cell detection (wireless) |## Usage```# onnxruntime-gpu for run it on GPUpip install onnxruntime opencv-python numpy pyclipper```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, postprocess- `onnx/` = the model fileRun the commands from the repository root.Test images used by the examples:- [jp_1.jpg](https://github.com/cimo/One_workspace/blob/main/file/test/jp_1.jpg) = full page- [det_box_0294.jpg](https://github.com/cimo/One_workspace/blob/main/file/test/det_box_0294.jpg) = single text line- [Table_1.jpg](https://github.com/cimo/One_workspace/blob/main/file/test/Table_1.jpg) = single table## PP-DocLayout_plus-L21 unmodified lines- Boxes overlap by design (no NMS in the model): filter by score (0.3 in the example) and handle<br>the containment on your side if needed.## PP-OCRv6_medium_det- [PP-OCRv6_medium_det/src/example.py](PP-OCRv6_medium_det/src/example.py)43 unmodified lines[PP-OCRv6_medium_rec/onnx/dictionary.txt](PP-OCRv6_medium_rec/onnx/dictionary.txt), 18709 is the space.- Score = mean probability of the kept time steps.## PP-LCNet_x1_0_table_cls- [PP-LCNet_x1_0_table_cls/src/example.py](PP-LCNet_x1_0_table_cls/src/example.py)```python3 PP-LCNet_x1_0_table_cls/src/example.py Table_1.jpg``````0.843585 | wired```Note:- Input = a single cropped table, not a full page: use the `table` boxes from PP-DocLayout_plus-L.- Input = RGB image with the short side resized to 256, center cropped to 224x224, scaled to 0..1<br>then normalized with the ImageNet mean / std, CHW with batch dimension.- Feed = `x`, the only input, fixed at 224x224 with a dynamic batch.- Output = `[1, 2]` already softmaxed, index 0 = `wired`, index 1 = `wireless`.- The label picks the cell detection model: `wired` = RT-DETR-L_wired_table_cell_det,<br>`wireless` = RT-DETR-L_wireless_table_cell_det.## RT-DETR-L_wired_table_cell_det- [RT-DETR-L_wired_table_cell_det/src/example.py](RT-DETR-L_wired_table_cell_det/src/example.py)11 unmodified lines```Note:- Input = a single cropped table with the borders drawn: use it when PP-LCNet_x1_0_table_cls<br>answers `wired`.- Input = RGB image resized to 640x640, float32 0..1, CHW with batch dimension.- Feed = `image`, `im_shape` (640, 640), `scale_factor` (640 / height, 640 / width).- Output row = `[classId, score, x1, y1, x2, y2]` with coordinates already in the cropped table space,<br>the box count is in the second output.- 1 label class only, `classId` is always 0 (cell), so the class is not printed.- Output = always 300 rows: filter by score (0.3 in the example) and remove the duplicates on your side,<br>the example drops a box over 0.5 of intersection over union or over 0.9 of containment.- The boxes are the single cells: cluster their edges to rebuild the rows / columns and the spans.## RT-DETR-L_wireless_table_cell_det12 unmodified lines```Note:- Same input, feed and output of RT-DETR-L_wired_table_cell_det, only the weights change: use it when<br>PP-LCNet_x1_0_table_cls answers `wireless`.- Input = a single cropped table without the borders drawn, the cells are separated by the spacing only.123459 unmodified lines15161718192021222324252627282930313233343536373839404142434445464748495021 unmodified lines7273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314443 unmodified lines18818919019119219311 unmodified lines20520620720820921021121221321421521621721821912 unmodified lines232233234235236---license: apache-2.0base_model: PaddlePaddlepipeline_tag: image-to-textlibrary_name: onnx9 unmodified lines| 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) |## Usage```# onnxruntime-gpu for run it on GPUpip 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, postprocess- `onnx/` = 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:- [jp_1.jpg](https://github.com/cimo/One_workspace/blob/main/file/test/invoice/jp_1.jpg) = full page- [det_box_0294.jpg](https://github.com/cimo/One_workspace/blob/main/file/test/string/1.jpg) = single text line- [Table_1.jpg](https://github.com/cimo/One_workspace/blob/main/file/test/table/1.jpg) = single table- [formula_1.jpg](https://github.com/cimo/One_workspace/blob/main/file/test/formula/1.jpg) = single formula## PP-DocLayout_plus-L21 unmodified lines- Boxes overlap by design (no NMS in the model): filter by score (0.3 in the example) and handle<br>the containment on your side if needed.## PP-FormulaNet_plus-L- [PP-FormulaNet_plus-L/src/example.py](PP-FormulaNet_plus-L/src/example.py)```python3 PP-FormulaNet_plus-L/src/example.py formula_1.jpg``````x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}```Note:- Input = a single formula crop, not a full page: use the `formula` boxes from PP-DocLayout_plus-L.- Input = crop trimmed to the ink, resized to fit 768x768 keeping the aspect ratio, centered on a black canvas,<br>RGB scaled to 0..1 then normalized with mean 0.7931 / std 0.1738, CHW with batch dimension.- Two graphs, exported from the official weights with fixed shapes:<br>`pp-formulaNet_plus-l_encoder.onnx` = feed `image` `[1, 3, 768, 768]`, output `memory` `[1, 144, 512]`;<br>`pp-formulaNet_plus-l_decoder.onnx` = one token per call, feed `token` `[1]`, `position` (scalar), `memory`<br>and `buffer` `[8, 1024, 512]`, output `logit` `[1, 50000]` and `state` `[8, 512]`.- Decode = greedy: start from `</s>` (id 2), write `state` in `buffer[:, position]` after every call, stop at `</s>`<br>or at 1024 tokens. The buffer keeps the states of the previous tokens, so every call costs the same.- Token map = [PP-FormulaNet_plus-L/onnx/tokenizer.json](PP-FormulaNet_plus-L/onnx/tokenizer.json), loaded with the `tokenizers` library.- Output = LaTeX without delimiters: add `$ ... $` or `$$ ... $$` on your side.## PP-LCNet_x1_0_doc_ori- [PP-LCNet_x1_0_doc_ori/src/example.py](PP-LCNet_x1_0_doc_ori/src/example.py)```python3 PP-LCNet_x1_0_doc_ori/src/example.py jp_1.jpg``````0.925804 | 0```Note:- Input = a full page, RGB image resized so the short side is 256, center cropped to 224x224, scaled to 0..1 then<br>normalized with the ImageNet mean / std, CHW with batch dimension.- Feed = `x`, the only input, shape `[batch, 3, 224, 224]`.- Output = `[batch, 4]` already softmaxed, index 0..3 = page rotated by 0, 90, 180, 270 degrees clockwise.- To straighten the page rotate it counter-clockwise by the returned angle<br>(90 = `cv2.ROTATE_90_COUNTERCLOCKWISE`, 180 = `cv2.ROTATE_180`, 270 = `cv2.ROTATE_90_CLOCKWISE`).- Only the center of the page is seen: on a page that is mostly blank or made of vertical text, verify the angle<br>with the text recognition score on your side.## PP-LCNet_x1_0_table_cls- [PP-LCNet_x1_0_table_cls/src/example.py](PP-LCNet_x1_0_table_cls/src/example.py)```python3 PP-LCNet_x1_0_table_cls/src/example.py Table_1.jpg``````0.843585 | wired```Note:- Input = a single table crop, not a full page: use the `table` boxes from PP-DocLayout_plus-L.- Input = RGB image resized so the short side is 256, center cropped to 224x224, scaled to 0..1 then<br>normalized with the ImageNet mean / std, CHW with batch dimension.- Feed = `x`, the only input, fixed shape `[1, 3, 224, 224]`.- Output = `[1, 2]` already softmaxed, index 0 is `wired` (ruled table), index 1 is `wireless` (no ruling lines).- Use the label to pick the cell detection model below.## PP-OCRv6_medium_det- [PP-OCRv6_medium_det/src/example.py](PP-OCRv6_medium_det/src/example.py)43 unmodified lines[PP-OCRv6_medium_rec/onnx/dictionary.txt](PP-OCRv6_medium_rec/onnx/dictionary.txt), 18709 is the space.- Score = mean probability of the kept time steps.## RT-DETR-L_wired_table_cell_det- [RT-DETR-L_wired_table_cell_det/src/example.py](RT-DETR-L_wired_table_cell_det/src/example.py)11 unmodified lines```Note:- Input = a single table crop classified as `wired` by PP-LCNet_x1_0_table_cls.- Input = RGB image resized to 640x640, float32 0..1, CHW with batch dimension.- Feed = `image`, `im_shape` (640, 640), `scale_factor` (640 / height, 640 / width).- Output row = `[classId, score, x1, y1, x2, y2]` with coordinates already in the original image space,<br>the box count is in the second output. There is a single class (`cell`).- Output = 300 queries per image, no NMS in the model: filter by score (0.3 in the example), then the example<br>applies a NMS (IoU 0.5) and drops any box that contains 2 or more smaller boxes (containment 0.9).- Cells are returned as axis aligned boxes, merged cells come out as a single wider / taller box:<br>snap the edges to a grid on your side to get row / column index and span.## RT-DETR-L_wireless_table_cell_det12 unmodified lines```Note:- Same input, feed, output and postprocess as RT-DETR-L_wired_table_cell_det.- Use it on a table crop classified as `wireless` by PP-LCNet_x1_0_table_cls.
README.md+91-44