docling-ocr-onnxtr 0.1.3__tar.gz → 0.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {docling_ocr_onnxtr-0.1.3 → docling_ocr_onnxtr-0.2.0}/PKG-INFO +58 -2
- {docling_ocr_onnxtr-0.1.3 → docling_ocr_onnxtr-0.2.0}/README.md +57 -1
- {docling_ocr_onnxtr-0.1.3 → docling_ocr_onnxtr-0.2.0}/docling_ocr_onnxtr/onnxtr_model.py +5 -3
- {docling_ocr_onnxtr-0.1.3 → docling_ocr_onnxtr-0.2.0}/docling_ocr_onnxtr/options.py +3 -3
- docling_ocr_onnxtr-0.2.0/docling_ocr_onnxtr/version.py +1 -0
- {docling_ocr_onnxtr-0.1.3 → docling_ocr_onnxtr-0.2.0}/docling_ocr_onnxtr.egg-info/PKG-INFO +58 -2
- {docling_ocr_onnxtr-0.1.3 → docling_ocr_onnxtr-0.2.0}/setup.py +1 -1
- docling_ocr_onnxtr-0.1.3/docling_ocr_onnxtr/version.py +0 -1
- {docling_ocr_onnxtr-0.1.3 → docling_ocr_onnxtr-0.2.0}/LICENSE +0 -0
- {docling_ocr_onnxtr-0.1.3 → docling_ocr_onnxtr-0.2.0}/docling_ocr_onnxtr/__init__.py +0 -0
- {docling_ocr_onnxtr-0.1.3 → docling_ocr_onnxtr-0.2.0}/docling_ocr_onnxtr/plugin.py +0 -0
- {docling_ocr_onnxtr-0.1.3 → docling_ocr_onnxtr-0.2.0}/docling_ocr_onnxtr/py.typed +0 -0
- {docling_ocr_onnxtr-0.1.3 → docling_ocr_onnxtr-0.2.0}/docling_ocr_onnxtr.egg-info/SOURCES.txt +0 -0
- {docling_ocr_onnxtr-0.1.3 → docling_ocr_onnxtr-0.2.0}/docling_ocr_onnxtr.egg-info/dependency_links.txt +0 -0
- {docling_ocr_onnxtr-0.1.3 → docling_ocr_onnxtr-0.2.0}/docling_ocr_onnxtr.egg-info/entry_points.txt +0 -0
- {docling_ocr_onnxtr-0.1.3 → docling_ocr_onnxtr-0.2.0}/docling_ocr_onnxtr.egg-info/requires.txt +0 -0
- {docling_ocr_onnxtr-0.1.3 → docling_ocr_onnxtr-0.2.0}/docling_ocr_onnxtr.egg-info/top_level.txt +0 -0
- {docling_ocr_onnxtr-0.1.3 → docling_ocr_onnxtr-0.2.0}/docling_ocr_onnxtr.egg-info/zip-safe +0 -0
- {docling_ocr_onnxtr-0.1.3 → docling_ocr_onnxtr-0.2.0}/pyproject.toml +0 -0
- {docling_ocr_onnxtr-0.1.3 → docling_ocr_onnxtr-0.2.0}/setup.cfg +0 -0
- {docling_ocr_onnxtr-0.1.3 → docling_ocr_onnxtr-0.2.0}/tests/test_pipeline_invalid_cases.py +0 -0
- {docling_ocr_onnxtr-0.1.3 → docling_ocr_onnxtr-0.2.0}/tests/test_plugin.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: docling-ocr-onnxtr
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.2.0
|
|
4
4
|
Summary: Onnx Text Recognition (OnnxTR) OCR plugin for docling
|
|
5
5
|
Author-email: Felix Dittrich <felixdittrich92@gmail.com>
|
|
6
6
|
Maintainer: Felix Dittrich
|
|
@@ -266,7 +266,7 @@ Dynamic: license-file
|
|
|
266
266
|
[](https://codecov.io/gh/felixdittrich92/docling-OCR-OnnxTR)
|
|
267
267
|
[](https://app.codacy.com/gh/felixdittrich92/docling-OCR-OnnxTR/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade)
|
|
268
268
|
[](https://www.codefactor.io/repository/github/felixdittrich92/docling-ocr-onnxtr)
|
|
269
|
-
[](https://pypi.org/project/docling-ocr-onnxtr/)
|
|
270
270
|

|
|
271
271
|
|
|
272
272
|
The `docling-OCR-OnnxTR` repository provides a plugin that integrates the [OnnxTR OCR engine](https://github.com/felixdittrich92/OnnxTR) into the [Docling framework](https://github.com/docling-project/docling), enhancing document processing capabilities with efficient and accurate text recognition.
|
|
@@ -358,6 +358,62 @@ def main():
|
|
|
358
358
|
print(md)
|
|
359
359
|
|
|
360
360
|
|
|
361
|
+
if __name__ == "__main__":
|
|
362
|
+
main()
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
It is also possible to load the models from local files instead of using the Hugging Face Hub or downloading them from the repo:
|
|
366
|
+
|
|
367
|
+
```python
|
|
368
|
+
from docling.datamodel.pipeline_options import PdfPipelineOptions
|
|
369
|
+
from docling.document_converter import (
|
|
370
|
+
ConversionResult,
|
|
371
|
+
DocumentConverter,
|
|
372
|
+
InputFormat,
|
|
373
|
+
PdfFormatOption,
|
|
374
|
+
)
|
|
375
|
+
from docling_ocr_onnxtr import OnnxtrOcrOptions
|
|
376
|
+
from onnxtr.models import db_mobilenet_v3_large, parseq
|
|
377
|
+
|
|
378
|
+
|
|
379
|
+
def main():
|
|
380
|
+
# Source document to convert
|
|
381
|
+
source = "https://arxiv.org/pdf/2408.09869v4"
|
|
382
|
+
|
|
383
|
+
# Load models from local files
|
|
384
|
+
# NOTE: You need to download the models first and then adjust the paths accordingly.
|
|
385
|
+
det_model = db_mobilenet_v3_large("/home/felix/.cache/onnxtr/models/db_mobilenet_v3_large-1866973f.onnx")
|
|
386
|
+
reco_model = parseq("/home/felix/.cache/onnxtr/models/parseq-00b40714.onnx")
|
|
387
|
+
|
|
388
|
+
ocr_options = OnnxtrOcrOptions(
|
|
389
|
+
# Text detection model
|
|
390
|
+
det_arch=det_model,
|
|
391
|
+
# Text recognition model
|
|
392
|
+
reco_arch=reco_model,
|
|
393
|
+
# This can be set to `True` to auto-correct the orientation of the pages
|
|
394
|
+
auto_correct_orientation=False,
|
|
395
|
+
)
|
|
396
|
+
|
|
397
|
+
pipeline_options = PdfPipelineOptions(
|
|
398
|
+
ocr_options=ocr_options,
|
|
399
|
+
)
|
|
400
|
+
pipeline_options.allow_external_plugins = True # <-- enabled the external plugins
|
|
401
|
+
|
|
402
|
+
# Convert the document
|
|
403
|
+
converter = DocumentConverter(
|
|
404
|
+
format_options={
|
|
405
|
+
InputFormat.PDF: PdfFormatOption(
|
|
406
|
+
pipeline_options=pipeline_options,
|
|
407
|
+
),
|
|
408
|
+
},
|
|
409
|
+
)
|
|
410
|
+
|
|
411
|
+
conversion_result: ConversionResult = converter.convert(source=source)
|
|
412
|
+
doc = conversion_result.document
|
|
413
|
+
md = doc.export_to_markdown()
|
|
414
|
+
print(md)
|
|
415
|
+
|
|
416
|
+
|
|
361
417
|
if __name__ == "__main__":
|
|
362
418
|
main()
|
|
363
419
|
```
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
[](https://codecov.io/gh/felixdittrich92/docling-OCR-OnnxTR)
|
|
8
8
|
[](https://app.codacy.com/gh/felixdittrich92/docling-OCR-OnnxTR/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade)
|
|
9
9
|
[](https://www.codefactor.io/repository/github/felixdittrich92/docling-ocr-onnxtr)
|
|
10
|
-
[](https://pypi.org/project/docling-ocr-onnxtr/)
|
|
11
11
|

|
|
12
12
|
|
|
13
13
|
The `docling-OCR-OnnxTR` repository provides a plugin that integrates the [OnnxTR OCR engine](https://github.com/felixdittrich92/OnnxTR) into the [Docling framework](https://github.com/docling-project/docling), enhancing document processing capabilities with efficient and accurate text recognition.
|
|
@@ -99,6 +99,62 @@ def main():
|
|
|
99
99
|
print(md)
|
|
100
100
|
|
|
101
101
|
|
|
102
|
+
if __name__ == "__main__":
|
|
103
|
+
main()
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
It is also possible to load the models from local files instead of using the Hugging Face Hub or downloading them from the repo:
|
|
107
|
+
|
|
108
|
+
```python
|
|
109
|
+
from docling.datamodel.pipeline_options import PdfPipelineOptions
|
|
110
|
+
from docling.document_converter import (
|
|
111
|
+
ConversionResult,
|
|
112
|
+
DocumentConverter,
|
|
113
|
+
InputFormat,
|
|
114
|
+
PdfFormatOption,
|
|
115
|
+
)
|
|
116
|
+
from docling_ocr_onnxtr import OnnxtrOcrOptions
|
|
117
|
+
from onnxtr.models import db_mobilenet_v3_large, parseq
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
def main():
|
|
121
|
+
# Source document to convert
|
|
122
|
+
source = "https://arxiv.org/pdf/2408.09869v4"
|
|
123
|
+
|
|
124
|
+
# Load models from local files
|
|
125
|
+
# NOTE: You need to download the models first and then adjust the paths accordingly.
|
|
126
|
+
det_model = db_mobilenet_v3_large("/home/felix/.cache/onnxtr/models/db_mobilenet_v3_large-1866973f.onnx")
|
|
127
|
+
reco_model = parseq("/home/felix/.cache/onnxtr/models/parseq-00b40714.onnx")
|
|
128
|
+
|
|
129
|
+
ocr_options = OnnxtrOcrOptions(
|
|
130
|
+
# Text detection model
|
|
131
|
+
det_arch=det_model,
|
|
132
|
+
# Text recognition model
|
|
133
|
+
reco_arch=reco_model,
|
|
134
|
+
# This can be set to `True` to auto-correct the orientation of the pages
|
|
135
|
+
auto_correct_orientation=False,
|
|
136
|
+
)
|
|
137
|
+
|
|
138
|
+
pipeline_options = PdfPipelineOptions(
|
|
139
|
+
ocr_options=ocr_options,
|
|
140
|
+
)
|
|
141
|
+
pipeline_options.allow_external_plugins = True # <-- enabled the external plugins
|
|
142
|
+
|
|
143
|
+
# Convert the document
|
|
144
|
+
converter = DocumentConverter(
|
|
145
|
+
format_options={
|
|
146
|
+
InputFormat.PDF: PdfFormatOption(
|
|
147
|
+
pipeline_options=pipeline_options,
|
|
148
|
+
),
|
|
149
|
+
},
|
|
150
|
+
)
|
|
151
|
+
|
|
152
|
+
conversion_result: ConversionResult = converter.convert(source=source)
|
|
153
|
+
doc = conversion_result.document
|
|
154
|
+
md = doc.export_to_markdown()
|
|
155
|
+
print(md)
|
|
156
|
+
|
|
157
|
+
|
|
102
158
|
if __name__ == "__main__":
|
|
103
159
|
main()
|
|
104
160
|
```
|
|
@@ -12,7 +12,7 @@ import numpy
|
|
|
12
12
|
import numpy as np
|
|
13
13
|
from docling.datamodel.base_models import Page
|
|
14
14
|
from docling.datamodel.document import ConversionResult
|
|
15
|
-
from docling.datamodel.pipeline_options import (
|
|
15
|
+
from docling.datamodel.pipeline_options import ( # type: ignore[attr-defined]
|
|
16
16
|
AcceleratorOptions,
|
|
17
17
|
OcrOptions,
|
|
18
18
|
)
|
|
@@ -91,11 +91,13 @@ class OnnxtrOcrModel(BaseOcrModel):
|
|
|
91
91
|
|
|
92
92
|
self.reader = ocr_predictor(
|
|
93
93
|
det_arch=(
|
|
94
|
-
from_hub(self.options.det_arch)
|
|
94
|
+
from_hub(self.options.det_arch)
|
|
95
|
+
if isinstance(self.options.det_arch, str) and self.options.det_arch.count("/") == 1
|
|
96
|
+
else self.options.det_arch
|
|
95
97
|
),
|
|
96
98
|
reco_arch=(
|
|
97
99
|
from_hub(self.options.reco_arch)
|
|
98
|
-
if self.options.reco_arch.count("/") == 1
|
|
100
|
+
if isinstance(self.options.reco_arch, str) and self.options.reco_arch.count("/") == 1
|
|
99
101
|
else self.options.reco_arch
|
|
100
102
|
),
|
|
101
103
|
det_bs=1, # NOTE: Should be always 1, because docling handles batching
|
|
@@ -22,9 +22,9 @@ class OnnxtrOcrOptions(OcrOptions):
|
|
|
22
22
|
# detection model objectness score threshold 'fast algorithm'
|
|
23
23
|
objectness_score: float = 0.3
|
|
24
24
|
|
|
25
|
-
# NOTE: This can be also a hf hub model
|
|
26
|
-
det_arch:
|
|
27
|
-
reco_arch:
|
|
25
|
+
# NOTE: This can be also a hf hub model or an instance of a model class.
|
|
26
|
+
det_arch: Any = "fast_base"
|
|
27
|
+
reco_arch: Any = "crnn_vgg16_bn"
|
|
28
28
|
reco_bs: int = 512
|
|
29
29
|
auto_correct_orientation: bool = False
|
|
30
30
|
preserve_aspect_ratio: bool = True
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = 'v0.2.0'
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: docling-ocr-onnxtr
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.2.0
|
|
4
4
|
Summary: Onnx Text Recognition (OnnxTR) OCR plugin for docling
|
|
5
5
|
Author-email: Felix Dittrich <felixdittrich92@gmail.com>
|
|
6
6
|
Maintainer: Felix Dittrich
|
|
@@ -266,7 +266,7 @@ Dynamic: license-file
|
|
|
266
266
|
[](https://codecov.io/gh/felixdittrich92/docling-OCR-OnnxTR)
|
|
267
267
|
[](https://app.codacy.com/gh/felixdittrich92/docling-OCR-OnnxTR/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade)
|
|
268
268
|
[](https://www.codefactor.io/repository/github/felixdittrich92/docling-ocr-onnxtr)
|
|
269
|
-
[](https://pypi.org/project/docling-ocr-onnxtr/)
|
|
270
270
|

|
|
271
271
|
|
|
272
272
|
The `docling-OCR-OnnxTR` repository provides a plugin that integrates the [OnnxTR OCR engine](https://github.com/felixdittrich92/OnnxTR) into the [Docling framework](https://github.com/docling-project/docling), enhancing document processing capabilities with efficient and accurate text recognition.
|
|
@@ -358,6 +358,62 @@ def main():
|
|
|
358
358
|
print(md)
|
|
359
359
|
|
|
360
360
|
|
|
361
|
+
if __name__ == "__main__":
|
|
362
|
+
main()
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
It is also possible to load the models from local files instead of using the Hugging Face Hub or downloading them from the repo:
|
|
366
|
+
|
|
367
|
+
```python
|
|
368
|
+
from docling.datamodel.pipeline_options import PdfPipelineOptions
|
|
369
|
+
from docling.document_converter import (
|
|
370
|
+
ConversionResult,
|
|
371
|
+
DocumentConverter,
|
|
372
|
+
InputFormat,
|
|
373
|
+
PdfFormatOption,
|
|
374
|
+
)
|
|
375
|
+
from docling_ocr_onnxtr import OnnxtrOcrOptions
|
|
376
|
+
from onnxtr.models import db_mobilenet_v3_large, parseq
|
|
377
|
+
|
|
378
|
+
|
|
379
|
+
def main():
|
|
380
|
+
# Source document to convert
|
|
381
|
+
source = "https://arxiv.org/pdf/2408.09869v4"
|
|
382
|
+
|
|
383
|
+
# Load models from local files
|
|
384
|
+
# NOTE: You need to download the models first and then adjust the paths accordingly.
|
|
385
|
+
det_model = db_mobilenet_v3_large("/home/felix/.cache/onnxtr/models/db_mobilenet_v3_large-1866973f.onnx")
|
|
386
|
+
reco_model = parseq("/home/felix/.cache/onnxtr/models/parseq-00b40714.onnx")
|
|
387
|
+
|
|
388
|
+
ocr_options = OnnxtrOcrOptions(
|
|
389
|
+
# Text detection model
|
|
390
|
+
det_arch=det_model,
|
|
391
|
+
# Text recognition model
|
|
392
|
+
reco_arch=reco_model,
|
|
393
|
+
# This can be set to `True` to auto-correct the orientation of the pages
|
|
394
|
+
auto_correct_orientation=False,
|
|
395
|
+
)
|
|
396
|
+
|
|
397
|
+
pipeline_options = PdfPipelineOptions(
|
|
398
|
+
ocr_options=ocr_options,
|
|
399
|
+
)
|
|
400
|
+
pipeline_options.allow_external_plugins = True # <-- enabled the external plugins
|
|
401
|
+
|
|
402
|
+
# Convert the document
|
|
403
|
+
converter = DocumentConverter(
|
|
404
|
+
format_options={
|
|
405
|
+
InputFormat.PDF: PdfFormatOption(
|
|
406
|
+
pipeline_options=pipeline_options,
|
|
407
|
+
),
|
|
408
|
+
},
|
|
409
|
+
)
|
|
410
|
+
|
|
411
|
+
conversion_result: ConversionResult = converter.convert(source=source)
|
|
412
|
+
doc = conversion_result.document
|
|
413
|
+
md = doc.export_to_markdown()
|
|
414
|
+
print(md)
|
|
415
|
+
|
|
416
|
+
|
|
361
417
|
if __name__ == "__main__":
|
|
362
418
|
main()
|
|
363
419
|
```
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = 'v0.1.3'
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{docling_ocr_onnxtr-0.1.3 → docling_ocr_onnxtr-0.2.0}/docling_ocr_onnxtr.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
{docling_ocr_onnxtr-0.1.3 → docling_ocr_onnxtr-0.2.0}/docling_ocr_onnxtr.egg-info/entry_points.txt
RENAMED
|
File without changes
|
{docling_ocr_onnxtr-0.1.3 → docling_ocr_onnxtr-0.2.0}/docling_ocr_onnxtr.egg-info/requires.txt
RENAMED
|
File without changes
|
{docling_ocr_onnxtr-0.1.3 → docling_ocr_onnxtr-0.2.0}/docling_ocr_onnxtr.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|