deepdoctection 0.38__tar.gz → 0.39.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.
Potentially problematic release.
This version of deepdoctection might be problematic. Click here for more details.
- {deepdoctection-0.38 → deepdoctection-0.39.1}/PKG-INFO +8 -8
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/__init__.py +5 -1
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/analyzer/dd.py +6 -5
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/analyzer/factory.py +7 -2
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/datapoint/convert.py +14 -8
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/datapoint/image.py +1 -1
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/datapoint/view.py +34 -24
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/extern/model.py +6 -97
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/mapper/cats.py +21 -10
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/mapper/match.py +0 -22
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/mapper/misc.py +12 -2
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/mapper/pubstruct.py +1 -1
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/pipe/base.py +38 -5
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/pipe/common.py +3 -3
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/pipe/doctectionpipe.py +20 -3
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/pipe/lm.py +20 -5
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/pipe/segment.py +4 -8
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/train/hf_detr_train.py +1 -1
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/train/hf_layoutlm_train.py +3 -1
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/utils/pdf_utils.py +17 -9
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection.egg-info/PKG-INFO +8 -8
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection.egg-info/requires.txt +7 -7
- {deepdoctection-0.38 → deepdoctection-0.39.1}/setup.py +5 -4
- {deepdoctection-0.38 → deepdoctection-0.39.1}/LICENSE +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/README.md +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/analyzer/__init__.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/analyzer/_config.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/configs/__init__.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/configs/conf_dd_one.yaml +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/configs/conf_tesseract.yaml +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/dataflow/__init__.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/dataflow/base.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/dataflow/common.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/dataflow/custom.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/dataflow/custom_serialize.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/dataflow/parallel_map.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/dataflow/serialize.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/dataflow/stats.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/datapoint/__init__.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/datapoint/annotation.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/datapoint/box.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/datasets/__init__.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/datasets/adapter.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/datasets/base.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/datasets/dataflow_builder.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/datasets/info.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/datasets/instances/__init__.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/datasets/instances/doclaynet.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/datasets/instances/fintabnet.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/datasets/instances/funsd.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/datasets/instances/iiitar13k.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/datasets/instances/layouttest.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/datasets/instances/publaynet.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/datasets/instances/pubtables1m.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/datasets/instances/pubtabnet.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/datasets/instances/rvlcdip.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/datasets/instances/xfund.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/datasets/instances/xsl/__init__.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/datasets/instances/xsl/pascal_voc.xsl +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/datasets/registry.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/datasets/save.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/eval/__init__.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/eval/accmetric.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/eval/base.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/eval/cocometric.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/eval/eval.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/eval/registry.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/eval/tedsmetric.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/eval/tp_eval_callback.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/extern/__init__.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/extern/base.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/extern/d2detect.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/extern/deskew.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/extern/doctrocr.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/extern/fastlang.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/extern/hfdetr.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/extern/hflayoutlm.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/extern/hflm.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/extern/pdftext.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/extern/pt/__init__.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/extern/pt/nms.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/extern/pt/ptutils.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/extern/tessocr.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/extern/texocr.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/extern/tp/__init__.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/extern/tp/tfutils.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/extern/tp/tpcompat.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/extern/tp/tpfrcnn/__init__.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/extern/tp/tpfrcnn/common.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/extern/tp/tpfrcnn/config/__init__.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/extern/tp/tpfrcnn/config/config.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/extern/tp/tpfrcnn/modeling/__init__.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/extern/tp/tpfrcnn/modeling/backbone.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/extern/tp/tpfrcnn/modeling/generalized_rcnn.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/extern/tp/tpfrcnn/modeling/model_box.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/extern/tp/tpfrcnn/modeling/model_cascade.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/extern/tp/tpfrcnn/modeling/model_fpn.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/extern/tp/tpfrcnn/modeling/model_frcnn.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/extern/tp/tpfrcnn/modeling/model_mrcnn.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/extern/tp/tpfrcnn/modeling/model_rpn.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/extern/tp/tpfrcnn/predict.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/extern/tp/tpfrcnn/preproc.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/extern/tp/tpfrcnn/utils/__init__.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/extern/tp/tpfrcnn/utils/box_ops.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/extern/tp/tpfrcnn/utils/np_box_ops.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/extern/tpdetect.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/mapper/__init__.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/mapper/cocostruct.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/mapper/d2struct.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/mapper/hfstruct.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/mapper/laylmstruct.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/mapper/maputils.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/mapper/pascalstruct.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/mapper/prodigystruct.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/mapper/tpstruct.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/mapper/xfundstruct.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/pipe/__init__.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/pipe/anngen.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/pipe/concurrency.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/pipe/language.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/pipe/layout.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/pipe/order.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/pipe/refine.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/pipe/registry.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/pipe/sub_layout.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/pipe/text.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/pipe/transform.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/py.typed +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/train/__init__.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/train/d2_frcnn_train.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/train/tp_frcnn_train.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/utils/__init__.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/utils/concurrency.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/utils/context.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/utils/develop.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/utils/env_info.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/utils/error.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/utils/file_utils.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/utils/fs.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/utils/identifier.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/utils/logger.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/utils/metacfg.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/utils/mocks.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/utils/settings.py +1 -1
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/utils/tqdm.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/utils/transform.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/utils/types.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/utils/utils.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection/utils/viz.py +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection.egg-info/SOURCES.txt +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection.egg-info/dependency_links.txt +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/deepdoctection.egg-info/top_level.txt +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/setup.cfg +0 -0
- {deepdoctection-0.38 → deepdoctection-0.39.1}/tests/test_utils.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: deepdoctection
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.39.1
|
|
4
4
|
Summary: Repository for Document AI
|
|
5
5
|
Home-page: https://github.com/deepdoctection/deepdoctection
|
|
6
6
|
Author: Dr. Janis Meyer
|
|
@@ -17,7 +17,7 @@ Requires-Python: >=3.9
|
|
|
17
17
|
Description-Content-Type: text/markdown
|
|
18
18
|
License-File: LICENSE
|
|
19
19
|
Requires-Dist: catalogue==2.0.10
|
|
20
|
-
Requires-Dist: huggingface_hub
|
|
20
|
+
Requires-Dist: huggingface_hub>=0.26.0
|
|
21
21
|
Requires-Dist: importlib-metadata>=5.0.0
|
|
22
22
|
Requires-Dist: jsonlines==3.1.0
|
|
23
23
|
Requires-Dist: lazy-imports==0.3.1
|
|
@@ -36,7 +36,7 @@ Requires-Dist: tabulate>=0.7.7
|
|
|
36
36
|
Requires-Dist: tqdm==4.64.0
|
|
37
37
|
Provides-Extra: tf
|
|
38
38
|
Requires-Dist: catalogue==2.0.10; extra == "tf"
|
|
39
|
-
Requires-Dist: huggingface_hub
|
|
39
|
+
Requires-Dist: huggingface_hub>=0.26.0; extra == "tf"
|
|
40
40
|
Requires-Dist: importlib-metadata>=5.0.0; extra == "tf"
|
|
41
41
|
Requires-Dist: jsonlines==3.1.0; extra == "tf"
|
|
42
42
|
Requires-Dist: lazy-imports==0.3.1; extra == "tf"
|
|
@@ -61,14 +61,14 @@ Requires-Dist: python-doctr==0.8.1; extra == "tf"
|
|
|
61
61
|
Requires-Dist: pycocotools>=2.0.2; extra == "tf"
|
|
62
62
|
Requires-Dist: boto3==1.34.102; extra == "tf"
|
|
63
63
|
Requires-Dist: pdfplumber>=0.11.0; extra == "tf"
|
|
64
|
-
Requires-Dist: fasttext
|
|
64
|
+
Requires-Dist: fasttext-wheel; extra == "tf"
|
|
65
65
|
Requires-Dist: jdeskew>=0.2.2; extra == "tf"
|
|
66
66
|
Requires-Dist: apted==1.0.3; extra == "tf"
|
|
67
67
|
Requires-Dist: distance==0.1.3; extra == "tf"
|
|
68
68
|
Requires-Dist: lxml>=4.9.1; extra == "tf"
|
|
69
69
|
Provides-Extra: pt
|
|
70
70
|
Requires-Dist: catalogue==2.0.10; extra == "pt"
|
|
71
|
-
Requires-Dist: huggingface_hub
|
|
71
|
+
Requires-Dist: huggingface_hub>=0.26.0; extra == "pt"
|
|
72
72
|
Requires-Dist: importlib-metadata>=5.0.0; extra == "pt"
|
|
73
73
|
Requires-Dist: jsonlines==3.1.0; extra == "pt"
|
|
74
74
|
Requires-Dist: lazy-imports==0.3.1; extra == "pt"
|
|
@@ -86,12 +86,12 @@ Requires-Dist: termcolor>=1.1; extra == "pt"
|
|
|
86
86
|
Requires-Dist: tabulate>=0.7.7; extra == "pt"
|
|
87
87
|
Requires-Dist: tqdm==4.64.0; extra == "pt"
|
|
88
88
|
Requires-Dist: timm>=0.9.16; extra == "pt"
|
|
89
|
-
Requires-Dist: transformers>=4.
|
|
89
|
+
Requires-Dist: transformers>=4.48.0; extra == "pt"
|
|
90
90
|
Requires-Dist: accelerate>=0.29.1; extra == "pt"
|
|
91
91
|
Requires-Dist: python-doctr==0.8.1; extra == "pt"
|
|
92
92
|
Requires-Dist: boto3==1.34.102; extra == "pt"
|
|
93
93
|
Requires-Dist: pdfplumber>=0.11.0; extra == "pt"
|
|
94
|
-
Requires-Dist: fasttext
|
|
94
|
+
Requires-Dist: fasttext-wheel; extra == "pt"
|
|
95
95
|
Requires-Dist: jdeskew>=0.2.2; extra == "pt"
|
|
96
96
|
Requires-Dist: apted==1.0.3; extra == "pt"
|
|
97
97
|
Requires-Dist: distance==0.1.3; extra == "pt"
|
|
@@ -99,7 +99,7 @@ Requires-Dist: lxml>=4.9.1; extra == "pt"
|
|
|
99
99
|
Provides-Extra: docs
|
|
100
100
|
Requires-Dist: tensorpack==0.11; extra == "docs"
|
|
101
101
|
Requires-Dist: boto3==1.34.102; extra == "docs"
|
|
102
|
-
Requires-Dist: transformers>=4.
|
|
102
|
+
Requires-Dist: transformers>=4.48.0; extra == "docs"
|
|
103
103
|
Requires-Dist: accelerate>=0.29.1; extra == "docs"
|
|
104
104
|
Requires-Dist: pdfplumber>=0.11.0; extra == "docs"
|
|
105
105
|
Requires-Dist: lxml>=4.9.1; extra == "docs"
|
|
@@ -6,6 +6,7 @@ Init file for deepdoctection package. This file is used to import all submodules
|
|
|
6
6
|
"""
|
|
7
7
|
|
|
8
8
|
import importlib.util
|
|
9
|
+
import os
|
|
9
10
|
|
|
10
11
|
# Before doing anything else, check if the .env file exists and load it
|
|
11
12
|
if importlib.util.find_spec("dotenv") is not None:
|
|
@@ -24,7 +25,7 @@ from .utils.logger import LoggingRecord, logger
|
|
|
24
25
|
|
|
25
26
|
# pylint: enable=wrong-import-position
|
|
26
27
|
|
|
27
|
-
__version__ = "0.
|
|
28
|
+
__version__ = "0.39.1"
|
|
28
29
|
|
|
29
30
|
_IMPORT_STRUCTURE = {
|
|
30
31
|
"analyzer": ["config_sanity_checks", "get_dd_analyzer", "ServiceFactory"],
|
|
@@ -423,6 +424,9 @@ _IMPORT_STRUCTURE = {
|
|
|
423
424
|
env_info = collect_env_info()
|
|
424
425
|
logger.debug(LoggingRecord(msg=env_info))
|
|
425
426
|
auto_select_pdf_render_framework()
|
|
427
|
+
os.environ["DPI"] = "300"
|
|
428
|
+
os.environ["IMAGE_WIDTH"] = ""
|
|
429
|
+
os.environ["IMAGE_HEIGHT"] = ""
|
|
426
430
|
|
|
427
431
|
# Direct imports for type-checking
|
|
428
432
|
if TYPE_CHECKING:
|
|
@@ -32,7 +32,6 @@ from ..extern.pt.ptutils import get_torch_device
|
|
|
32
32
|
from ..extern.tp.tfutils import disable_tp_layer_logging, get_tf_device
|
|
33
33
|
from ..pipe.doctectionpipe import DoctectionPipe
|
|
34
34
|
from ..utils.env_info import ENV_VARS_TRUE
|
|
35
|
-
from ..utils.error import DependencyError
|
|
36
35
|
from ..utils.file_utils import tensorpack_available
|
|
37
36
|
from ..utils.fs import get_configs_dir_path, get_package_path, maybe_copy_config_to_cache
|
|
38
37
|
from ..utils.logger import LoggingRecord, logger
|
|
@@ -118,13 +117,15 @@ def get_dd_analyzer(
|
|
|
118
117
|
:return: A DoctectionPipe instance with given configs
|
|
119
118
|
"""
|
|
120
119
|
config_overwrite = [] if config_overwrite is None else config_overwrite
|
|
121
|
-
|
|
122
|
-
|
|
120
|
+
if os.environ.get("DD_USE_TF", "0") in ENV_VARS_TRUE:
|
|
121
|
+
lib = "TF"
|
|
123
122
|
device = get_tf_device()
|
|
124
|
-
elif
|
|
123
|
+
elif os.environ.get("DD_USE_TORCH", "0") in ENV_VARS_TRUE:
|
|
124
|
+
lib = "PT"
|
|
125
125
|
device = get_torch_device()
|
|
126
126
|
else:
|
|
127
|
-
|
|
127
|
+
lib = None
|
|
128
|
+
device = None
|
|
128
129
|
dd_one_config_path = maybe_copy_config_to_cache(
|
|
129
130
|
get_package_path(), get_configs_dir_path() / "dd", _DD_ONE, reset_config_file
|
|
130
131
|
)
|
|
@@ -48,6 +48,7 @@ from ..pipe.segment import PubtablesSegmentationService, TableSegmentationServic
|
|
|
48
48
|
from ..pipe.sub_layout import DetectResultGenerator, SubImageLayoutService
|
|
49
49
|
from ..pipe.text import TextExtractionService
|
|
50
50
|
from ..pipe.transform import SimpleTransformService
|
|
51
|
+
from ..utils.error import DependencyError
|
|
51
52
|
from ..utils.file_utils import detectron2_available
|
|
52
53
|
from ..utils.fs import get_configs_dir_path
|
|
53
54
|
from ..utils.metacfg import AttrDict
|
|
@@ -62,8 +63,6 @@ __all__ = [
|
|
|
62
63
|
"ServiceFactory",
|
|
63
64
|
]
|
|
64
65
|
|
|
65
|
-
# from ._config import cfg
|
|
66
|
-
|
|
67
66
|
|
|
68
67
|
class ServiceFactory:
|
|
69
68
|
"""
|
|
@@ -94,6 +93,8 @@ class ServiceFactory:
|
|
|
94
93
|
:param config: configuration object
|
|
95
94
|
:param mode: either `LAYOUT`,`CELL` or `ITEM`
|
|
96
95
|
"""
|
|
96
|
+
if config.LIB is None:
|
|
97
|
+
raise DependencyError("At least one of the env variables DD_USE_TF or DD_USE_TORCH must be set.")
|
|
97
98
|
weights = (
|
|
98
99
|
getattr(config.TF, mode).WEIGHTS
|
|
99
100
|
if config.LIB == "TF"
|
|
@@ -310,6 +311,8 @@ class ServiceFactory:
|
|
|
310
311
|
config_overwrite=[f"LANGUAGES={config.LANGUAGE}"] if config.LANGUAGE is not None else None,
|
|
311
312
|
)
|
|
312
313
|
if config.OCR.USE_DOCTR:
|
|
314
|
+
if config.LIB is None:
|
|
315
|
+
raise DependencyError("At least one of the env variables DD_USE_TF or DD_USE_TORCH must be set.")
|
|
313
316
|
weights = (
|
|
314
317
|
config.OCR.WEIGHTS.DOCTR_RECOGNITION.TF
|
|
315
318
|
if config.LIB == "TF"
|
|
@@ -353,6 +356,8 @@ class ServiceFactory:
|
|
|
353
356
|
:param config: configuration object
|
|
354
357
|
:return: DoctrTextlineDetector
|
|
355
358
|
"""
|
|
359
|
+
if config.LIB is None:
|
|
360
|
+
raise DependencyError("At least one of the env variables DD_USE_TF or DD_USE_TORCH must be set.")
|
|
356
361
|
weights = config.OCR.WEIGHTS.DOCTR_WORD.TF if config.LIB == "TF" else config.OCR.WEIGHTS.DOCTR_WORD.PT
|
|
357
362
|
weights_path = ModelDownloadManager.maybe_download_weights_and_configs(weights)
|
|
358
363
|
profile = ModelCatalog.get_profile(weights)
|
|
@@ -154,7 +154,9 @@ def convert_pdf_bytes_to_np_array(pdf_bytes: bytes, dpi: Optional[int] = None) -
|
|
|
154
154
|
return np_array.astype(uint8)
|
|
155
155
|
|
|
156
156
|
|
|
157
|
-
def convert_pdf_bytes_to_np_array_v2(
|
|
157
|
+
def convert_pdf_bytes_to_np_array_v2(
|
|
158
|
+
pdf_bytes: bytes, dpi: Optional[int] = None, width: Optional[int] = None, height: Optional[int] = None
|
|
159
|
+
) -> PixelValues:
|
|
158
160
|
"""
|
|
159
161
|
Converts a pdf passed as bytes into a numpy array. We use poppler or pdfmium to convert the pdf to an image.
|
|
160
162
|
If both is available you can steer the selection of the render engine with environment variables:
|
|
@@ -165,17 +167,21 @@ def convert_pdf_bytes_to_np_array_v2(pdf_bytes: bytes, dpi: Optional[int] = 200)
|
|
|
165
167
|
:param pdf_bytes: A pdf as bytes object. A byte representation can from a pdf file can be generated e.g. with
|
|
166
168
|
`utils.fs.load_bytes_from_pdf_file`
|
|
167
169
|
:param dpi: The dpi value of the resulting output image. For high resolution set dpi=300.
|
|
170
|
+
:param width: The width of the resulting output image. This option does only work when using Poppler as
|
|
171
|
+
PDF renderer
|
|
172
|
+
:param height: The height of the resulting output image. This option does only work when using Poppler as
|
|
173
|
+
PDF renderer
|
|
168
174
|
:return: Image as numpy array.
|
|
169
175
|
"""
|
|
170
176
|
|
|
171
|
-
with BytesIO(pdf_bytes) as pdf_file:
|
|
172
|
-
pdf = PdfReader(pdf_file).pages[0]
|
|
173
|
-
shape = pdf.mediabox # pylint: disable=E1101
|
|
174
|
-
height = shape[3] - shape[1]
|
|
175
|
-
width = shape[2] - shape[0]
|
|
176
|
-
|
|
177
177
|
if dpi is None:
|
|
178
|
-
|
|
178
|
+
if width is None or height is None:
|
|
179
|
+
with BytesIO(pdf_bytes) as pdf_file:
|
|
180
|
+
pdf = PdfReader(pdf_file).pages[0]
|
|
181
|
+
shape = pdf.mediabox # pylint: disable=E1101
|
|
182
|
+
height = shape[3] - shape[1]
|
|
183
|
+
width = shape[2] - shape[0]
|
|
184
|
+
return pdf_to_np_array(pdf_bytes, size=(int(width), int(height))) # type: ignore
|
|
179
185
|
return pdf_to_np_array(pdf_bytes, dpi=dpi)
|
|
180
186
|
|
|
181
187
|
|
|
@@ -153,7 +153,7 @@ class Image:
|
|
|
153
153
|
self.set_width_height(self._image.shape[1], self._image.shape[0])
|
|
154
154
|
self._self_embedding()
|
|
155
155
|
elif isinstance(image, bytes):
|
|
156
|
-
self._image = convert_pdf_bytes_to_np_array_v2(image, dpi=environ
|
|
156
|
+
self._image = convert_pdf_bytes_to_np_array_v2(image, dpi=int(environ["DPI"]))
|
|
157
157
|
self.set_width_height(self._image.shape[1], self._image.shape[0])
|
|
158
158
|
self._self_embedding()
|
|
159
159
|
else:
|
|
@@ -228,23 +228,33 @@ class Layout(ImageAnnotationBaseView):
|
|
|
228
228
|
|
|
229
229
|
"""
|
|
230
230
|
words = self.get_ordered_words()
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
231
|
+
if words:
|
|
232
|
+
characters, ann_ids, token_classes, token_tags, token_classes_ids, token_tag_ids = zip(
|
|
233
|
+
*[
|
|
234
|
+
(
|
|
235
|
+
word.characters,
|
|
236
|
+
word.annotation_id,
|
|
237
|
+
word.token_class,
|
|
238
|
+
word.token_tag,
|
|
239
|
+
word.get_sub_category(WordType.TOKEN_CLASS).category_id
|
|
240
|
+
if WordType.TOKEN_CLASS in word.sub_categories
|
|
241
|
+
else None,
|
|
242
|
+
word.get_sub_category(WordType.TOKEN_TAG).category_id
|
|
243
|
+
if WordType.TOKEN_TAG in word.sub_categories
|
|
244
|
+
else None,
|
|
245
|
+
)
|
|
246
|
+
for word in words
|
|
247
|
+
]
|
|
248
|
+
)
|
|
249
|
+
else:
|
|
250
|
+
characters, ann_ids, token_classes, token_tags, token_classes_ids, token_tag_ids = (
|
|
251
|
+
[], # type: ignore
|
|
252
|
+
[], # type: ignore
|
|
253
|
+
[], # type: ignore
|
|
254
|
+
[], # type: ignore
|
|
255
|
+
[], # type: ignore
|
|
256
|
+
[], # type: ignore
|
|
257
|
+
)
|
|
248
258
|
return {
|
|
249
259
|
"text": " ".join(characters),
|
|
250
260
|
"words": characters,
|
|
@@ -327,7 +337,7 @@ class Table(Layout):
|
|
|
327
337
|
:return: A list of `Cell` objects that are row headers.
|
|
328
338
|
"""
|
|
329
339
|
all_relation_ids = self.get_relationship(Relationships.CHILD)
|
|
330
|
-
all_cells: list[Cell] = self.base_page.get_annotation(
|
|
340
|
+
all_cells: list[Cell] = self.base_page.get_annotation( # type: ignore
|
|
331
341
|
category_names=[LayoutType.CELL, CellType.SPANNING], annotation_ids=all_relation_ids
|
|
332
342
|
)
|
|
333
343
|
row_header_cells = list(filter(lambda cell: CellType.ROW_HEADER in cell.sub_categories, all_cells))
|
|
@@ -363,18 +373,18 @@ class Table(Layout):
|
|
|
363
373
|
category_names=[LayoutType.CELL, CellType.SPANNING], annotation_ids=all_relation_ids
|
|
364
374
|
)
|
|
365
375
|
row_cells = list(
|
|
366
|
-
filter(
|
|
367
|
-
lambda c: row_number in (c.row_number, c.row_number + c.row_span), all_cells # type: ignore
|
|
368
|
-
)
|
|
376
|
+
filter(lambda c: row_number in (c.row_number, c.row_number + c.row_span), all_cells) # type: ignore
|
|
369
377
|
)
|
|
370
|
-
row_cells.sort(key=lambda c: c.column_number)
|
|
378
|
+
row_cells.sort(key=lambda c: c.column_number) # type: ignore
|
|
371
379
|
column_header_cells = self.column_header_cells
|
|
372
380
|
|
|
373
381
|
kv_dict: Mapping[str, str] = {}
|
|
374
382
|
for cell in row_cells:
|
|
375
383
|
for header in column_header_cells:
|
|
376
|
-
if (
|
|
377
|
-
|
|
384
|
+
if (
|
|
385
|
+
cell.column_number == header.column_number # type: ignore
|
|
386
|
+
and cell.annotation_id != header.annotation_id # type: ignore
|
|
387
|
+
):
|
|
378
388
|
kv_dict[(header.column_number, header.text)] = cell.text # type: ignore
|
|
379
389
|
break
|
|
380
390
|
return kv_dict
|
|
@@ -24,7 +24,7 @@ from dataclasses import asdict, dataclass, field
|
|
|
24
24
|
from typing import Any, Mapping, Optional, Union
|
|
25
25
|
|
|
26
26
|
import jsonlines
|
|
27
|
-
from huggingface_hub import
|
|
27
|
+
from huggingface_hub import hf_hub_download
|
|
28
28
|
from tabulate import tabulate
|
|
29
29
|
from termcolor import colored
|
|
30
30
|
|
|
@@ -136,51 +136,6 @@ class ModelCatalog:
|
|
|
136
136
|
dl_library="TF",
|
|
137
137
|
model_wrapper="TPFrcnnDetector",
|
|
138
138
|
),
|
|
139
|
-
"item/model-1620000.data-00000-of-00001": ModelProfile(
|
|
140
|
-
name="item/model-1620000.data-00000-of-00001",
|
|
141
|
-
description="Tensorpack row/column detection model trained on Pubtabnet",
|
|
142
|
-
config="dd/tp/conf_frcnn_rows.yaml",
|
|
143
|
-
size=[823546048, 25787],
|
|
144
|
-
tp_model=True,
|
|
145
|
-
hf_repo_id="deepdoctection/tp_casc_rcnn_X_32xd4_50_FPN_GN_2FC_pubtabnet_rc",
|
|
146
|
-
hf_model_name="model-1620000",
|
|
147
|
-
hf_config_file=["conf_frcnn_rows.yaml"],
|
|
148
|
-
categories={1: LayoutType.ROW, 2: LayoutType.COLUMN},
|
|
149
|
-
dl_library="TF",
|
|
150
|
-
model_wrapper="TPFrcnnDetector",
|
|
151
|
-
),
|
|
152
|
-
"layout/model-800000.data-00000-of-00001": ModelProfile(
|
|
153
|
-
name="layout/model-800000.data-00000-of-00001",
|
|
154
|
-
description="Tensorpack layout detection model trained on Publaynet",
|
|
155
|
-
config="dd/tp/conf_frcnn_layout.yaml",
|
|
156
|
-
size=[823656748, 25796],
|
|
157
|
-
tp_model=True,
|
|
158
|
-
hf_repo_id="deepdoctection/tp_casc_rcnn_X_32xd4_50_FPN_GN_2FC_publaynet",
|
|
159
|
-
hf_model_name="model-800000",
|
|
160
|
-
hf_config_file=["conf_frcnn_layout.yaml"],
|
|
161
|
-
dl_library="TF",
|
|
162
|
-
categories={
|
|
163
|
-
1: LayoutType.TEXT,
|
|
164
|
-
2: LayoutType.TITLE,
|
|
165
|
-
3: LayoutType.LIST,
|
|
166
|
-
4: LayoutType.TABLE,
|
|
167
|
-
5: LayoutType.FIGURE,
|
|
168
|
-
},
|
|
169
|
-
model_wrapper="TPFrcnnDetector",
|
|
170
|
-
),
|
|
171
|
-
"cell/model-1800000.data-00000-of-00001": ModelProfile(
|
|
172
|
-
name="cell/model-1800000.data-00000-of-00001",
|
|
173
|
-
description="Tensorpack cell detection model trained on Pubtabnet",
|
|
174
|
-
config="dd/tp/conf_frcnn_cell.yaml",
|
|
175
|
-
size=[823509160, 25905],
|
|
176
|
-
tp_model=True,
|
|
177
|
-
hf_repo_id="deepdoctection/tp_casc_rcnn_X_32xd4_50_FPN_GN_2FC_pubtabnet_c",
|
|
178
|
-
hf_model_name="model-1800000",
|
|
179
|
-
hf_config_file=["conf_frcnn_cell.yaml"],
|
|
180
|
-
categories={1: LayoutType.CELL},
|
|
181
|
-
dl_library="TF",
|
|
182
|
-
model_wrapper="TPFrcnnDetector",
|
|
183
|
-
),
|
|
184
139
|
"layout/d2_model_0829999_layout_inf_only.pt": ModelProfile(
|
|
185
140
|
name="layout/d2_model_0829999_layout_inf_only.pt",
|
|
186
141
|
description="Detectron2 layout detection model trained on Publaynet",
|
|
@@ -200,25 +155,6 @@ class ModelCatalog:
|
|
|
200
155
|
dl_library="PT",
|
|
201
156
|
model_wrapper="D2FrcnnDetector",
|
|
202
157
|
),
|
|
203
|
-
"layout/d2_model_0829999_layout.pth": ModelProfile(
|
|
204
|
-
name="layout/d2_model_0829999_layout.pth",
|
|
205
|
-
description="Detectron2 layout detection model trained on Publaynet. Checkpoint for resuming training",
|
|
206
|
-
config="dd/d2/layout/CASCADE_RCNN_R_50_FPN_GN.yaml",
|
|
207
|
-
size=[548377327],
|
|
208
|
-
tp_model=False,
|
|
209
|
-
hf_repo_id="deepdoctection/d2_casc_rcnn_X_32xd4_50_FPN_GN_2FC_publaynet_inference_only",
|
|
210
|
-
hf_model_name="d2_model_0829999_layout.pth",
|
|
211
|
-
hf_config_file=["Base-RCNN-FPN.yaml", "CASCADE_RCNN_R_50_FPN_GN.yaml"],
|
|
212
|
-
categories={
|
|
213
|
-
1: LayoutType.TEXT,
|
|
214
|
-
2: LayoutType.TITLE,
|
|
215
|
-
3: LayoutType.LIST,
|
|
216
|
-
4: LayoutType.TABLE,
|
|
217
|
-
5: LayoutType.FIGURE,
|
|
218
|
-
},
|
|
219
|
-
dl_library="PT",
|
|
220
|
-
model_wrapper="D2FrcnnDetector",
|
|
221
|
-
),
|
|
222
158
|
"layout/d2_model_0829999_layout_inf_only.ts": ModelProfile(
|
|
223
159
|
name="layout/d2_model_0829999_layout_inf_only.ts",
|
|
224
160
|
description="Detectron2 layout detection model trained on Publaynet. Torchscript export",
|
|
@@ -264,32 +200,6 @@ class ModelCatalog:
|
|
|
264
200
|
dl_library="PT",
|
|
265
201
|
model_wrapper="D2FrcnnTracingDetector",
|
|
266
202
|
),
|
|
267
|
-
"cell/d2_model_1849999_cell.pth": ModelProfile(
|
|
268
|
-
name="cell/d2_model_1849999_cell.pth",
|
|
269
|
-
description="Detectron2 cell detection inference only model trained on Pubtabnet",
|
|
270
|
-
config="dd/d2/cell/CASCADE_RCNN_R_50_FPN_GN.yaml",
|
|
271
|
-
size=[548279023],
|
|
272
|
-
tp_model=False,
|
|
273
|
-
hf_repo_id="deepdoctection/d2_casc_rcnn_X_32xd4_50_FPN_GN_2FC_pubtabnet_c_inference_only",
|
|
274
|
-
hf_model_name="cell/d2_model_1849999_cell.pth",
|
|
275
|
-
hf_config_file=["Base-RCNN-FPN.yaml", "CASCADE_RCNN_R_50_FPN_GN.yaml"],
|
|
276
|
-
categories={1: LayoutType.CELL},
|
|
277
|
-
dl_library="PT",
|
|
278
|
-
model_wrapper="D2FrcnnDetector",
|
|
279
|
-
),
|
|
280
|
-
"item/d2_model_1639999_item.pth": ModelProfile(
|
|
281
|
-
name="item/d2_model_1639999_item.pth",
|
|
282
|
-
description="Detectron2 item detection model trained on Pubtabnet",
|
|
283
|
-
config="dd/d2/item/CASCADE_RCNN_R_50_FPN_GN.yaml",
|
|
284
|
-
size=[548303599],
|
|
285
|
-
tp_model=False,
|
|
286
|
-
hf_repo_id="deepdoctection/d2_casc_rcnn_X_32xd4_50_FPN_GN_2FC_pubtabnet_rc_inference_only",
|
|
287
|
-
hf_model_name="d2_model_1639999_item.pth",
|
|
288
|
-
hf_config_file=["Base-RCNN-FPN.yaml", "CASCADE_RCNN_R_50_FPN_GN.yaml"],
|
|
289
|
-
categories={1: LayoutType.ROW, 2: LayoutType.COLUMN},
|
|
290
|
-
dl_library="PT",
|
|
291
|
-
model_wrapper="D2FrcnnDetector",
|
|
292
|
-
),
|
|
293
203
|
"item/d2_model_1639999_item_inf_only.pt": ModelProfile(
|
|
294
204
|
name="item/d2_model_1639999_item_inf_only.pt",
|
|
295
205
|
description="Detectron2 item detection model inference only trained on Pubtabnet",
|
|
@@ -1232,20 +1142,19 @@ class ModelDownloadManager:
|
|
|
1232
1142
|
def _load_from_hf_hub(
|
|
1233
1143
|
repo_id: str, file_name: str, cache_directory: PathLikeOrStr, force_download: bool = False
|
|
1234
1144
|
) -> int:
|
|
1235
|
-
url = hf_hub_url(repo_id=repo_id, filename=file_name)
|
|
1236
1145
|
token = os.environ.get("HF_CREDENTIALS", None)
|
|
1237
|
-
f_path =
|
|
1238
|
-
|
|
1239
|
-
|
|
1146
|
+
f_path = hf_hub_download(
|
|
1147
|
+
repo_id,
|
|
1148
|
+
file_name,
|
|
1149
|
+
local_dir=cache_directory, # type: ignore
|
|
1240
1150
|
force_filename=file_name,
|
|
1241
1151
|
force_download=force_download,
|
|
1242
1152
|
token=token,
|
|
1243
|
-
legacy_cache_layout=True,
|
|
1244
1153
|
)
|
|
1245
1154
|
if f_path:
|
|
1246
1155
|
stat_info = os.stat(f_path)
|
|
1247
1156
|
size = stat_info.st_size
|
|
1248
1157
|
|
|
1249
|
-
assert size > 0, f"Downloaded an empty file from {
|
|
1158
|
+
assert size > 0, f"Downloaded an empty file from {f_path}!"
|
|
1250
1159
|
return size
|
|
1251
1160
|
raise TypeError("Returned value from cached_download cannot be Null")
|
|
@@ -73,18 +73,21 @@ def re_assign_cat_ids(
|
|
|
73
73
|
Annotations that are not in the dictionary provided will be removed.
|
|
74
74
|
|
|
75
75
|
:param dp: Image
|
|
76
|
-
:param categories_dict_name_as_key: e.g. `{LayoutType.word:
|
|
76
|
+
:param categories_dict_name_as_key: e.g. `{LayoutType.word: 1}`
|
|
77
77
|
:param cat_to_sub_cat_mapping: e.g. `{<LayoutType.word>:
|
|
78
78
|
{<WordType.token_class>:
|
|
79
|
-
{<FundsFirstPage.
|
|
80
|
-
<FundsFirstPage.
|
|
81
|
-
<FundsFirstPage.
|
|
82
|
-
<FundsFirstPage.
|
|
83
|
-
<TokenClasses.
|
|
84
|
-
<WordType.
|
|
85
|
-
{<BioTag.
|
|
86
|
-
<BioTag.
|
|
87
|
-
<BioTag.
|
|
79
|
+
{<FundsFirstPage.REPORT_DATE>: 1,
|
|
80
|
+
<FundsFirstPage.REPORT_TYPE>: 2,
|
|
81
|
+
<FundsFirstPage.UMBRELLA>: 3,
|
|
82
|
+
<FundsFirstPage.FUND_NAME>: 4,
|
|
83
|
+
<TokenClasses.OTHER>: 5},
|
|
84
|
+
<WordType.TAG>:
|
|
85
|
+
{<BioTag.INSIDE>: 1,
|
|
86
|
+
<BioTag.OUTSIDE>: 2,
|
|
87
|
+
<BioTag.BEGIN>: 3}}}`
|
|
88
|
+
To re-assign the category ids of an image summary, use the key 'default_type' for the default category, e.g.
|
|
89
|
+
`{DefaultType.DEFAULT_TYPE: {<PageType.DOCUMENT_TYPE>: {<DocumentType.INVOICE>:1,
|
|
90
|
+
<DocumentType.BANK_STATEMENT>:2}}}`
|
|
88
91
|
:return: Image
|
|
89
92
|
"""
|
|
90
93
|
|
|
@@ -104,6 +107,14 @@ def re_assign_cat_ids(
|
|
|
104
107
|
sub_category = ann.get_sub_category(key)
|
|
105
108
|
sub_category.category_id = sub_cat_values_dict.get(sub_category.category_name, DEFAULT_CATEGORY_ID)
|
|
106
109
|
|
|
110
|
+
if cat_to_sub_cat_mapping:
|
|
111
|
+
if "default_type" in cat_to_sub_cat_mapping:
|
|
112
|
+
sub_cat_keys_to_sub_cat_values = cat_to_sub_cat_mapping[get_type("default_type")]
|
|
113
|
+
for key in sub_cat_keys_to_sub_cat_values:
|
|
114
|
+
sub_cat_values_dict = sub_cat_keys_to_sub_cat_values[key]
|
|
115
|
+
sub_category = dp.summary.get_sub_category(key)
|
|
116
|
+
sub_category.category_id = sub_cat_values_dict.get(sub_category.category_name, DEFAULT_CATEGORY_ID)
|
|
117
|
+
|
|
107
118
|
dp.remove(annotation_ids=ann_ids_to_remove)
|
|
108
119
|
|
|
109
120
|
return dp
|
|
@@ -101,17 +101,6 @@ def match_anns_by_intersection(
|
|
|
101
101
|
]
|
|
102
102
|
)
|
|
103
103
|
|
|
104
|
-
# second try, if ann has empty image
|
|
105
|
-
n_dim = child_ann_boxes.ndim
|
|
106
|
-
if n_dim != 2:
|
|
107
|
-
child_ann_boxes = np.array(
|
|
108
|
-
[
|
|
109
|
-
ann.bounding_box.transform(dp.width, dp.height, absolute_coords=True).to_list(mode="xyxy")
|
|
110
|
-
for ann in child_anns
|
|
111
|
-
if ann.bounding_box is not None
|
|
112
|
-
]
|
|
113
|
-
)
|
|
114
|
-
|
|
115
104
|
parent_anns = dp.get_annotation(annotation_ids=parent_ann_ids, category_names=parent_ann_category_names)
|
|
116
105
|
parent_ann_boxes = np.array(
|
|
117
106
|
[
|
|
@@ -120,17 +109,6 @@ def match_anns_by_intersection(
|
|
|
120
109
|
]
|
|
121
110
|
)
|
|
122
111
|
|
|
123
|
-
# same for parent
|
|
124
|
-
n_dim = parent_ann_boxes.ndim
|
|
125
|
-
if n_dim != 2:
|
|
126
|
-
parent_ann_boxes = np.array(
|
|
127
|
-
[
|
|
128
|
-
ann.bounding_box.transform(dp.width, dp.height, absolute_coords=True).to_list(mode="xyxy")
|
|
129
|
-
for ann in parent_anns
|
|
130
|
-
if ann.bounding_box is not None
|
|
131
|
-
]
|
|
132
|
-
)
|
|
133
|
-
|
|
134
112
|
if matching_rule in ["iou"] and parent_anns and child_anns:
|
|
135
113
|
iou_matrix = iou(child_ann_boxes, parent_ann_boxes)
|
|
136
114
|
output = iou_matrix > threshold
|
|
@@ -38,12 +38,20 @@ with try_import() as import_guard:
|
|
|
38
38
|
from lxml import etree # pylint: disable=W0611
|
|
39
39
|
|
|
40
40
|
|
|
41
|
-
def to_image(
|
|
41
|
+
def to_image(
|
|
42
|
+
dp: Union[str, Mapping[str, Union[str, bytes]]],
|
|
43
|
+
dpi: Optional[int] = None,
|
|
44
|
+
width: Optional[int] = None,
|
|
45
|
+
height: Optional[int] = None,
|
|
46
|
+
) -> Optional[Image]:
|
|
42
47
|
"""
|
|
43
48
|
Mapping an input from `dataflow.SerializerFiles` or similar to an Image
|
|
44
49
|
|
|
45
50
|
:param dp: Image
|
|
46
51
|
:param dpi: dot per inch definition for pdf resolution when converting to numpy array
|
|
52
|
+
:param width: target width of the image. This option does only work when using Poppler as PDF renderer
|
|
53
|
+
:param height: target width of the image. This option does only work when using Poppler as PDF renderer
|
|
54
|
+
:param height: target height of the image
|
|
47
55
|
:return: Image
|
|
48
56
|
"""
|
|
49
57
|
|
|
@@ -77,7 +85,9 @@ def to_image(dp: Union[str, Mapping[str, Union[str, bytes]]], dpi: Optional[int]
|
|
|
77
85
|
dp_image.pdf_bytes = dp.get("pdf_bytes")
|
|
78
86
|
if dp_image.pdf_bytes is not None:
|
|
79
87
|
if isinstance(dp_image.pdf_bytes, bytes):
|
|
80
|
-
dp_image.image = convert_pdf_bytes_to_np_array_v2(
|
|
88
|
+
dp_image.image = convert_pdf_bytes_to_np_array_v2(
|
|
89
|
+
dp_image.pdf_bytes, dpi=dpi, width=width, height=height
|
|
90
|
+
)
|
|
81
91
|
elif image_bytes is not None:
|
|
82
92
|
dp_image.image = convert_bytes_to_np_array(image_bytes)
|
|
83
93
|
else:
|
|
@@ -393,7 +393,7 @@ def pub_to_image_uncur( # pylint: disable=R0914
|
|
|
393
393
|
np_image = load_image_from_file(dp["filename"])
|
|
394
394
|
if is_file_extension(dp["filename"], ".pdf"):
|
|
395
395
|
pdf_bytes = load_bytes_from_pdf_file(dp["filename"])
|
|
396
|
-
np_image = convert_pdf_bytes_to_np_array_v2(pdf_bytes)
|
|
396
|
+
np_image = convert_pdf_bytes_to_np_array_v2(pdf_bytes, dpi=200)
|
|
397
397
|
dp = _convert_boxes(dp, np_image.shape[0])
|
|
398
398
|
|
|
399
399
|
if load_image and np_image is not None:
|