deepdoctection 0.42.0__py3-none-any.whl → 0.43__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.

Potentially problematic release.


This version of deepdoctection might be problematic. Click here for more details.

Files changed (124) hide show
  1. deepdoctection/__init__.py +2 -1
  2. deepdoctection/analyzer/__init__.py +2 -1
  3. deepdoctection/analyzer/config.py +904 -0
  4. deepdoctection/analyzer/dd.py +36 -62
  5. deepdoctection/analyzer/factory.py +311 -141
  6. deepdoctection/configs/conf_dd_one.yaml +100 -44
  7. deepdoctection/configs/profiles.jsonl +32 -0
  8. deepdoctection/dataflow/__init__.py +9 -6
  9. deepdoctection/dataflow/base.py +33 -15
  10. deepdoctection/dataflow/common.py +96 -75
  11. deepdoctection/dataflow/custom.py +36 -29
  12. deepdoctection/dataflow/custom_serialize.py +135 -91
  13. deepdoctection/dataflow/parallel_map.py +33 -31
  14. deepdoctection/dataflow/serialize.py +15 -10
  15. deepdoctection/dataflow/stats.py +41 -28
  16. deepdoctection/datapoint/__init__.py +4 -6
  17. deepdoctection/datapoint/annotation.py +104 -66
  18. deepdoctection/datapoint/box.py +190 -130
  19. deepdoctection/datapoint/convert.py +66 -39
  20. deepdoctection/datapoint/image.py +151 -95
  21. deepdoctection/datapoint/view.py +383 -236
  22. deepdoctection/datasets/__init__.py +2 -6
  23. deepdoctection/datasets/adapter.py +11 -11
  24. deepdoctection/datasets/base.py +118 -81
  25. deepdoctection/datasets/dataflow_builder.py +18 -12
  26. deepdoctection/datasets/info.py +76 -57
  27. deepdoctection/datasets/instances/__init__.py +6 -2
  28. deepdoctection/datasets/instances/doclaynet.py +17 -14
  29. deepdoctection/datasets/instances/fintabnet.py +16 -22
  30. deepdoctection/datasets/instances/funsd.py +11 -6
  31. deepdoctection/datasets/instances/iiitar13k.py +9 -9
  32. deepdoctection/datasets/instances/layouttest.py +9 -9
  33. deepdoctection/datasets/instances/publaynet.py +9 -9
  34. deepdoctection/datasets/instances/pubtables1m.py +13 -13
  35. deepdoctection/datasets/instances/pubtabnet.py +13 -15
  36. deepdoctection/datasets/instances/rvlcdip.py +8 -8
  37. deepdoctection/datasets/instances/xfund.py +11 -9
  38. deepdoctection/datasets/registry.py +18 -11
  39. deepdoctection/datasets/save.py +12 -11
  40. deepdoctection/eval/__init__.py +3 -2
  41. deepdoctection/eval/accmetric.py +72 -52
  42. deepdoctection/eval/base.py +29 -10
  43. deepdoctection/eval/cocometric.py +14 -12
  44. deepdoctection/eval/eval.py +56 -41
  45. deepdoctection/eval/registry.py +6 -3
  46. deepdoctection/eval/tedsmetric.py +24 -9
  47. deepdoctection/eval/tp_eval_callback.py +13 -12
  48. deepdoctection/extern/__init__.py +1 -1
  49. deepdoctection/extern/base.py +176 -97
  50. deepdoctection/extern/d2detect.py +127 -92
  51. deepdoctection/extern/deskew.py +19 -10
  52. deepdoctection/extern/doctrocr.py +157 -106
  53. deepdoctection/extern/fastlang.py +25 -17
  54. deepdoctection/extern/hfdetr.py +137 -60
  55. deepdoctection/extern/hflayoutlm.py +329 -248
  56. deepdoctection/extern/hflm.py +67 -33
  57. deepdoctection/extern/model.py +108 -762
  58. deepdoctection/extern/pdftext.py +37 -12
  59. deepdoctection/extern/pt/nms.py +15 -1
  60. deepdoctection/extern/pt/ptutils.py +13 -9
  61. deepdoctection/extern/tessocr.py +87 -54
  62. deepdoctection/extern/texocr.py +29 -14
  63. deepdoctection/extern/tp/tfutils.py +36 -8
  64. deepdoctection/extern/tp/tpcompat.py +54 -16
  65. deepdoctection/extern/tp/tpfrcnn/config/config.py +20 -4
  66. deepdoctection/extern/tpdetect.py +4 -2
  67. deepdoctection/mapper/__init__.py +1 -1
  68. deepdoctection/mapper/cats.py +117 -76
  69. deepdoctection/mapper/cocostruct.py +35 -17
  70. deepdoctection/mapper/d2struct.py +56 -29
  71. deepdoctection/mapper/hfstruct.py +32 -19
  72. deepdoctection/mapper/laylmstruct.py +221 -185
  73. deepdoctection/mapper/maputils.py +71 -35
  74. deepdoctection/mapper/match.py +76 -62
  75. deepdoctection/mapper/misc.py +68 -44
  76. deepdoctection/mapper/pascalstruct.py +13 -12
  77. deepdoctection/mapper/prodigystruct.py +33 -19
  78. deepdoctection/mapper/pubstruct.py +42 -32
  79. deepdoctection/mapper/tpstruct.py +39 -19
  80. deepdoctection/mapper/xfundstruct.py +20 -13
  81. deepdoctection/pipe/__init__.py +1 -2
  82. deepdoctection/pipe/anngen.py +104 -62
  83. deepdoctection/pipe/base.py +226 -107
  84. deepdoctection/pipe/common.py +206 -123
  85. deepdoctection/pipe/concurrency.py +74 -47
  86. deepdoctection/pipe/doctectionpipe.py +108 -47
  87. deepdoctection/pipe/language.py +41 -24
  88. deepdoctection/pipe/layout.py +45 -18
  89. deepdoctection/pipe/lm.py +146 -78
  90. deepdoctection/pipe/order.py +196 -113
  91. deepdoctection/pipe/refine.py +111 -63
  92. deepdoctection/pipe/registry.py +1 -1
  93. deepdoctection/pipe/segment.py +213 -142
  94. deepdoctection/pipe/sub_layout.py +76 -46
  95. deepdoctection/pipe/text.py +52 -33
  96. deepdoctection/pipe/transform.py +8 -6
  97. deepdoctection/train/d2_frcnn_train.py +87 -69
  98. deepdoctection/train/hf_detr_train.py +72 -40
  99. deepdoctection/train/hf_layoutlm_train.py +85 -46
  100. deepdoctection/train/tp_frcnn_train.py +56 -28
  101. deepdoctection/utils/concurrency.py +59 -16
  102. deepdoctection/utils/context.py +40 -19
  103. deepdoctection/utils/develop.py +25 -17
  104. deepdoctection/utils/env_info.py +85 -36
  105. deepdoctection/utils/error.py +16 -10
  106. deepdoctection/utils/file_utils.py +246 -62
  107. deepdoctection/utils/fs.py +162 -43
  108. deepdoctection/utils/identifier.py +29 -16
  109. deepdoctection/utils/logger.py +49 -32
  110. deepdoctection/utils/metacfg.py +83 -21
  111. deepdoctection/utils/pdf_utils.py +119 -62
  112. deepdoctection/utils/settings.py +24 -10
  113. deepdoctection/utils/tqdm.py +10 -5
  114. deepdoctection/utils/transform.py +182 -46
  115. deepdoctection/utils/utils.py +61 -28
  116. deepdoctection/utils/viz.py +150 -104
  117. deepdoctection-0.43.dist-info/METADATA +376 -0
  118. deepdoctection-0.43.dist-info/RECORD +149 -0
  119. {deepdoctection-0.42.0.dist-info → deepdoctection-0.43.dist-info}/WHEEL +1 -1
  120. deepdoctection/analyzer/_config.py +0 -146
  121. deepdoctection-0.42.0.dist-info/METADATA +0 -431
  122. deepdoctection-0.42.0.dist-info/RECORD +0 -148
  123. {deepdoctection-0.42.0.dist-info → deepdoctection-0.43.dist-info}/licenses/LICENSE +0 -0
  124. {deepdoctection-0.42.0.dist-info → deepdoctection-0.43.dist-info}/top_level.txt +0 -0
@@ -1,146 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- # File: config.py
3
-
4
- # Copyright 2024 Dr. Janis Meyer. All rights reserved.
5
- #
6
- # Licensed under the Apache License, Version 2.0 (the "License");
7
- # you may not use this file except in compliance with the License.
8
- # You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
-
18
- """Pipeline configuration for deepdoctection analyzer. Do not change the defaults in this file. """
19
-
20
- from ..datapoint.view import IMAGE_DEFAULTS
21
- from ..utils.metacfg import AttrDict
22
- from ..utils.settings import CellType, LayoutType
23
-
24
- cfg = AttrDict()
25
-
26
-
27
- cfg.LANGUAGE = None
28
- cfg.LIB = None
29
- cfg.DEVICE = None
30
- cfg.USE_ROTATOR = False
31
- cfg.USE_LAYOUT = True
32
- cfg.USE_TABLE_SEGMENTATION = True
33
-
34
- cfg.TF.LAYOUT.WEIGHTS = "layout/model-800000_inf_only.data-00000-of-00001"
35
- cfg.TF.LAYOUT.FILTER = None
36
-
37
- cfg.TF.CELL.WEIGHTS = "cell/model-1800000_inf_only.data-00000-of-00001"
38
- cfg.TF.CELL.FILTER = None
39
-
40
- cfg.TF.ITEM.WEIGHTS = "item/model-1620000_inf_only.data-00000-of-00001"
41
- cfg.TF.ITEM.FILTER = None
42
-
43
- cfg.PT.ENFORCE_WEIGHTS.LAYOUT = True
44
- cfg.PT.LAYOUT.WEIGHTS = "layout/d2_model_0829999_layout_inf_only.pt"
45
- cfg.PT.LAYOUT.WEIGHTS_TS = "layout/d2_model_0829999_layout_inf_only.ts"
46
- cfg.PT.LAYOUT.FILTER = None
47
- cfg.PT.LAYOUT.PAD.TOP = 60
48
- cfg.PT.LAYOUT.PAD.RIGHT = 60
49
- cfg.PT.LAYOUT.PAD.BOTTOM = 60
50
- cfg.PT.LAYOUT.PAD.LEFT = 60
51
-
52
- cfg.PT.ENFORCE_WEIGHTS.ITEM = True
53
- cfg.PT.ITEM.WEIGHTS = "item/d2_model_1639999_item_inf_only.pt"
54
- cfg.PT.ITEM.WEIGHTS_TS = "item/d2_model_1639999_item_inf_only.ts"
55
- cfg.PT.ITEM.FILTER = None
56
- cfg.PT.ITEM.PAD.TOP = 60
57
- cfg.PT.ITEM.PAD.RIGHT = 60
58
- cfg.PT.ITEM.PAD.BOTTOM = 60
59
- cfg.PT.ITEM.PAD.LEFT = 60
60
-
61
- cfg.PT.ENFORCE_WEIGHTS.CELL = True
62
- cfg.PT.CELL.WEIGHTS = "cell/d2_model_1849999_cell_inf_only.pt"
63
- cfg.PT.CELL.WEIGHTS_TS = "cell/d2_model_1849999_cell_inf_only.ts"
64
- cfg.PT.CELL.FILTER = None
65
-
66
- cfg.USE_LAYOUT_NMS = False
67
- cfg.LAYOUT_NMS_PAIRS.COMBINATIONS = None
68
- cfg.LAYOUT_NMS_PAIRS.THRESHOLDS = None
69
- cfg.LAYOUT_NMS_PAIRS.PRIORITY = None
70
-
71
- cfg.SEGMENTATION.ASSIGNMENT_RULE = "ioa"
72
- cfg.SEGMENTATION.THRESHOLD_ROWS = 0.4
73
- cfg.SEGMENTATION.THRESHOLD_COLS = 0.4
74
- cfg.SEGMENTATION.FULL_TABLE_TILING = True
75
- cfg.SEGMENTATION.REMOVE_IOU_THRESHOLD_ROWS = 0.001
76
- cfg.SEGMENTATION.REMOVE_IOU_THRESHOLD_COLS = 0.001
77
- cfg.SEGMENTATION.TABLE_NAME = LayoutType.TABLE
78
- cfg.SEGMENTATION.PUBTABLES_CELL_NAMES = [
79
- CellType.SPANNING,
80
- CellType.ROW_HEADER,
81
- CellType.COLUMN_HEADER,
82
- CellType.PROJECTED_ROW_HEADER,
83
- LayoutType.CELL,
84
- ]
85
- cfg.SEGMENTATION.PUBTABLES_SPANNING_CELL_NAMES = [
86
- CellType.SPANNING,
87
- CellType.ROW_HEADER,
88
- CellType.COLUMN_HEADER,
89
- CellType.PROJECTED_ROW_HEADER,
90
- ]
91
- cfg.SEGMENTATION.PUBTABLES_ITEM_NAMES = [LayoutType.ROW, LayoutType.COLUMN]
92
- cfg.SEGMENTATION.PUBTABLES_SUB_ITEM_NAMES = [CellType.ROW_NUMBER, CellType.COLUMN_NUMBER]
93
- cfg.SEGMENTATION.CELL_NAMES = [CellType.HEADER, CellType.BODY, LayoutType.CELL]
94
- cfg.SEGMENTATION.ITEM_NAMES = [LayoutType.ROW, LayoutType.COLUMN]
95
- cfg.SEGMENTATION.SUB_ITEM_NAMES = [CellType.ROW_NUMBER, CellType.COLUMN_NUMBER]
96
- cfg.SEGMENTATION.PUBTABLES_ITEM_HEADER_CELL_NAMES = [CellType.COLUMN_HEADER, CellType.ROW_HEADER]
97
- cfg.SEGMENTATION.PUBTABLES_ITEM_HEADER_THRESHOLDS = [0.6, 0.0001]
98
- cfg.SEGMENTATION.STRETCH_RULE = "equal"
99
-
100
- cfg.USE_TABLE_REFINEMENT = True
101
- cfg.USE_PDF_MINER = False
102
-
103
- cfg.PDF_MINER.X_TOLERANCE = 3
104
- cfg.PDF_MINER.Y_TOLERANCE = 3
105
-
106
- cfg.USE_OCR = True
107
-
108
- cfg.OCR.USE_TESSERACT = True
109
- cfg.OCR.USE_DOCTR = False
110
- cfg.OCR.USE_TEXTRACT = False
111
- cfg.OCR.CONFIG.TESSERACT = "dd/conf_tesseract.yaml"
112
-
113
- cfg.OCR.WEIGHTS.DOCTR_WORD.TF = "doctr/db_resnet50/tf/db_resnet50-adcafc63.zip"
114
- cfg.OCR.WEIGHTS.DOCTR_WORD.PT = "doctr/db_resnet50/pt/db_resnet50-ac60cadc.pt"
115
- cfg.OCR.WEIGHTS.DOCTR_RECOGNITION.TF = "doctr/crnn_vgg16_bn/tf/crnn_vgg16_bn-76b7f2c6.zip"
116
- cfg.OCR.WEIGHTS.DOCTR_RECOGNITION.PT = "doctr/crnn_vgg16_bn/pt/crnn_vgg16_bn-9762b0b0.pt"
117
-
118
- cfg.TEXT_CONTAINER = IMAGE_DEFAULTS["text_container"]
119
- cfg.WORD_MATCHING.PARENTAL_CATEGORIES = [
120
- LayoutType.TEXT,
121
- LayoutType.TITLE,
122
- LayoutType.LIST,
123
- LayoutType.CELL,
124
- CellType.COLUMN_HEADER,
125
- CellType.PROJECTED_ROW_HEADER,
126
- CellType.SPANNING,
127
- CellType.ROW_HEADER,
128
- ]
129
- cfg.WORD_MATCHING.RULE = "ioa"
130
- cfg.WORD_MATCHING.THRESHOLD = 0.6
131
- cfg.WORD_MATCHING.MAX_PARENT_ONLY = True
132
-
133
- cfg.TEXT_ORDERING.TEXT_BLOCK_CATEGORIES = IMAGE_DEFAULTS["text_block_categories"]
134
- cfg.TEXT_ORDERING.FLOATING_TEXT_BLOCK_CATEGORIES = IMAGE_DEFAULTS["floating_text_block_categories"]
135
- cfg.TEXT_ORDERING.INCLUDE_RESIDUAL_TEXT_CONTAINER = False
136
- cfg.TEXT_ORDERING.STARTING_POINT_TOLERANCE = 0.005
137
- cfg.TEXT_ORDERING.BROKEN_LINE_TOLERANCE = 0.003
138
- cfg.TEXT_ORDERING.HEIGHT_TOLERANCE = 2.0
139
- cfg.TEXT_ORDERING.PARAGRAPH_BREAK = 0.035
140
-
141
- cfg.USE_LAYOUT_LINK = False
142
- cfg.USE_LINE_MATCHER = False
143
- cfg.LAYOUT_LINK.PARENTAL_CATEGORIES = []
144
- cfg.LAYOUT_LINK.CHILD_CATEGORIES = []
145
-
146
- cfg.freeze()
@@ -1,431 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: deepdoctection
3
- Version: 0.42.0
4
- Summary: Repository for Document AI
5
- Home-page: https://github.com/deepdoctection/deepdoctection
6
- Author: Dr. Janis Meyer
7
- License: Apache License 2.0
8
- Classifier: Development Status :: 4 - Beta
9
- Classifier: License :: OSI Approved :: Apache Software License
10
- Classifier: Natural Language :: English
11
- Classifier: Operating System :: POSIX :: Linux
12
- Classifier: Programming Language :: Python :: 3.9
13
- Classifier: Programming Language :: Python :: 3.10
14
- Classifier: Programming Language :: Python :: 3.11
15
- Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
16
- Requires-Python: >=3.9
17
- Description-Content-Type: text/markdown
18
- License-File: LICENSE
19
- Requires-Dist: catalogue==2.0.10
20
- Requires-Dist: huggingface_hub>=0.26.0
21
- Requires-Dist: importlib-metadata>=5.0.0
22
- Requires-Dist: jsonlines==3.1.0
23
- Requires-Dist: lazy-imports==0.3.1
24
- Requires-Dist: mock==4.0.3
25
- Requires-Dist: networkx>=2.7.1
26
- Requires-Dist: numpy<2.0,>=1.21
27
- Requires-Dist: packaging>=20.0
28
- Requires-Dist: Pillow>=10.0.0
29
- Requires-Dist: pypdf>=3.16.0
30
- Requires-Dist: pypdfium2>=4.30.0
31
- Requires-Dist: pyyaml>=6.0.1
32
- Requires-Dist: pyzmq>=16
33
- Requires-Dist: scipy>=1.13.1
34
- Requires-Dist: termcolor>=1.1
35
- Requires-Dist: tabulate>=0.7.7
36
- Requires-Dist: tqdm==4.64.0
37
- Provides-Extra: tf
38
- Requires-Dist: catalogue==2.0.10; extra == "tf"
39
- Requires-Dist: huggingface_hub>=0.26.0; extra == "tf"
40
- Requires-Dist: importlib-metadata>=5.0.0; extra == "tf"
41
- Requires-Dist: jsonlines==3.1.0; extra == "tf"
42
- Requires-Dist: lazy-imports==0.3.1; extra == "tf"
43
- Requires-Dist: mock==4.0.3; extra == "tf"
44
- Requires-Dist: networkx>=2.7.1; extra == "tf"
45
- Requires-Dist: numpy<2.0,>=1.21; extra == "tf"
46
- Requires-Dist: packaging>=20.0; extra == "tf"
47
- Requires-Dist: Pillow>=10.0.0; extra == "tf"
48
- Requires-Dist: pypdf>=3.16.0; extra == "tf"
49
- Requires-Dist: pypdfium2>=4.30.0; extra == "tf"
50
- Requires-Dist: pyyaml>=6.0.1; extra == "tf"
51
- Requires-Dist: pyzmq>=16; extra == "tf"
52
- Requires-Dist: scipy>=1.13.1; extra == "tf"
53
- Requires-Dist: termcolor>=1.1; extra == "tf"
54
- Requires-Dist: tabulate>=0.7.7; extra == "tf"
55
- Requires-Dist: tqdm==4.64.0; extra == "tf"
56
- Requires-Dist: tensorpack==0.11; extra == "tf"
57
- Requires-Dist: protobuf==3.20.1; extra == "tf"
58
- Requires-Dist: tensorflow-addons>=0.17.1; extra == "tf"
59
- Requires-Dist: tf2onnx>=1.9.2; extra == "tf"
60
- Requires-Dist: python-doctr==0.9.0; extra == "tf"
61
- Requires-Dist: pycocotools>=2.0.2; extra == "tf"
62
- Requires-Dist: boto3==1.34.102; extra == "tf"
63
- Requires-Dist: pdfplumber>=0.11.0; extra == "tf"
64
- Requires-Dist: fasttext-wheel; extra == "tf"
65
- Requires-Dist: jdeskew>=0.2.2; extra == "tf"
66
- Requires-Dist: apted==1.0.3; extra == "tf"
67
- Requires-Dist: distance==0.1.3; extra == "tf"
68
- Requires-Dist: lxml>=4.9.1; extra == "tf"
69
- Provides-Extra: pt
70
- Requires-Dist: catalogue==2.0.10; extra == "pt"
71
- Requires-Dist: huggingface_hub>=0.26.0; extra == "pt"
72
- Requires-Dist: importlib-metadata>=5.0.0; extra == "pt"
73
- Requires-Dist: jsonlines==3.1.0; extra == "pt"
74
- Requires-Dist: lazy-imports==0.3.1; extra == "pt"
75
- Requires-Dist: mock==4.0.3; extra == "pt"
76
- Requires-Dist: networkx>=2.7.1; extra == "pt"
77
- Requires-Dist: numpy<2.0,>=1.21; extra == "pt"
78
- Requires-Dist: packaging>=20.0; extra == "pt"
79
- Requires-Dist: Pillow>=10.0.0; extra == "pt"
80
- Requires-Dist: pypdf>=3.16.0; extra == "pt"
81
- Requires-Dist: pypdfium2>=4.30.0; extra == "pt"
82
- Requires-Dist: pyyaml>=6.0.1; extra == "pt"
83
- Requires-Dist: pyzmq>=16; extra == "pt"
84
- Requires-Dist: scipy>=1.13.1; extra == "pt"
85
- Requires-Dist: termcolor>=1.1; extra == "pt"
86
- Requires-Dist: tabulate>=0.7.7; extra == "pt"
87
- Requires-Dist: tqdm==4.64.0; extra == "pt"
88
- Requires-Dist: timm>=0.9.16; extra == "pt"
89
- Requires-Dist: transformers>=4.48.0; extra == "pt"
90
- Requires-Dist: accelerate>=0.29.1; extra == "pt"
91
- Requires-Dist: python-doctr==0.9.0; extra == "pt"
92
- Requires-Dist: boto3==1.34.102; extra == "pt"
93
- Requires-Dist: pdfplumber>=0.11.0; extra == "pt"
94
- Requires-Dist: fasttext-wheel; extra == "pt"
95
- Requires-Dist: jdeskew>=0.2.2; extra == "pt"
96
- Requires-Dist: apted==1.0.3; extra == "pt"
97
- Requires-Dist: distance==0.1.3; extra == "pt"
98
- Requires-Dist: lxml>=4.9.1; extra == "pt"
99
- Provides-Extra: docs
100
- Requires-Dist: tensorpack==0.11; extra == "docs"
101
- Requires-Dist: boto3==1.34.102; extra == "docs"
102
- Requires-Dist: transformers>=4.48.0; extra == "docs"
103
- Requires-Dist: accelerate>=0.29.1; extra == "docs"
104
- Requires-Dist: pdfplumber>=0.11.0; extra == "docs"
105
- Requires-Dist: lxml>=4.9.1; extra == "docs"
106
- Requires-Dist: lxml-stubs>=0.5.1; extra == "docs"
107
- Requires-Dist: jdeskew>=0.2.2; extra == "docs"
108
- Requires-Dist: jinja2==3.0.3; extra == "docs"
109
- Requires-Dist: mkdocs-material; extra == "docs"
110
- Requires-Dist: mkdocstrings-python; extra == "docs"
111
- Requires-Dist: griffe==0.25.0; extra == "docs"
112
- Provides-Extra: dev
113
- Requires-Dist: python-dotenv==1.0.0; extra == "dev"
114
- Requires-Dist: click; extra == "dev"
115
- Requires-Dist: black==23.7.0; extra == "dev"
116
- Requires-Dist: isort==5.13.2; extra == "dev"
117
- Requires-Dist: pylint==2.17.4; extra == "dev"
118
- Requires-Dist: mypy==1.4.1; extra == "dev"
119
- Requires-Dist: wandb; extra == "dev"
120
- Requires-Dist: types-PyYAML>=6.0.12.12; extra == "dev"
121
- Requires-Dist: types-termcolor>=1.1.3; extra == "dev"
122
- Requires-Dist: types-tabulate>=0.9.0.3; extra == "dev"
123
- Requires-Dist: types-tqdm>=4.66.0.5; extra == "dev"
124
- Requires-Dist: lxml-stubs>=0.5.1; extra == "dev"
125
- Requires-Dist: types-Pillow>=10.2.0.20240406; extra == "dev"
126
- Requires-Dist: types-urllib3>=1.26.25.14; extra == "dev"
127
- Provides-Extra: test
128
- Requires-Dist: pytest==8.0.2; extra == "test"
129
- Requires-Dist: pytest-cov; extra == "test"
130
- Dynamic: author
131
- Dynamic: classifier
132
- Dynamic: description
133
- Dynamic: description-content-type
134
- Dynamic: home-page
135
- Dynamic: license
136
- Dynamic: license-file
137
- Dynamic: provides-extra
138
- Dynamic: requires-dist
139
- Dynamic: requires-python
140
- Dynamic: summary
141
-
142
-
143
- <p align="center">
144
- <img src="https://github.com/deepdoctection/deepdoctection/raw/master/docs/tutorials/_imgs/dd_logo.png" alt="Deep Doctection Logo" width="60%">
145
- <h3 align="center">
146
- A Document AI Package
147
- </h3>
148
- </p>
149
-
150
-
151
- **deep**doctection is a Python library that orchestrates document extraction and document layout analysis tasks using deep learning models. It does
152
- not implement models but enables you to build pipelines using highly acknowledged libraries for object detection, OCR
153
- and selected NLP tasks and provides an integrated framework for fine-tuning, evaluating and running models. For more
154
- specific text processing tasks use one of the many other great NLP libraries.
155
-
156
- **deep**doctection focuses on applications and is made for those who want to solve real world problems related to
157
- document extraction from PDFs or scans in various image formats.
158
-
159
- Check the demo of a document layout analysis pipeline with OCR on
160
- :hugs: [**Hugging Face spaces**](https://huggingface.co/spaces/deepdoctection/deepdoctection).
161
-
162
- # Overview
163
-
164
- **deep**doctection provides model wrappers of supported libraries for various tasks to be integrated into
165
- pipelines. Its core function does not depend on any specific deep learning library. Selected models for the following
166
- tasks are currently supported:
167
-
168
- - Document layout analysis including table recognition in Tensorflow with [**Tensorpack**](https://github.com/tensorpack),
169
- or PyTorch with [**Detectron2**](https://github.com/facebookresearch/detectron2/tree/main/detectron2),
170
- - OCR with support of [**Tesseract**](https://github.com/tesseract-ocr/tesseract), [**DocTr**](https://github.com/mindee/doctr)
171
- (Tensorflow and PyTorch implementations available) and a wrapper to an API for a commercial solution,
172
- - Text mining for native PDFs with [**pdfplumber**](https://github.com/jsvine/pdfplumber),
173
- - Language detection with [**fastText**](https://github.com/facebookresearch/fastText),
174
- - Deskewing and rotating images with [**jdeskew**](https://github.com/phamquiluan/jdeskew).
175
- - Document and token classification with all LayoutLM models provided by the
176
- [**Transformer library**](https://github.com/huggingface/transformers).
177
- (Yes, you can use any LayoutLM-model with any of the provided OCR-or pdfplumber tools straight away!).
178
- - Table detection and table structure recognition with
179
- [**table-transformer**](https://github.com/microsoft/table-transformer).
180
- - There is a small dataset for token classification [available](https://huggingface.co/datasets/deepdoctection/FRFPE)
181
- and a lot of new [tutorials](https://github.com/deepdoctection/notebooks/blob/main/Layoutlm_v2_on_custom_token_classification.ipynb)
182
- to show, how to train and evaluate this dataset using LayoutLMv1, LayoutLMv2, LayoutXLM and LayoutLMv3.
183
- - Comprehensive configuration of **analyzer** like choosing different models, output parsing, OCR selection.
184
- Check this [notebook](https://github.com/deepdoctection/notebooks/blob/main/Analyzer_Configuration.ipynb) or the
185
- [docs](https://deepdoctection.readthedocs.io/en/latest/tutorials/analyzer_configuration_notebook/) for more infos.
186
- - Document layout analysis and table recognition now runs with
187
- [**Torchscript**](https://pytorch.org/docs/stable/jit.html) (CPU) as well and [**Detectron2**](https://github.com/facebookresearch/detectron2/tree/main/detectron2) is not required
188
- anymore for basic inference.
189
- - More angle predictors for determining the rotation of a document based on [**Tesseract**](https://github.com/tesseract-ocr/tesseract) and [**DocTr**](https://github.com/mindee/doctr)
190
- - Token classification with [**LiLT**](https://github.com/jpWang/LiLT) via
191
- [**transformers**](https://github.com/huggingface/transformers).
192
- We have added a model wrapper for token classification with LiLT and added a some LiLT models to the model catalog
193
- that seem to look promising, especially if you want to train a model on non-english data. The training script for
194
- LayoutLM can be used for LiLT as well.
195
- - [**new**] There are two notebooks available that show, how to write a
196
- [custom predictor](https://github.com/deepdoctection/notebooks/blob/main/Doclaynet_Analyzer_Config.ipynb) based on
197
- a third party library that has not been supported yet and how to use
198
- [advanced configuration](https://github.com/deepdoctection/notebooks/blob/main/Doclaynet_Analyzer_Config.ipynb) to
199
- get links between layout segments e.g. captions and tables or figures.
200
-
201
- **deep**doctection provides on top of that methods for pre-processing inputs to models like cropping or resizing and to
202
- post-process results, like validating duplicate outputs, relating words to detected layout segments or ordering words
203
- into contiguous text. You will get an output in JSON format that you can customize even further by yourself.
204
-
205
- Have a look at the [**introduction notebook**](https://github.com/deepdoctection/notebooks/blob/main/Get_Started.ipynb) in the
206
- [notebook repo](https://github.com/deepdoctection/notebooks) for an easy start.
207
-
208
- Check the [**release notes**](https://github.com/deepdoctection/deepdoctection/releases) for recent updates.
209
-
210
- ## Models
211
-
212
- **deep**doctection or its support libraries provide pre-trained models that are in most of the cases available at the
213
- [**Hugging Face Model Hub**](https://huggingface.co/deepdoctection) or that will be automatically downloaded once
214
- requested. For instance, you can find pre-trained object detection models from the Tensorpack or Detectron2 framework
215
- for coarse layout analysis, table cell detection and table recognition.
216
-
217
- ## Datasets and training scripts
218
-
219
- Training is a substantial part to get pipelines ready on some specific domain, let it be document layout analysis,
220
- document classification or NER. **deep**doctection provides training scripts for models that are based on trainers
221
- developed from the library that hosts the model code. Moreover, **deep**doctection hosts code to some well established
222
- datasets like **Publaynet** that makes it easy to experiment. It also contains mappings from widely used data
223
- formats like COCO and it has a dataset framework (akin to [**datasets**](https://github.com/huggingface/datasets) so that
224
- setting up training on a custom dataset becomes very easy. [**This notebook**](https://github.com/deepdoctection/notebooks/blob/main/Datasets_and_Eval.ipynb)
225
- shows you how to do this.
226
-
227
- ## Evaluation
228
-
229
- **deep**doctection comes equipped with a framework that allows you to evaluate predictions of a single or multiple
230
- models in a pipeline against some ground truth. Check again [**here**](https://github.com/deepdoctection/notebooks/blob/main/Datasets_and_Eval.ipynb) how it is
231
- done.
232
-
233
- ## Inference
234
-
235
- Having set up a pipeline it takes you a few lines of code to instantiate the pipeline and after a for loop all pages will
236
- be processed through the pipeline.
237
-
238
- ```python
239
- import deepdoctection as dd
240
- from IPython.core.display import HTML
241
- from matplotlib import pyplot as plt
242
-
243
- analyzer = dd.get_dd_analyzer() # instantiate the built-in analyzer similar to the Hugging Face space demo
244
-
245
- df = analyzer.analyze(path = "/path/to/your/doc.pdf") # setting up pipeline
246
- df.reset_state() # Trigger some initialization
247
-
248
- doc = iter(df)
249
- page = next(doc)
250
-
251
- image = page.viz()
252
- plt.figure(figsize = (25,17))
253
- plt.axis('off')
254
- plt.imshow(image)
255
- ```
256
-
257
- ![text](https://github.com/deepdoctection/deepdoctection/raw/master/docs/tutorials/_imgs/dd_rm_sample.png)
258
-
259
- ```
260
- HTML(page.tables[0].html)
261
- ```
262
-
263
- ![table](https://github.com/deepdoctection/deepdoctection/raw/master/docs/tutorials/_imgs/dd_rm_table.png)
264
-
265
-
266
- ```
267
- print(page.text)
268
- ```
269
-
270
- ![table](https://github.com/deepdoctection/deepdoctection/raw/master/docs/tutorials/_imgs/dd_rm_text.png)
271
-
272
-
273
- ## Documentation
274
-
275
- There is an extensive [**documentation**](https://deepdoctection.readthedocs.io/en/latest/index.html#) available
276
- containing tutorials, design concepts and the API. We want to present things as comprehensively and understandably
277
- as possible. However, we are aware that there are still many areas where significant improvements can be made in terms
278
- of clarity, grammar and correctness. We look forward to every hint and comment that increases the quality of the
279
- documentation.
280
-
281
-
282
- ## Requirements
283
-
284
- ![requirements](https://github.com/deepdoctection/deepdoctection/raw/master/docs/tutorials/_imgs/requirements_deepdoctection_081124.png)
285
-
286
- Everything in the overview listed below the **deep**doctection layer are necessary requirements and have to be installed
287
- separately.
288
-
289
- - Linux or macOS. (Windows is not supported but there is a [Dockerfile](./docker/pytorch-cpu-jupyter/Dockerfile) available)
290
- - Python >= 3.9
291
- - 1.13 <= PyTorch **or** 2.11 <= Tensorflow < 2.16. (For lower Tensorflow versions the code will only run on a GPU).
292
- In general, if you want to train or fine-tune models, a GPU is required.
293
-
294
- - With respect to the Deep Learning framework, you must decide between [Tensorflow](https://www.tensorflow.org/install?hl=en)
295
- and [PyTorch](https://pytorch.org/get-started/locally/).
296
- - [Tesseract](https://github.com/tesseract-ocr/tesseract) OCR engine will be used through a Python wrapper. The core
297
- engine has to be installed separately.
298
-
299
-
300
- - For release `v.0.34.0` and below **deep**doctection uses Python wrappers for [Poppler](https://poppler.freedesktop.org/) to convert PDF
301
- documents into images. For release `v.0.35.0` this dependency will be optional.
302
-
303
- The following overview shows the availability of the models in conjunction with the DL framework.
304
-
305
- | Task | PyTorch | Torchscript | Tensorflow |
306
- |-----------------------------------------------|:-------:|----------------|:------------:|
307
- | Layout detection via Detectron2/Tensorpack | ✅ | ✅ (CPU only) | ✅ (GPU only) |
308
- | Table recognition via Detectron2/Tensorpack | ✅ | ✅ (CPU only) | ✅ (GPU only) |
309
- | Table transformer via Transformers | ✅ | ❌ | ❌ |
310
- | DocTr | ✅ | ❌ | ✅ |
311
- | LayoutLM (v1, v2, v3, XLM) via Transformers | ✅ | ❌ | ❌ |
312
-
313
-
314
-
315
- ## Installation
316
-
317
- We recommend using a virtual environment. You can install the package via pip or from source.
318
-
319
- ### Install with pip from PyPi
320
-
321
- #### Minimal installation
322
-
323
- If you want to get started with a minimal setting (e.g. running the **deep**doctection analyzer with
324
- default configuration or trying the 'Get started notebook'), install **deep**doctection with
325
-
326
- ```
327
- pip install deepdoctection
328
- ```
329
-
330
- If you want to use the Tensorflow framework, please install Tensorpack separately. Detectron2 will not be installed
331
- and layout models/ table recognition models will run with Torchscript on a CPU.
332
-
333
- #### Full installation
334
-
335
- The following installation will give you ALL models available within the Deep Learning framework as well as all models
336
- that are independent of Tensorflow/PyTorch. Please note, that the dependencies are very complex. We try hard to keep
337
- the requirements up to date though.
338
-
339
- For **Tensorflow**, run
340
-
341
- ```
342
- pip install deepdoctection[tf]
343
- ```
344
-
345
- For **PyTorch**,
346
-
347
- first install **Detectron2** separately as it is not distributed via PyPi. Check the instruction
348
- [here](https://detectron2.readthedocs.io/en/latest/tutorials/install.html). Then run
349
-
350
- ```
351
- pip install deepdoctection[pt]
352
- ```
353
-
354
- This will install **deep**doctection with all dependencies listed above the **deep**doctection layer. Use this setting,
355
- if you want to get started or want to explore all features.
356
-
357
- If you want to have more control with your installation and are looking for fewer dependencies then
358
- install **deep**doctection with the basic setup only.
359
-
360
- ```
361
- pip install deepdoctection
362
- ```
363
-
364
- This will ignore all model libraries (layers above the **deep**doctection layer in the diagram) and you
365
- will be responsible to install them by yourself. Note, that you will not be able to run any pipeline with this setup.
366
-
367
- For further information, please consult the [**full installation instructions**](https://deepdoctection.readthedocs.io/en/latest/install/).
368
-
369
-
370
- ### Installation from source
371
-
372
- Download the repository or clone via
373
-
374
- ```
375
- git clone https://github.com/deepdoctection/deepdoctection.git
376
- ```
377
-
378
- To get started with **Tensorflow**, run:
379
-
380
- ```
381
- cd deepdoctection
382
- pip install ".[tf]"
383
- ```
384
-
385
- Installing the full **PyTorch** setup from source will also install **Detectron2** for you:
386
-
387
- ```
388
- cd deepdoctection
389
- pip install ".[source-pt]"
390
- ```
391
-
392
- ### Running a Docker container from Docker hub
393
-
394
- Starting from release `v.0.27.0`, pre-existing Docker images can be downloaded from the
395
- [Docker hub](https://hub.docker.com/r/deepdoctection/deepdoctection).
396
-
397
- ```
398
- docker pull deepdoctection/deepdoctection:<release_tag>
399
- ```
400
-
401
- To start the container, you can use the Docker compose file `./docker/pytorch-gpu/docker-compose.yaml`.
402
- In the `.env` file provided, specify the host directory where **deep**doctection's cache should be stored.
403
- This directory will be mounted. Additionally, specify a working directory to mount files to be processed into the
404
- container.
405
-
406
- ```
407
- docker compose up -d
408
- ```
409
-
410
- will start the container.
411
-
412
- ## Credits
413
-
414
- We thank all libraries that provide high quality code and pre-trained models. Without, it would have been impossible
415
- to develop this framework.
416
-
417
- ## Problems
418
-
419
- We try hard to eliminate bugs. We also know that the code is not free of issues. We welcome all issues relevant to this
420
- repo and try to address them as quickly as possible. Bug fixes or enhancements will be deployed in a new release every 10
421
- to 12 weeks.
422
-
423
- ## If you like **deep**doctection ...
424
-
425
- ...you can easily support the project by making it more visible. Leaving a star or a recommendation will help.
426
-
427
-
428
- ## License
429
-
430
- Distributed under the Apache 2.0 License. Check [LICENSE](https://github.com/deepdoctection/deepdoctection/blob/master/LICENSE)
431
- for additional information.