deepdoctection 0.40.0__tar.gz → 0.41.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


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

Files changed (155) hide show
  1. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/PKG-INFO +1 -1
  2. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/__init__.py +5 -3
  3. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/analyzer/factory.py +1 -1
  4. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/datapoint/convert.py +0 -24
  5. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/datapoint/view.py +1 -2
  6. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/datasets/base.py +3 -1
  7. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/extern/base.py +108 -1
  8. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/extern/deskew.py +1 -1
  9. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/extern/doctrocr.py +2 -1
  10. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/extern/tessocr.py +1 -1
  11. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/extern/tp/tpfrcnn/preproc.py +1 -1
  12. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/mapper/laylmstruct.py +1 -2
  13. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/mapper/match.py +2 -2
  14. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/pipe/common.py +3 -2
  15. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/pipe/sub_layout.py +8 -4
  16. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/pipe/transform.py +38 -16
  17. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/utils/settings.py +5 -0
  18. deepdoctection-0.41.0/deepdoctection/utils/transform.py +359 -0
  19. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection.egg-info/PKG-INFO +1 -1
  20. deepdoctection-0.40.0/deepdoctection/utils/transform.py +0 -224
  21. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/LICENSE +0 -0
  22. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/README.md +0 -0
  23. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/analyzer/__init__.py +0 -0
  24. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/analyzer/_config.py +0 -0
  25. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/analyzer/dd.py +0 -0
  26. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/configs/__init__.py +0 -0
  27. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/configs/conf_dd_one.yaml +0 -0
  28. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/configs/conf_tesseract.yaml +0 -0
  29. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/dataflow/__init__.py +0 -0
  30. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/dataflow/base.py +0 -0
  31. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/dataflow/common.py +0 -0
  32. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/dataflow/custom.py +0 -0
  33. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/dataflow/custom_serialize.py +0 -0
  34. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/dataflow/parallel_map.py +0 -0
  35. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/dataflow/serialize.py +0 -0
  36. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/dataflow/stats.py +0 -0
  37. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/datapoint/__init__.py +0 -0
  38. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/datapoint/annotation.py +0 -0
  39. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/datapoint/box.py +0 -0
  40. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/datapoint/image.py +0 -0
  41. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/datasets/__init__.py +0 -0
  42. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/datasets/adapter.py +0 -0
  43. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/datasets/dataflow_builder.py +0 -0
  44. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/datasets/info.py +0 -0
  45. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/datasets/instances/__init__.py +0 -0
  46. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/datasets/instances/doclaynet.py +0 -0
  47. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/datasets/instances/fintabnet.py +0 -0
  48. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/datasets/instances/funsd.py +0 -0
  49. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/datasets/instances/iiitar13k.py +0 -0
  50. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/datasets/instances/layouttest.py +0 -0
  51. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/datasets/instances/publaynet.py +0 -0
  52. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/datasets/instances/pubtables1m.py +0 -0
  53. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/datasets/instances/pubtabnet.py +0 -0
  54. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/datasets/instances/rvlcdip.py +0 -0
  55. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/datasets/instances/xfund.py +0 -0
  56. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/datasets/instances/xsl/__init__.py +0 -0
  57. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/datasets/instances/xsl/pascal_voc.xsl +0 -0
  58. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/datasets/registry.py +0 -0
  59. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/datasets/save.py +0 -0
  60. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/eval/__init__.py +0 -0
  61. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/eval/accmetric.py +0 -0
  62. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/eval/base.py +0 -0
  63. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/eval/cocometric.py +0 -0
  64. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/eval/eval.py +0 -0
  65. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/eval/registry.py +0 -0
  66. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/eval/tedsmetric.py +0 -0
  67. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/eval/tp_eval_callback.py +0 -0
  68. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/extern/__init__.py +0 -0
  69. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/extern/d2detect.py +0 -0
  70. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/extern/fastlang.py +0 -0
  71. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/extern/hfdetr.py +0 -0
  72. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/extern/hflayoutlm.py +0 -0
  73. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/extern/hflm.py +0 -0
  74. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/extern/model.py +0 -0
  75. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/extern/pdftext.py +0 -0
  76. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/extern/pt/__init__.py +0 -0
  77. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/extern/pt/nms.py +0 -0
  78. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/extern/pt/ptutils.py +0 -0
  79. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/extern/texocr.py +0 -0
  80. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/extern/tp/__init__.py +0 -0
  81. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/extern/tp/tfutils.py +0 -0
  82. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/extern/tp/tpcompat.py +0 -0
  83. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/extern/tp/tpfrcnn/__init__.py +0 -0
  84. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/extern/tp/tpfrcnn/common.py +0 -0
  85. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/extern/tp/tpfrcnn/config/__init__.py +0 -0
  86. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/extern/tp/tpfrcnn/config/config.py +0 -0
  87. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/extern/tp/tpfrcnn/modeling/__init__.py +0 -0
  88. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/extern/tp/tpfrcnn/modeling/backbone.py +0 -0
  89. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/extern/tp/tpfrcnn/modeling/generalized_rcnn.py +0 -0
  90. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/extern/tp/tpfrcnn/modeling/model_box.py +0 -0
  91. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/extern/tp/tpfrcnn/modeling/model_cascade.py +0 -0
  92. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/extern/tp/tpfrcnn/modeling/model_fpn.py +0 -0
  93. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/extern/tp/tpfrcnn/modeling/model_frcnn.py +0 -0
  94. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/extern/tp/tpfrcnn/modeling/model_mrcnn.py +0 -0
  95. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/extern/tp/tpfrcnn/modeling/model_rpn.py +0 -0
  96. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/extern/tp/tpfrcnn/predict.py +0 -0
  97. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/extern/tp/tpfrcnn/utils/__init__.py +0 -0
  98. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/extern/tp/tpfrcnn/utils/box_ops.py +0 -0
  99. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/extern/tp/tpfrcnn/utils/np_box_ops.py +0 -0
  100. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/extern/tpdetect.py +0 -0
  101. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/mapper/__init__.py +0 -0
  102. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/mapper/cats.py +0 -0
  103. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/mapper/cocostruct.py +0 -0
  104. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/mapper/d2struct.py +0 -0
  105. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/mapper/hfstruct.py +0 -0
  106. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/mapper/maputils.py +0 -0
  107. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/mapper/misc.py +0 -0
  108. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/mapper/pascalstruct.py +0 -0
  109. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/mapper/prodigystruct.py +0 -0
  110. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/mapper/pubstruct.py +0 -0
  111. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/mapper/tpstruct.py +0 -0
  112. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/mapper/xfundstruct.py +0 -0
  113. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/pipe/__init__.py +0 -0
  114. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/pipe/anngen.py +0 -0
  115. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/pipe/base.py +0 -0
  116. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/pipe/concurrency.py +0 -0
  117. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/pipe/doctectionpipe.py +0 -0
  118. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/pipe/language.py +0 -0
  119. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/pipe/layout.py +0 -0
  120. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/pipe/lm.py +0 -0
  121. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/pipe/order.py +0 -0
  122. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/pipe/refine.py +0 -0
  123. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/pipe/registry.py +0 -0
  124. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/pipe/segment.py +0 -0
  125. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/pipe/text.py +0 -0
  126. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/py.typed +0 -0
  127. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/train/__init__.py +0 -0
  128. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/train/d2_frcnn_train.py +0 -0
  129. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/train/hf_detr_train.py +0 -0
  130. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/train/hf_layoutlm_train.py +0 -0
  131. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/train/tp_frcnn_train.py +0 -0
  132. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/utils/__init__.py +0 -0
  133. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/utils/concurrency.py +0 -0
  134. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/utils/context.py +0 -0
  135. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/utils/develop.py +0 -0
  136. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/utils/env_info.py +0 -0
  137. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/utils/error.py +0 -0
  138. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/utils/file_utils.py +0 -0
  139. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/utils/fs.py +0 -0
  140. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/utils/identifier.py +0 -0
  141. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/utils/logger.py +0 -0
  142. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/utils/metacfg.py +0 -0
  143. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/utils/mocks.py +0 -0
  144. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/utils/pdf_utils.py +0 -0
  145. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/utils/tqdm.py +0 -0
  146. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/utils/types.py +0 -0
  147. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/utils/utils.py +0 -0
  148. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection/utils/viz.py +0 -0
  149. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection.egg-info/SOURCES.txt +0 -0
  150. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection.egg-info/dependency_links.txt +0 -0
  151. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection.egg-info/requires.txt +0 -0
  152. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/deepdoctection.egg-info/top_level.txt +0 -0
  153. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/setup.cfg +0 -0
  154. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/setup.py +0 -0
  155. {deepdoctection-0.40.0 → deepdoctection-0.41.0}/tests/test_utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: deepdoctection
3
- Version: 0.40.0
3
+ Version: 0.41.0
4
4
  Summary: Repository for Document AI
5
5
  Home-page: https://github.com/deepdoctection/deepdoctection
6
6
  Author: Dr. Janis Meyer
@@ -25,7 +25,7 @@ from .utils.logger import LoggingRecord, logger
25
25
 
26
26
  # pylint: enable=wrong-import-position
27
27
 
28
- __version__ = "0.40.0"
28
+ __version__ = "0.41.0"
29
29
 
30
30
  _IMPORT_STRUCTURE = {
31
31
  "analyzer": ["config_sanity_checks", "get_dd_analyzer", "ServiceFactory"],
@@ -90,8 +90,6 @@ _IMPORT_STRUCTURE = {
90
90
  "convert_np_array_to_b64_b",
91
91
  "convert_bytes_to_np_array",
92
92
  "convert_pdf_bytes_to_np_array_v2",
93
- "box_to_point4",
94
- "point4_to_box",
95
93
  "as_dict",
96
94
  "ImageAnnotationBaseView",
97
95
  "Image",
@@ -164,6 +162,7 @@ _IMPORT_STRUCTURE = {
164
162
  "LMSequenceClassifier",
165
163
  "LanguageDetector",
166
164
  "ImageTransformer",
165
+ "DeterministicImageTransformer",
167
166
  "InferenceResize",
168
167
  "D2FrcnnDetector",
169
168
  "D2FrcnnTracingDetector",
@@ -401,11 +400,14 @@ _IMPORT_STRUCTURE = {
401
400
  "get_type",
402
401
  "get_tqdm",
403
402
  "get_tqdm_default_kwargs",
403
+ "box_to_point4",
404
+ "point4_to_box",
404
405
  "ResizeTransform",
405
406
  "InferenceResize",
406
407
  "normalize_image",
407
408
  "pad_image",
408
409
  "PadTransform",
410
+ "RotationTransform",
409
411
  "delete_keys_from_dict",
410
412
  "split_string",
411
413
  "string_to_dict",
@@ -197,7 +197,7 @@ class ServiceFactory:
197
197
  getattr(config.PT, mode).PAD.BOTTOM,
198
198
  getattr(config.PT, mode).PAD.LEFT,
199
199
  )
200
- return PadTransform(top=top, right=right, bottom=bottom, left=left) #
200
+ return PadTransform(pad_top=top, pad_right=right, pad_bottom=bottom, pad_left=left) #
201
201
 
202
202
  @staticmethod
203
203
  def build_padder(config: AttrDict, mode: str) -> PadTransform:
@@ -27,7 +27,6 @@ from typing import Any, Optional, Union, no_type_check
27
27
 
28
28
  import numpy as np
29
29
  from numpy import uint8
30
- from numpy.typing import NDArray
31
30
  from pypdf import PdfReader
32
31
 
33
32
  from ..utils.develop import deprecated
@@ -42,8 +41,6 @@ __all__ = [
42
41
  "convert_np_array_to_b64_b",
43
42
  "convert_bytes_to_np_array",
44
43
  "convert_pdf_bytes_to_np_array_v2",
45
- "box_to_point4",
46
- "point4_to_box",
47
44
  "as_dict",
48
45
  ]
49
46
 
@@ -187,24 +184,3 @@ def convert_pdf_bytes_to_np_array_v2(
187
184
  width = shape[2] - shape[0]
188
185
  return pdf_to_np_array(pdf_bytes, size=(int(width), int(height))) # type: ignore
189
186
  return pdf_to_np_array(pdf_bytes, dpi=dpi)
190
-
191
-
192
- def box_to_point4(boxes: NDArray[np.float32]) -> NDArray[np.float32]:
193
- """
194
- :param boxes: nx4
195
- :return: (nx4)x2
196
- """
197
- box = boxes[:, [0, 1, 2, 3, 0, 3, 2, 1]]
198
- box = box.reshape((-1, 2))
199
- return box
200
-
201
-
202
- def point4_to_box(points: NDArray[np.float32]) -> NDArray[np.float32]:
203
- """
204
- :param points: (nx4)x2
205
- :return: nx4 boxes (x1y1x2y2)
206
- """
207
- points = points.reshape((-1, 4, 2))
208
- min_xy = points.min(axis=1) # nx2
209
- max_xy = points.max(axis=1) # nx2
210
- return np.concatenate((min_xy, max_xy), axis=1)
@@ -41,12 +41,11 @@ from ..utils.settings import (
41
41
  WordType,
42
42
  get_type,
43
43
  )
44
- from ..utils.transform import ResizeTransform
44
+ from ..utils.transform import ResizeTransform, box_to_point4, point4_to_box
45
45
  from ..utils.types import HTML, AnnotationDict, Chunks, ImageDict, PathLikeOrStr, PixelValues, Text_, csv
46
46
  from ..utils.viz import draw_boxes, interactive_imshow, viz_handler
47
47
  from .annotation import CategoryAnnotation, ContainerAnnotation, ImageAnnotation, ann_from_dict
48
48
  from .box import BoundingBox, crop_box_from_image
49
- from .convert import box_to_point4, point4_to_box
50
49
  from .image import Image
51
50
 
52
51
 
@@ -369,7 +369,9 @@ class MergeDataset(DatasetBase):
369
369
  self.buffer_datasets(**dataflow_build_kwargs)
370
370
  split_defaultdict = defaultdict(list)
371
371
  for image in self.datapoint_list: # type: ignore
372
- split_defaultdict[ann_id_to_split[image.image_id]].append(image)
372
+ maybe_image_id = ann_id_to_split.get(image.image_id)
373
+ if maybe_image_id is not None:
374
+ split_defaultdict[maybe_image_id].append(image)
373
375
  train_dataset = split_defaultdict["train"]
374
376
  val_dataset = split_defaultdict["val"]
375
377
  test_dataset = split_defaultdict["test"]
@@ -26,6 +26,7 @@ from dataclasses import dataclass, field
26
26
  from types import MappingProxyType
27
27
  from typing import TYPE_CHECKING, Any, Literal, Mapping, Optional, Sequence, Union, overload
28
28
 
29
+ import numpy as np
29
30
  from lazy_imports import try_import
30
31
 
31
32
  from ..utils.identifier import get_uuid_from_str
@@ -38,6 +39,7 @@ from ..utils.settings import (
38
39
  token_class_tag_to_token_class_with_tag,
39
40
  token_class_with_tag_to_token_class_and_tag,
40
41
  )
42
+ from ..utils.transform import BaseTransform, box_to_point4, point4_to_box
41
43
  from ..utils.types import JsonDict, PixelValues, Requirement
42
44
 
43
45
  if TYPE_CHECKING:
@@ -621,7 +623,7 @@ class ImageTransformer(PredictorBase, ABC):
621
623
  """
622
624
 
623
625
  @abstractmethod
624
- def transform(self, np_img: PixelValues, specification: DetectionResult) -> PixelValues:
626
+ def transform_image(self, np_img: PixelValues, specification: DetectionResult) -> PixelValues:
625
627
  """
626
628
  Abstract method transform
627
629
  """
@@ -641,3 +643,108 @@ class ImageTransformer(PredictorBase, ABC):
641
643
  def get_category_names(self) -> tuple[ObjectTypes, ...]:
642
644
  """returns category names"""
643
645
  raise NotImplementedError()
646
+
647
+ def transform_coords(self, detect_results: Sequence[DetectionResult]) -> Sequence[DetectionResult]:
648
+ """
649
+ Transform coordinates aligned with the transform_image method.
650
+
651
+ :param detect_results: List of DetectionResults
652
+ :return: List of DetectionResults. If you pass uuid it is possible to track the transformed bounding boxes.
653
+ """
654
+
655
+ raise NotImplementedError()
656
+
657
+ def inverse_transform_coords(self, detect_results: Sequence[DetectionResult]) -> Sequence[DetectionResult]:
658
+ """
659
+ Inverse transform coordinates aligned with the transform_image method. Composing transform_coords with
660
+ inverse_transform_coords should return the original coordinates.
661
+
662
+ :param detect_results: List of DetectionResults
663
+ :return: List of DetectionResults. If you pass uuid it is possible to track the transformed bounding boxes.
664
+ """
665
+
666
+ raise NotImplementedError()
667
+
668
+
669
+ class DeterministicImageTransformer(ImageTransformer):
670
+ """
671
+ A wrapper for BaseTransform classes that implements the ImageTransformer interface.
672
+
673
+ This class provides a bridge between the BaseTransform system (which handles image and coordinate
674
+ transformations like rotation, padding, etc.) and the predictors framework by implementing the
675
+ ImageTransformer interface. It allows BaseTransform objects to be used within pipelines that
676
+ expect ImageTransformer components.
677
+
678
+ The transformer performs deterministic transformations on images and their associated coordinates,
679
+ enabling operations like padding, rotation, and other geometric transformations while maintaining
680
+ the relationship between image content and annotation coordinates.
681
+
682
+ :param base_transform: A BaseTransform instance that defines the actual transformation operations
683
+ to be applied to images and coordinates.
684
+ """
685
+
686
+ def __init__(self, base_transform: BaseTransform):
687
+ """
688
+ Initialize the DeterministicImageTransformer with a BaseTransform instance.
689
+
690
+ :param base_transform: A BaseTransform instance that defines the actual transformation operations
691
+ """
692
+ self.base_transform = base_transform
693
+ self.name = base_transform.__class__.__name__
694
+ self.model_id = self.get_model_id()
695
+
696
+ def transform_image(self, np_img: PixelValues, specification: DetectionResult) -> PixelValues:
697
+ return self.base_transform.apply_image(np_img)
698
+
699
+ def transform_coords(self, detect_results: Sequence[DetectionResult]) -> Sequence[DetectionResult]:
700
+ boxes = np.array([detect_result.box for detect_result in detect_results])
701
+ # boxes = box_to_point4(boxes)
702
+ boxes = self.base_transform.apply_coords(boxes)
703
+ # boxes = point4_to_box(boxes)
704
+ detection_results = []
705
+ for idx, detect_result in enumerate(detect_results):
706
+ detection_results.append(
707
+ DetectionResult(
708
+ box=boxes[idx, :].tolist(),
709
+ class_name=detect_result.class_name,
710
+ class_id=detect_result.class_id,
711
+ score=detect_result.score,
712
+ absolute_coords=detect_result.absolute_coords,
713
+ uuid=detect_result.uuid,
714
+ )
715
+ )
716
+ return detection_results
717
+
718
+ def inverse_transform_coords(self, detect_results: Sequence[DetectionResult]) -> Sequence[DetectionResult]:
719
+ boxes = np.array([detect_result.box for detect_result in detect_results])
720
+ boxes = box_to_point4(boxes)
721
+ boxes = self.base_transform.inverse_apply_coords(boxes)
722
+ boxes = point4_to_box(boxes)
723
+ detection_results = []
724
+ for idx, detect_result in enumerate(detect_results):
725
+ detection_results.append(
726
+ DetectionResult(
727
+ box=boxes[idx, :].tolist(),
728
+ class_id=detect_result.class_id,
729
+ score=detect_result.score,
730
+ absolute_coords=detect_result.absolute_coords,
731
+ uuid=detect_result.uuid,
732
+ )
733
+ )
734
+ return detection_results
735
+
736
+ def clone(self) -> DeterministicImageTransformer:
737
+ return self.__class__(self.base_transform)
738
+
739
+ def predict(self, np_img: PixelValues) -> DetectionResult:
740
+ detect_result = DetectionResult()
741
+ for init_arg in self.base_transform.get_init_args():
742
+ setattr(detect_result, init_arg, getattr(self.base_transform, init_arg))
743
+ return detect_result
744
+
745
+ def get_category_names(self) -> tuple[ObjectTypes, ...]:
746
+ return self.base_transform.get_category_names()
747
+
748
+ @classmethod
749
+ def get_requirements(cls) -> list[Requirement]:
750
+ return []
@@ -43,7 +43,7 @@ class Jdeskewer(ImageTransformer):
43
43
  self.model_id = self.get_model_id()
44
44
  self.min_angle_rotation = min_angle_rotation
45
45
 
46
- def transform(self, np_img: PixelValues, specification: DetectionResult) -> PixelValues:
46
+ def transform_image(self, np_img: PixelValues, specification: DetectionResult) -> PixelValues:
47
47
  """
48
48
  Rotation of the image according to the angle determined by the jdeskew estimator.
49
49
 
@@ -514,8 +514,9 @@ class DocTrRotationTransformer(ImageTransformer):
514
514
  self.number_contours = number_contours
515
515
  self.ratio_threshold_for_lines = ratio_threshold_for_lines
516
516
  self.name = "doctr_rotation_transformer"
517
+ self.model_id = self.get_model_id()
517
518
 
518
- def transform(self, np_img: PixelValues, specification: DetectionResult) -> PixelValues:
519
+ def transform_image(self, np_img: PixelValues, specification: DetectionResult) -> PixelValues:
519
520
  """
520
521
  Applies the predicted rotation to the image, effectively rotating the image backwards.
521
522
  This method uses either the Pillow library or OpenCV for the rotation operation, depending on the configuration.
@@ -423,7 +423,7 @@ class TesseractRotationTransformer(ImageTransformer):
423
423
  self.categories = ModelCategories(init_categories={1: PageType.ANGLE})
424
424
  self.model_id = self.get_model_id()
425
425
 
426
- def transform(self, np_img: PixelValues, specification: DetectionResult) -> PixelValues:
426
+ def transform_image(self, np_img: PixelValues, specification: DetectionResult) -> PixelValues:
427
427
  """
428
428
  Applies the predicted rotation to the image, effectively rotating the image backwards.
429
429
  This method uses either the Pillow library or OpenCV for the rotation operation, depending on the configuration.
@@ -15,9 +15,9 @@ from typing import Any, List, Optional, Tuple
15
15
  import numpy as np
16
16
  from lazy_imports import try_import
17
17
 
18
- from ....datapoint.convert import box_to_point4, point4_to_box
19
18
  from ....utils.error import MalformedData
20
19
  from ....utils.logger import log_once
20
+ from ....utils.transform import box_to_point4, point4_to_box
21
21
  from ....utils.types import JsonDict, PixelValues
22
22
  from .common import filter_boxes_inside_shape, np_iou
23
23
  from .modeling.model_fpn import get_all_anchors_fpn
@@ -31,11 +31,10 @@ import numpy.typing as npt
31
31
  from lazy_imports import try_import
32
32
 
33
33
  from ..datapoint.annotation import ContainerAnnotation
34
- from ..datapoint.convert import box_to_point4, point4_to_box
35
34
  from ..datapoint.image import Image
36
35
  from ..datapoint.view import Page
37
36
  from ..utils.settings import DatasetType, LayoutType, PageType, Relationships, WordType
38
- from ..utils.transform import ResizeTransform, normalize_image
37
+ from ..utils.transform import ResizeTransform, box_to_point4, normalize_image, point4_to_box
39
38
  from ..utils.types import JsonDict
40
39
  from .maputils import curry
41
40
 
@@ -157,8 +157,8 @@ def match_anns_by_intersection(
157
157
 
158
158
  def match_anns_by_distance(
159
159
  dp: Image,
160
- parent_ann_category_names: Optional[Union[TypeOrStr, Sequence[TypeOrStr]]]=None,
161
- child_ann_category_names: Optional[Union[TypeOrStr, Sequence[TypeOrStr]]]=None,
160
+ parent_ann_category_names: Optional[Union[TypeOrStr, Sequence[TypeOrStr]]] = None,
161
+ child_ann_category_names: Optional[Union[TypeOrStr, Sequence[TypeOrStr]]] = None,
162
162
  parent_ann_ids: Optional[Union[Sequence[str], str]] = None,
163
163
  child_ann_ids: Optional[Union[str, Sequence[str]]] = None,
164
164
  parent_ann_service_ids: Optional[Union[str, Sequence[str]]] = None,
@@ -51,8 +51,9 @@ class ImageCroppingService(PipelineComponent):
51
51
  """
52
52
 
53
53
  def __init__(
54
- self, category_names: Optional[Union[TypeOrStr, Sequence[TypeOrStr]]] = None,
55
- service_ids: Optional[Sequence[str]] = None
54
+ self,
55
+ category_names: Optional[Union[TypeOrStr, Sequence[TypeOrStr]]] = None,
56
+ service_ids: Optional[Sequence[str]] = None,
56
57
  ) -> None:
57
58
  """
58
59
  :param category_names: A single name or a list of category names to crop
@@ -153,8 +153,8 @@ class SubImageLayoutService(PipelineComponent):
153
153
  **Example**
154
154
 
155
155
  detect_result_generator = DetectResultGenerator(categories_items)
156
- d_items = TPFrcnnDetector(item_config_path, item_weights_path, {"1": LayoutType.row,
157
- "2": LayoutType.column})
156
+ d_items = TPFrcnnDetector(item_config_path, item_weights_path, {1: LayoutType.row,
157
+ 2: LayoutType.column})
158
158
  item_component = SubImageLayoutService(d_items, LayoutType.table, detect_result_generator)
159
159
  """
160
160
 
@@ -162,6 +162,7 @@ class SubImageLayoutService(PipelineComponent):
162
162
  self,
163
163
  sub_image_detector: ObjectDetector,
164
164
  sub_image_names: Union[str, Sequence[TypeOrStr]],
165
+ service_ids: Optional[Sequence[str]] = None,
165
166
  detect_result_generator: Optional[DetectResultGenerator] = None,
166
167
  padder: Optional[PadTransform] = None,
167
168
  ):
@@ -170,7 +171,8 @@ class SubImageLayoutService(PipelineComponent):
170
171
  :param sub_image_names: Category names of ImageAnnotations to be presented to the detector.
171
172
  Attention: The selected ImageAnnotations must have: attr:`image` and: attr:`image.image`
172
173
  not None.
173
- :param category_id_mapping: Mapping of category IDs. Usually, the category ids start with 1.
174
+ :param service_ids: List of service ids to be used for filtering the ImageAnnotations. If None, all
175
+ ImageAnnotations will be used.
174
176
  :param detect_result_generator: 'DetectResultGenerator' instance. 'categories' attribute has to be the same as
175
177
  the 'categories' attribute of the 'sub_image_detector'. The generator will be
176
178
  responsible to create 'DetectionResult' for some categories, if they have not
@@ -184,6 +186,7 @@ class SubImageLayoutService(PipelineComponent):
184
186
  if isinstance(sub_image_names, str)
185
187
  else tuple((get_type(cat) for cat in sub_image_names))
186
188
  )
189
+ self.service_ids = service_ids
187
190
  self.detect_result_generator = detect_result_generator
188
191
  self.padder = padder
189
192
  self.predictor = sub_image_detector
@@ -205,7 +208,7 @@ class SubImageLayoutService(PipelineComponent):
205
208
  - Optionally invoke the DetectResultGenerator
206
209
  - Generate ImageAnnotations and dump to parent image and sub image.
207
210
  """
208
- sub_image_anns = dp.get_annotation(category_names=self.sub_image_name)
211
+ sub_image_anns = dp.get_annotation(category_names=self.sub_image_name, service_ids=self.service_ids)
209
212
  for sub_image_ann in sub_image_anns:
210
213
  np_image = self.prepare_np_image(sub_image_ann)
211
214
  detect_result_list = self.predictor.predict(np_image)
@@ -246,6 +249,7 @@ class SubImageLayoutService(PipelineComponent):
246
249
  return self.__class__(
247
250
  predictor,
248
251
  self.sub_image_name,
252
+ self.service_ids,
249
253
  self.detect_result_generator,
250
254
  padder_clone,
251
255
  )
@@ -1,5 +1,5 @@
1
1
  # -*- coding: utf-8 -*-
2
- # File: transform.py
2
+ # File: test_transform.py
3
3
 
4
4
  # Copyright 2022 Dr. Janis Meyer. All rights reserved.
5
5
  #
@@ -22,6 +22,7 @@ on images (e.g. deskew, de-noising or more general GAN like operations.
22
22
 
23
23
  from __future__ import annotations
24
24
 
25
+ from .. import DetectionResult
25
26
  from ..datapoint.image import Image
26
27
  from ..extern.base import ImageTransformer
27
28
  from .base import MetaAnnotation, PipelineComponent
@@ -49,25 +50,46 @@ class SimpleTransformService(PipelineComponent):
49
50
  super().__init__(self._get_name(transform_predictor.name), self.transform_predictor.model_id)
50
51
 
51
52
  def serve(self, dp: Image) -> None:
52
- if dp.annotations:
53
- raise RuntimeError(
54
- "SimpleTransformService receives datapoints with ÌmageAnnotations. This violates the "
55
- "pipeline building API but this can currently be catched only at runtime. "
56
- "Please make sure that this component is the first one in the pipeline."
57
- )
58
-
59
53
  if dp.image is not None:
60
54
  detection_result = self.transform_predictor.predict(dp.image)
61
- transformed_image = self.transform_predictor.transform(dp.image, detection_result)
55
+ transformed_image = self.transform_predictor.transform_image(dp.image, detection_result)
62
56
  self.dp_manager.datapoint.clear_image(True)
63
57
  self.dp_manager.datapoint.image = transformed_image
64
- self.dp_manager.set_summary_annotation(
65
- summary_key=self.transform_predictor.get_category_names()[0],
66
- summary_name=self.transform_predictor.get_category_names()[0],
67
- summary_number=None,
68
- summary_value=getattr(detection_result, self.transform_predictor.get_category_names()[0].value, None),
69
- summary_score=detection_result.score,
70
- )
58
+ for category in self.transform_predictor.get_category_names():
59
+ self.dp_manager.set_summary_annotation(
60
+ summary_key=category,
61
+ summary_name=category,
62
+ summary_number=None,
63
+ summary_value=getattr(detection_result, category.value, None),
64
+ summary_score=detection_result.score,
65
+ )
66
+ detect_results = []
67
+ for ann in dp.get_annotation():
68
+ box = ann.get_bounding_box()
69
+ if not box.absolute_coords:
70
+ box = box.transform(dp.width, dp.height)
71
+ detect_results.append(
72
+ DetectionResult(
73
+ box=box.to_list(mode="xyxy"),
74
+ class_name=ann.category_name, # type: ignore
75
+ score=ann.score,
76
+ class_id=ann.category_id,
77
+ uuid=ann.annotation_id,
78
+ )
79
+ )
80
+ output_detect_results = self.transform_predictor.transform_coords(detect_results)
81
+ for detect_result in output_detect_results:
82
+ ann = dp.get_annotation(annotation_ids=detect_result.uuid)[0]
83
+ transformed_ann_id = self.dp_manager.set_image_annotation(detect_result)
84
+ if transformed_ann_id is None:
85
+ print("here")
86
+ transformed_ann = self.dp_manager.datapoint.get_annotation(annotation_ids=transformed_ann_id)[0]
87
+
88
+ for key, sub_ann in ann.sub_categories.items():
89
+ transformed_ann.dump_sub_category(key, sub_ann)
90
+ if ann.image is not None:
91
+ dp.image_ann_to_image(transformed_ann.annotation_id, ann.image.image is not None)
92
+ ann.deactivate()
71
93
 
72
94
  def clone(self) -> SimpleTransformService:
73
95
  return self.__class__(self.transform_predictor)
@@ -67,6 +67,11 @@ class PageType(ObjectTypes):
67
67
  DOCUMENT_TYPE = "document_type"
68
68
  LANGUAGE = "language"
69
69
  ANGLE = "angle"
70
+ SIZE = "size"
71
+ PAD_TOP = "pad_top"
72
+ PAD_BOTTOM = "pad_bottom"
73
+ PAD_LEFT = "pad_left"
74
+ PAD_RIGHT = "pad_right"
70
75
 
71
76
 
72
77
  @object_types_registry.register("SummaryType")