by Koffiepoeder · 2d ago · 0 comments
0) some preprocessing steps (contrast/brightness)
1) layout detection by paddle [0]
2) layout detection by granite docling heron [1]
3) a smart merging algorithm, eg non overlapping surface maximization. Just ask your llm and iterqte a bit.
4) Custom models for table areas [3] and text nodes [4]
-
5) Optional: postprocessing with gemma for structured output
I am now reaching >99% accuracy for invoice and receipt scanning. Even low quality pictures in bad light usually come out fine. 0: https://www.paddleocr.ai/main/en/version3.x/algorithm/PP-StructureV3/PP-StructureV3.html
1: https://docling-project.github.io/docling/usage/model_catalog/#stages-and-models-overview
3: currently mobile, I will complete these later, don't know the exact models by heart
4:I would love to have an internal stack.
Speed and cost are an issue right now.
For the preprocessing, I forgot to mention that I also DO use paddle here: I combine usage of (paddle) PP-LCNet and (paddle) UVDoc for page rotation and straightening. [0] [1]
For OCR of detailed text fragments, I use MinerU2.5-Pro-2605-1.2B (Q8_0) with some blank detection (i.e. if the response is blank, I try some variations with widening pixels at each edge and brightness/contrast). [2]
For tables, the full pipeline looks as follows: - (paddle) PP-LCNet for detecting which kind of table: bordered or borderless [3] - (paddle) SLANet Plus is used to propose a cell grid. However results here are not always adequate, as such: we also run MinerU's UnetStructure for bordered tables or if SLANet plus output is bad (low cell count). [3] [4] - For the text extraction step, we use (paddle) PP-OCRv6 Small to detect the areas, then the regular mineru for the real text extraction. [5] [2] - A final step is to reassemble the tables in to html, this is more procedural/code based.
If interested, I can maybe extract relevant parts into a custom pipeline and push it, though the code is not polished.
[0] https://huggingface.co/PaddlePaddle/PP-LCNet_x1_0_doc_ori_onnx
[1] https://huggingface.co/PaddlePaddle/UVDoc_onnx
[2] https://huggingface.co/mradermacher/MinerU2.5-Pro-2605-1.2B-GGUF
[3] https://www.paddleocr.ai/v3.3.1/en/version3.x/module_usage/table_structure_recognition.html
[4] https://github.com/opendatalab/MinerU/blob/79d6d8d79fb8f3ddba5cc34c07a16f0ec36f56c7/mineru/model/table/rec/unet_table/table_structure_unet.py
[5] https://www.paddleocr.ai/main/en/version3.x/module_usage/text_detection.htmlMight be a bit clearer than my stacked comments that are all over the place.
Basically the gist of it is, use paddle for most stuff, improve where relevant with some mineru and heron detections. Build in fallbacks - at every step.