python-doctr 1.0.0__tar.gz → 1.0.1__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.
- {python_doctr-1.0.0 → python_doctr-1.0.1}/PKG-INFO +13 -6
- {python_doctr-1.0.0 → python_doctr-1.0.1}/README.md +8 -1
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/contrib/artefacts.py +1 -1
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/contrib/base.py +1 -1
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/datasets/coco_text.py +1 -1
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/datasets/cord.py +1 -1
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/datasets/datasets/base.py +1 -1
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/datasets/datasets/pytorch.py +1 -1
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/datasets/detection.py +1 -1
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/datasets/doc_artefacts.py +1 -1
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/datasets/funsd.py +1 -1
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/datasets/generator/base.py +1 -1
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/datasets/generator/pytorch.py +1 -1
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/datasets/ic03.py +1 -1
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/datasets/ic13.py +1 -1
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/datasets/iiit5k.py +1 -1
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/datasets/iiithws.py +1 -1
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/datasets/imgur5k.py +1 -1
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/datasets/mjsynth.py +1 -1
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/datasets/ocr.py +1 -1
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/datasets/orientation.py +1 -1
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/datasets/recognition.py +1 -1
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/datasets/sroie.py +1 -1
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/datasets/svhn.py +1 -1
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/datasets/svt.py +1 -1
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/datasets/synthtext.py +1 -1
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/datasets/utils.py +1 -1
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/datasets/vocabs.py +1 -1
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/datasets/wildreceipt.py +1 -1
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/file_utils.py +1 -1
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/io/elements.py +1 -1
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/io/html.py +1 -1
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/io/image/base.py +1 -1
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/io/image/pytorch.py +1 -1
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/io/pdf.py +1 -1
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/io/reader.py +1 -1
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/models/_utils.py +55 -17
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/models/builder.py +1 -1
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/models/classification/magc_resnet/pytorch.py +1 -1
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/models/classification/mobilenet/pytorch.py +1 -1
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/models/classification/predictor/pytorch.py +1 -1
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/models/classification/resnet/pytorch.py +1 -1
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/models/classification/textnet/pytorch.py +1 -1
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/models/classification/vgg/pytorch.py +1 -1
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/models/classification/vip/layers/pytorch.py +1 -1
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/models/classification/vip/pytorch.py +1 -1
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/models/classification/vit/pytorch.py +1 -1
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/models/classification/zoo.py +1 -1
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/models/core.py +1 -1
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/models/detection/_utils/base.py +1 -1
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/models/detection/_utils/pytorch.py +1 -1
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/models/detection/core.py +1 -1
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/models/detection/differentiable_binarization/base.py +1 -1
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/models/detection/differentiable_binarization/pytorch.py +1 -1
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/models/detection/fast/base.py +1 -1
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/models/detection/fast/pytorch.py +1 -1
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/models/detection/linknet/base.py +1 -1
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/models/detection/linknet/pytorch.py +1 -1
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/models/detection/predictor/pytorch.py +1 -1
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/models/detection/zoo.py +1 -1
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/models/factory/hub.py +18 -13
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/models/kie_predictor/base.py +1 -1
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/models/kie_predictor/pytorch.py +1 -1
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/models/modules/layers/pytorch.py +1 -1
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/models/modules/transformer/pytorch.py +1 -1
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/models/modules/vision_transformer/pytorch.py +1 -1
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/models/predictor/base.py +1 -1
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/models/predictor/pytorch.py +1 -1
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/models/preprocessor/pytorch.py +1 -1
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/models/recognition/core.py +1 -1
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/models/recognition/crnn/pytorch.py +1 -1
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/models/recognition/master/base.py +1 -1
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/models/recognition/master/pytorch.py +1 -1
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/models/recognition/parseq/base.py +1 -1
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/models/recognition/parseq/pytorch.py +1 -1
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/models/recognition/predictor/_utils.py +1 -1
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/models/recognition/predictor/pytorch.py +1 -1
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/models/recognition/sar/pytorch.py +1 -1
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/models/recognition/utils.py +1 -1
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/models/recognition/viptr/pytorch.py +1 -1
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/models/recognition/vitstr/base.py +1 -1
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/models/recognition/vitstr/pytorch.py +1 -1
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/models/recognition/zoo.py +1 -1
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/models/utils/pytorch.py +2 -1
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/models/zoo.py +1 -1
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/transforms/functional/base.py +3 -2
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/transforms/functional/pytorch.py +1 -1
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/transforms/modules/base.py +2 -2
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/transforms/modules/pytorch.py +1 -1
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/utils/common_types.py +1 -1
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/utils/data.py +1 -2
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/utils/fonts.py +1 -1
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/utils/geometry.py +1 -1
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/utils/metrics.py +1 -1
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/utils/multithreading.py +1 -1
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/utils/reconstitution.py +1 -1
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/utils/repr.py +1 -1
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/utils/visualization.py +1 -1
- python_doctr-1.0.1/doctr/version.py +1 -0
- {python_doctr-1.0.0 → python_doctr-1.0.1}/pyproject.toml +4 -4
- {python_doctr-1.0.0 → python_doctr-1.0.1}/python_doctr.egg-info/PKG-INFO +13 -6
- {python_doctr-1.0.0 → python_doctr-1.0.1}/python_doctr.egg-info/requires.txt +4 -4
- {python_doctr-1.0.0 → python_doctr-1.0.1}/setup.py +2 -2
- python_doctr-1.0.0/doctr/version.py +0 -1
- {python_doctr-1.0.0 → python_doctr-1.0.1}/LICENSE +0 -0
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/__init__.py +0 -0
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/contrib/__init__.py +0 -0
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/datasets/__init__.py +0 -0
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/datasets/datasets/__init__.py +0 -0
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/datasets/generator/__init__.py +0 -0
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/io/__init__.py +0 -0
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/io/image/__init__.py +0 -0
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/models/__init__.py +0 -0
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/models/classification/__init__.py +0 -0
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/models/classification/magc_resnet/__init__.py +0 -0
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/models/classification/mobilenet/__init__.py +0 -0
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/models/classification/predictor/__init__.py +0 -0
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/models/classification/resnet/__init__.py +0 -0
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/models/classification/textnet/__init__.py +0 -0
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/models/classification/vgg/__init__.py +0 -0
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/models/classification/vip/__init__.py +0 -0
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/models/classification/vip/layers/__init__.py +0 -0
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/models/classification/vit/__init__.py +0 -0
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/models/detection/__init__.py +0 -0
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/models/detection/_utils/__init__.py +0 -0
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/models/detection/differentiable_binarization/__init__.py +0 -0
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/models/detection/fast/__init__.py +0 -0
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/models/detection/linknet/__init__.py +0 -0
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/models/detection/predictor/__init__.py +0 -0
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/models/factory/__init__.py +0 -0
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/models/kie_predictor/__init__.py +0 -0
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/models/modules/__init__.py +0 -0
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/models/modules/layers/__init__.py +0 -0
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/models/modules/transformer/__init__.py +0 -0
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/models/modules/vision_transformer/__init__.py +0 -0
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/models/predictor/__init__.py +0 -0
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/models/preprocessor/__init__.py +0 -0
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/models/recognition/__init__.py +0 -0
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/models/recognition/crnn/__init__.py +0 -0
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/models/recognition/master/__init__.py +0 -0
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/models/recognition/parseq/__init__.py +0 -0
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/models/recognition/predictor/__init__.py +0 -0
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/models/recognition/sar/__init__.py +0 -0
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/models/recognition/viptr/__init__.py +0 -0
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/models/recognition/vitstr/__init__.py +0 -0
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/models/utils/__init__.py +0 -0
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/py.typed +0 -0
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/transforms/__init__.py +0 -0
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/transforms/functional/__init__.py +0 -0
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/transforms/modules/__init__.py +0 -0
- {python_doctr-1.0.0 → python_doctr-1.0.1}/doctr/utils/__init__.py +0 -0
- {python_doctr-1.0.0 → python_doctr-1.0.1}/python_doctr.egg-info/SOURCES.txt +0 -0
- {python_doctr-1.0.0 → python_doctr-1.0.1}/python_doctr.egg-info/dependency_links.txt +0 -0
- {python_doctr-1.0.0 → python_doctr-1.0.1}/python_doctr.egg-info/top_level.txt +0 -0
- {python_doctr-1.0.0 → python_doctr-1.0.1}/python_doctr.egg-info/zip-safe +0 -0
- {python_doctr-1.0.0 → python_doctr-1.0.1}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: python-doctr
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.1
|
|
4
4
|
Summary: Document Text Recognition (docTR): deep Learning for high-performance OCR on documents.
|
|
5
5
|
Author-email: Mindee <contact@mindee.com>
|
|
6
6
|
Maintainer: François-Guillaume Fernandez, Charles Gaillard, Olivier Dulcy, Felix Dittrich
|
|
@@ -233,12 +233,12 @@ Requires-Dist: numpy<3.0.0,>=1.16.0
|
|
|
233
233
|
Requires-Dist: scipy<2.0.0,>=1.4.0
|
|
234
234
|
Requires-Dist: h5py<4.0.0,>=3.1.0
|
|
235
235
|
Requires-Dist: opencv-python<5.0.0,>=4.5.0
|
|
236
|
-
Requires-Dist: pypdfium2<
|
|
236
|
+
Requires-Dist: pypdfium2<6.0.0,>=4.11.0
|
|
237
237
|
Requires-Dist: pyclipper<2.0.0,>=1.2.0
|
|
238
238
|
Requires-Dist: shapely<3.0.0,>=1.6.0
|
|
239
239
|
Requires-Dist: langdetect<2.0.0,>=1.0.9
|
|
240
240
|
Requires-Dist: rapidfuzz<4.0.0,>=3.0.0
|
|
241
|
-
Requires-Dist: huggingface-hub<
|
|
241
|
+
Requires-Dist: huggingface-hub<2.0.0,>=0.20.0
|
|
242
242
|
Requires-Dist: Pillow>=9.2.0
|
|
243
243
|
Requires-Dist: defusedxml>=0.7.0
|
|
244
244
|
Requires-Dist: anyascii>=0.3.2
|
|
@@ -265,7 +265,7 @@ Provides-Extra: docs
|
|
|
265
265
|
Requires-Dist: sphinx!=3.5.0,>=3.0.0; extra == "docs"
|
|
266
266
|
Requires-Dist: sphinxemoji>=0.1.8; extra == "docs"
|
|
267
267
|
Requires-Dist: sphinx-copybutton>=0.3.1; extra == "docs"
|
|
268
|
-
Requires-Dist: docutils<0.
|
|
268
|
+
Requires-Dist: docutils<0.23; extra == "docs"
|
|
269
269
|
Requires-Dist: recommonmark>=0.7.1; extra == "docs"
|
|
270
270
|
Requires-Dist: sphinx-markdown-tables>=0.0.15; extra == "docs"
|
|
271
271
|
Requires-Dist: sphinx-tabs>=3.3.0; extra == "docs"
|
|
@@ -288,7 +288,7 @@ Requires-Dist: pre-commit>=3.0.0; extra == "dev"
|
|
|
288
288
|
Requires-Dist: sphinx!=3.5.0,>=3.0.0; extra == "dev"
|
|
289
289
|
Requires-Dist: sphinxemoji>=0.1.8; extra == "dev"
|
|
290
290
|
Requires-Dist: sphinx-copybutton>=0.3.1; extra == "dev"
|
|
291
|
-
Requires-Dist: docutils<0.
|
|
291
|
+
Requires-Dist: docutils<0.23; extra == "dev"
|
|
292
292
|
Requires-Dist: recommonmark>=0.7.1; extra == "dev"
|
|
293
293
|
Requires-Dist: sphinx-markdown-tables>=0.0.15; extra == "dev"
|
|
294
294
|
Requires-Dist: sphinx-tabs>=3.3.0; extra == "dev"
|
|
@@ -361,7 +361,7 @@ Should you use docTR on documents that include rotated pages, or pages with mult
|
|
|
361
361
|
you have multiple options to handle it:
|
|
362
362
|
|
|
363
363
|
- If you only use straight document pages with straight words (horizontal, same reading direction),
|
|
364
|
-
consider passing `
|
|
364
|
+
consider passing `assume_straight_pages=True` to the ocr_predictor. It will directly fit straight boxes
|
|
365
365
|
on your page and return straight boxes, which makes it the fastest option.
|
|
366
366
|
|
|
367
367
|
- If you want the predictor to output straight boxes (no matter the orientation of your pages, the final localizations
|
|
@@ -621,6 +621,13 @@ print(requests.post("http://localhost:8080/ocr", params=params, files=files).jso
|
|
|
621
621
|
|
|
622
622
|
Looking for more illustrations of docTR features? You might want to check the [Jupyter notebooks](https://github.com/mindee/doctr/tree/main/notebooks) designed to give you a broader overview.
|
|
623
623
|
|
|
624
|
+
## Supported By
|
|
625
|
+
|
|
626
|
+
This project is supported by [t2k GmbH](https://www.text2knowledge.de/de),
|
|
627
|
+
<p align="center">
|
|
628
|
+
<img src="https://github.com/mindee/doctr/raw/main/docs/images/t2k_logo.png" width="40%">
|
|
629
|
+
</p>
|
|
630
|
+
|
|
624
631
|
## Citation
|
|
625
632
|
|
|
626
633
|
If you wish to cite this project, feel free to use this [BibTeX](http://www.bibtex.org/) reference:
|
|
@@ -64,7 +64,7 @@ Should you use docTR on documents that include rotated pages, or pages with mult
|
|
|
64
64
|
you have multiple options to handle it:
|
|
65
65
|
|
|
66
66
|
- If you only use straight document pages with straight words (horizontal, same reading direction),
|
|
67
|
-
consider passing `
|
|
67
|
+
consider passing `assume_straight_pages=True` to the ocr_predictor. It will directly fit straight boxes
|
|
68
68
|
on your page and return straight boxes, which makes it the fastest option.
|
|
69
69
|
|
|
70
70
|
- If you want the predictor to output straight boxes (no matter the orientation of your pages, the final localizations
|
|
@@ -324,6 +324,13 @@ print(requests.post("http://localhost:8080/ocr", params=params, files=files).jso
|
|
|
324
324
|
|
|
325
325
|
Looking for more illustrations of docTR features? You might want to check the [Jupyter notebooks](https://github.com/mindee/doctr/tree/main/notebooks) designed to give you a broader overview.
|
|
326
326
|
|
|
327
|
+
## Supported By
|
|
328
|
+
|
|
329
|
+
This project is supported by [t2k GmbH](https://www.text2knowledge.de/de),
|
|
330
|
+
<p align="center">
|
|
331
|
+
<img src="https://github.com/mindee/doctr/raw/main/docs/images/t2k_logo.png" width="40%">
|
|
332
|
+
</p>
|
|
333
|
+
|
|
327
334
|
## Citation
|
|
328
335
|
|
|
329
336
|
If you wish to cite this project, feel free to use this [BibTeX](http://www.bibtex.org/) reference:
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Copyright (C) 2021-
|
|
1
|
+
# Copyright (C) 2021-2026, Mindee.
|
|
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.
|
|
@@ -26,6 +26,8 @@ def get_max_width_length_ratio(contour: np.ndarray) -> float:
|
|
|
26
26
|
the maximum shape ratio
|
|
27
27
|
"""
|
|
28
28
|
_, (w, h), _ = cv2.minAreaRect(contour)
|
|
29
|
+
if w == 0 or h == 0:
|
|
30
|
+
return 0.0
|
|
29
31
|
return max(w / h, h / w)
|
|
30
32
|
|
|
31
33
|
|
|
@@ -53,7 +55,7 @@ def estimate_orientation(
|
|
|
53
55
|
the estimated angle of the page (clockwise, negative for left side rotation, positive for right side rotation)
|
|
54
56
|
"""
|
|
55
57
|
assert len(img.shape) == 3 and img.shape[-1] in [1, 3], f"Image shape {img.shape} not supported"
|
|
56
|
-
|
|
58
|
+
|
|
57
59
|
# Convert image to grayscale if necessary
|
|
58
60
|
if img.shape[-1] == 3:
|
|
59
61
|
gray_img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
|
|
@@ -62,11 +64,14 @@ def estimate_orientation(
|
|
|
62
64
|
else:
|
|
63
65
|
thresh = img.astype(np.uint8)
|
|
64
66
|
|
|
65
|
-
page_orientation, orientation_confidence = general_page_orientation or (
|
|
66
|
-
|
|
67
|
+
page_orientation, orientation_confidence = general_page_orientation or (0, 0.0)
|
|
68
|
+
is_confident = page_orientation is not None and orientation_confidence >= min_confidence
|
|
69
|
+
base_angle = page_orientation if is_confident else 0
|
|
70
|
+
|
|
71
|
+
if is_confident:
|
|
67
72
|
# We rotate the image to the general orientation which improves the detection
|
|
68
73
|
# No expand needed bitmap is already padded
|
|
69
|
-
thresh = rotate_image(thresh, -
|
|
74
|
+
thresh = rotate_image(thresh, -base_angle)
|
|
70
75
|
else: # That's only required if we do not work on the detection models bin map
|
|
71
76
|
# try to merge words in lines
|
|
72
77
|
(h, w) = img.shape[:2]
|
|
@@ -88,30 +93,63 @@ def estimate_orientation(
|
|
|
88
93
|
angles = []
|
|
89
94
|
for contour in contours[:n_ct]:
|
|
90
95
|
_, (w, h), angle = cv2.minAreaRect(contour)
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
96
|
+
|
|
97
|
+
# OpenCV version-proof normalization: force 'w' to be the long side
|
|
98
|
+
# so the angle is consistently relative to the major axis.
|
|
99
|
+
# https://github.com/opencv/opencv/pull/28051/changes
|
|
100
|
+
if w < h:
|
|
101
|
+
w, h = h, w
|
|
102
|
+
angle -= 90
|
|
103
|
+
|
|
104
|
+
# Normalize angle to be within [-90, 90]
|
|
105
|
+
while angle <= -90:
|
|
106
|
+
angle += 180
|
|
107
|
+
while angle > 90:
|
|
108
|
+
angle -= 180
|
|
109
|
+
|
|
110
|
+
if h > 0:
|
|
111
|
+
if w / h > ratio_threshold_for_lines: # select only contours with ratio like lines
|
|
112
|
+
angles.append(angle)
|
|
113
|
+
elif w / h < 1 / ratio_threshold_for_lines: # if lines are vertical, substract 90 degree
|
|
114
|
+
angles.append(angle - 90)
|
|
95
115
|
|
|
96
116
|
if len(angles) == 0:
|
|
97
|
-
|
|
117
|
+
skew_angle = 0 # in case no angles is found
|
|
98
118
|
else:
|
|
119
|
+
# median_low picks a value from the data to avoid outliers
|
|
99
120
|
median = -median_low(angles)
|
|
100
|
-
|
|
121
|
+
skew_angle = -round(median) if abs(median) != 0 else 0
|
|
122
|
+
|
|
123
|
+
# Resolve the 90-degree flip ambiguity.
|
|
124
|
+
# If the estimation is exactly 90/-90, it's usually a vertical detection of horizontal lines.
|
|
125
|
+
if abs(skew_angle) == 90:
|
|
126
|
+
skew_angle = 0
|
|
101
127
|
|
|
102
128
|
# combine with the general orientation and the estimated angle
|
|
103
|
-
|
|
129
|
+
# Apply the detected skew to our base orientation
|
|
130
|
+
final_angle = base_angle + skew_angle
|
|
131
|
+
|
|
132
|
+
# Standardize result to [-179, 180] range to handle wrap-around cases (e.g., 180 + -31)
|
|
133
|
+
while final_angle > 180:
|
|
134
|
+
final_angle -= 360
|
|
135
|
+
while final_angle <= -180:
|
|
136
|
+
final_angle += 360
|
|
137
|
+
|
|
138
|
+
if is_confident:
|
|
139
|
+
# If the estimated angle is perpendicular, treat it as 0 to avoid wrong flips
|
|
140
|
+
if abs(skew_angle) % 90 == 0:
|
|
141
|
+
return page_orientation
|
|
142
|
+
|
|
104
143
|
# special case where the estimated angle is mostly wrong:
|
|
105
144
|
# case 1: - and + swapped
|
|
106
145
|
# case 2: estimated angle is completely wrong
|
|
107
146
|
# so in this case we prefer the general page orientation
|
|
108
|
-
if abs(
|
|
147
|
+
if abs(skew_angle) == abs(page_orientation) and page_orientation != 0:
|
|
109
148
|
return page_orientation
|
|
110
|
-
estimated_angle = estimated_angle if page_orientation == 0 else page_orientation + estimated_angle
|
|
111
|
-
if estimated_angle > 180:
|
|
112
|
-
estimated_angle -= 360
|
|
113
149
|
|
|
114
|
-
return
|
|
150
|
+
return int(
|
|
151
|
+
final_angle
|
|
152
|
+
) # return the clockwise angle (negative - left side rotation, positive - right side rotation)
|
|
115
153
|
|
|
116
154
|
|
|
117
155
|
def rectify_crops(
|