docling-ocr-onnxtr 0.1.3__py3-none-any.whl → 0.2.1__py3-none-any.whl

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.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2021-2025, Felix Dittrich.
1
+ # Copyright (C) 2021-2026, Felix Dittrich.
2
2
 
3
3
  # This program is licensed under the Apache License 2.0.
4
4
  # See LICENSE or go to <https://opensource.org/licenses/Apache-2.0> for full license details.
@@ -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) if self.options.det_arch.count("/") == 1 else 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
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2021-2025, Felix Dittrich.
1
+ # Copyright (C) 2021-2026, Felix Dittrich.
2
2
 
3
3
  # This program is licensed under the Apache License 2.0.
4
4
  # See LICENSE or go to <https://opensource.org/licenses/Apache-2.0> for full license details.
@@ -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: str = "fast_base"
27
- reco_arch: str = "crnn_vgg16_bn"
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
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2021-2025, Felix Dittrich.
1
+ # Copyright (C) 2021-2026, Felix Dittrich.
2
2
 
3
3
  # This program is licensed under the Apache License 2.0.
4
4
  # See LICENSE or go to <https://opensource.org/licenses/Apache-2.0> for full license details.
@@ -1 +1 @@
1
- __version__ = 'v0.1.3'
1
+ __version__ = 'v0.2.1'
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: docling-ocr-onnxtr
3
- Version: 0.1.3
3
+ Version: 0.2.1
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
  [![codecov](https://codecov.io/gh/felixdittrich92/docling-OCR-OnnxTR/graph/badge.svg?token=L3AHXKV86A)](https://codecov.io/gh/felixdittrich92/docling-OCR-OnnxTR)
267
267
  [![Codacy Badge](https://app.codacy.com/project/badge/Grade/0d250447650240ee9ca573950fea8b99)](https://app.codacy.com/gh/felixdittrich92/docling-OCR-OnnxTR/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade)
268
268
  [![CodeFactor](https://www.codefactor.io/repository/github/felixdittrich92/docling-ocr-onnxtr/badge)](https://www.codefactor.io/repository/github/felixdittrich92/docling-ocr-onnxtr)
269
- [![Pypi](https://img.shields.io/badge/pypi-v0.1.3-blue.svg)](https://pypi.org/project/docling-ocr-onnxtr/)
269
+ [![Pypi](https://img.shields.io/badge/pypi-v0.2.0-blue.svg)](https://pypi.org/project/docling-ocr-onnxtr/)
270
270
  ![PyPI - Downloads](https://img.shields.io/pypi/dm/docling-ocr-onnxtr)
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
  ```
@@ -0,0 +1,13 @@
1
+ docling_ocr_onnxtr/__init__.py,sha256=w8M8ctJDcDcxxrRJ_GT-G7JP3H7E1O50AuoK4l2djf0,85
2
+ docling_ocr_onnxtr/onnxtr_model.py,sha256=_sBsw4AmPmVER0ofeTSoO8o2o7TYo1ae74VFFUC1M78,8628
3
+ docling_ocr_onnxtr/options.py,sha256=OV8-zrZgtvyBPrsWhXgN64QJgi1zJAqtNG2js2FGsx0,1299
4
+ docling_ocr_onnxtr/plugin.py,sha256=RYPYVx43To4-iasgR6t4cLGkM-FcDtJes4YEd9wNn34,317
5
+ docling_ocr_onnxtr/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
+ docling_ocr_onnxtr/version.py,sha256=EoWBp-fpFJDMBjvxaKatEYeaQJfcLahYmd4ZV9CZhgU,23
7
+ docling_ocr_onnxtr-0.2.1.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
8
+ docling_ocr_onnxtr-0.2.1.dist-info/METADATA,sha256=0Fo39ZwO7vE5ojp3lZE1xXDcrLI8pzl6ZQSlkIwd8jo,23822
9
+ docling_ocr_onnxtr-0.2.1.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
10
+ docling_ocr_onnxtr-0.2.1.dist-info/entry_points.txt,sha256=4bUh15gjHVjgG1_vEtZgZ0Kyo7ygkWeAugc_W-EtSfo,57
11
+ docling_ocr_onnxtr-0.2.1.dist-info/top_level.txt,sha256=vmOD5JYg8FKSI-iXyYH73_9AwJdxPOP1TsSY1nDp5iE,24
12
+ docling_ocr_onnxtr-0.2.1.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
13
+ docling_ocr_onnxtr-0.2.1.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.9.0)
2
+ Generator: setuptools (80.10.2)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,13 +0,0 @@
1
- docling_ocr_onnxtr/__init__.py,sha256=w8M8ctJDcDcxxrRJ_GT-G7JP3H7E1O50AuoK4l2djf0,85
2
- docling_ocr_onnxtr/onnxtr_model.py,sha256=TwqkdmnciylUcoZo2bZ7V_WEZs4aIYr6rvTX9cISeBA,8471
3
- docling_ocr_onnxtr/options.py,sha256=gOzKHo86zwAVI_5-YxOr4NaRkNFwlv1RXeag7ZKWxtM,1266
4
- docling_ocr_onnxtr/plugin.py,sha256=qtPPjpsiXyExvK7Vu8ssZhqxDV2gqFTHIIBBv1qz1lA,317
5
- docling_ocr_onnxtr/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
- docling_ocr_onnxtr/version.py,sha256=FM-qCgFYvksyN8UbtON9BhvA7yby2ImDMSOhdXo8wJU,23
7
- docling_ocr_onnxtr-0.1.3.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
8
- docling_ocr_onnxtr-0.1.3.dist-info/METADATA,sha256=U08tpeGZrYEX6L4IjplX_AzSnHLlBhkRoNSf4Pskst0,22094
9
- docling_ocr_onnxtr-0.1.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
10
- docling_ocr_onnxtr-0.1.3.dist-info/entry_points.txt,sha256=4bUh15gjHVjgG1_vEtZgZ0Kyo7ygkWeAugc_W-EtSfo,57
11
- docling_ocr_onnxtr-0.1.3.dist-info/top_level.txt,sha256=vmOD5JYg8FKSI-iXyYH73_9AwJdxPOP1TsSY1nDp5iE,24
12
- docling_ocr_onnxtr-0.1.3.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
13
- docling_ocr_onnxtr-0.1.3.dist-info/RECORD,,