deepdoctection 1.0.4__tar.gz → 1.0.6__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.
Files changed (58) hide show
  1. {deepdoctection-1.0.4 → deepdoctection-1.0.6}/PKG-INFO +1 -1
  2. {deepdoctection-1.0.4 → deepdoctection-1.0.6}/pyproject.toml +1 -1
  3. {deepdoctection-1.0.4 → deepdoctection-1.0.6}/src/deepdoctection/__init__.py +1 -1
  4. {deepdoctection-1.0.4 → deepdoctection-1.0.6}/src/deepdoctection/extern/base.py +2 -0
  5. {deepdoctection-1.0.4 → deepdoctection-1.0.6}/src/deepdoctection/pipe/anngen.py +66 -4
  6. {deepdoctection-1.0.4 → deepdoctection-1.0.6}/src/deepdoctection.egg-info/PKG-INFO +1 -1
  7. {deepdoctection-1.0.4 → deepdoctection-1.0.6}/README.md +0 -0
  8. {deepdoctection-1.0.4 → deepdoctection-1.0.6}/setup.cfg +0 -0
  9. {deepdoctection-1.0.4 → deepdoctection-1.0.6}/src/deepdoctection/analyzer/__init__.py +0 -0
  10. {deepdoctection-1.0.4 → deepdoctection-1.0.6}/src/deepdoctection/analyzer/config.py +0 -0
  11. {deepdoctection-1.0.4 → deepdoctection-1.0.6}/src/deepdoctection/analyzer/dd.py +0 -0
  12. {deepdoctection-1.0.4 → deepdoctection-1.0.6}/src/deepdoctection/analyzer/factory.py +0 -0
  13. {deepdoctection-1.0.4 → deepdoctection-1.0.6}/src/deepdoctection/configs/__init__.py +0 -0
  14. {deepdoctection-1.0.4 → deepdoctection-1.0.6}/src/deepdoctection/configs/conf_dd_one.yaml +0 -0
  15. {deepdoctection-1.0.4 → deepdoctection-1.0.6}/src/deepdoctection/configs/conf_tesseract.yaml +0 -0
  16. {deepdoctection-1.0.4 → deepdoctection-1.0.6}/src/deepdoctection/configs/profiles.jsonl +0 -0
  17. {deepdoctection-1.0.4 → deepdoctection-1.0.6}/src/deepdoctection/eval/__init__.py +0 -0
  18. {deepdoctection-1.0.4 → deepdoctection-1.0.6}/src/deepdoctection/eval/accmetric.py +0 -0
  19. {deepdoctection-1.0.4 → deepdoctection-1.0.6}/src/deepdoctection/eval/base.py +0 -0
  20. {deepdoctection-1.0.4 → deepdoctection-1.0.6}/src/deepdoctection/eval/cocometric.py +0 -0
  21. {deepdoctection-1.0.4 → deepdoctection-1.0.6}/src/deepdoctection/eval/eval.py +0 -0
  22. {deepdoctection-1.0.4 → deepdoctection-1.0.6}/src/deepdoctection/eval/registry.py +0 -0
  23. {deepdoctection-1.0.4 → deepdoctection-1.0.6}/src/deepdoctection/eval/tedsmetric.py +0 -0
  24. {deepdoctection-1.0.4 → deepdoctection-1.0.6}/src/deepdoctection/extern/__init__.py +0 -0
  25. {deepdoctection-1.0.4 → deepdoctection-1.0.6}/src/deepdoctection/extern/d2detect.py +0 -0
  26. {deepdoctection-1.0.4 → deepdoctection-1.0.6}/src/deepdoctection/extern/deskew.py +0 -0
  27. {deepdoctection-1.0.4 → deepdoctection-1.0.6}/src/deepdoctection/extern/doctrocr.py +0 -0
  28. {deepdoctection-1.0.4 → deepdoctection-1.0.6}/src/deepdoctection/extern/hfdetr.py +0 -0
  29. {deepdoctection-1.0.4 → deepdoctection-1.0.6}/src/deepdoctection/extern/hflayoutlm.py +0 -0
  30. {deepdoctection-1.0.4 → deepdoctection-1.0.6}/src/deepdoctection/extern/hflm.py +0 -0
  31. {deepdoctection-1.0.4 → deepdoctection-1.0.6}/src/deepdoctection/extern/model.py +0 -0
  32. {deepdoctection-1.0.4 → deepdoctection-1.0.6}/src/deepdoctection/extern/pdftext.py +0 -0
  33. {deepdoctection-1.0.4 → deepdoctection-1.0.6}/src/deepdoctection/extern/tessocr.py +0 -0
  34. {deepdoctection-1.0.4 → deepdoctection-1.0.6}/src/deepdoctection/extern/texocr.py +0 -0
  35. {deepdoctection-1.0.4 → deepdoctection-1.0.6}/src/deepdoctection/pipe/__init__.py +0 -0
  36. {deepdoctection-1.0.4 → deepdoctection-1.0.6}/src/deepdoctection/pipe/base.py +0 -0
  37. {deepdoctection-1.0.4 → deepdoctection-1.0.6}/src/deepdoctection/pipe/common.py +0 -0
  38. {deepdoctection-1.0.4 → deepdoctection-1.0.6}/src/deepdoctection/pipe/concurrency.py +0 -0
  39. {deepdoctection-1.0.4 → deepdoctection-1.0.6}/src/deepdoctection/pipe/doctectionpipe.py +0 -0
  40. {deepdoctection-1.0.4 → deepdoctection-1.0.6}/src/deepdoctection/pipe/language.py +0 -0
  41. {deepdoctection-1.0.4 → deepdoctection-1.0.6}/src/deepdoctection/pipe/layout.py +0 -0
  42. {deepdoctection-1.0.4 → deepdoctection-1.0.6}/src/deepdoctection/pipe/lm.py +0 -0
  43. {deepdoctection-1.0.4 → deepdoctection-1.0.6}/src/deepdoctection/pipe/order.py +0 -0
  44. {deepdoctection-1.0.4 → deepdoctection-1.0.6}/src/deepdoctection/pipe/refine.py +0 -0
  45. {deepdoctection-1.0.4 → deepdoctection-1.0.6}/src/deepdoctection/pipe/registry.py +0 -0
  46. {deepdoctection-1.0.4 → deepdoctection-1.0.6}/src/deepdoctection/pipe/segment.py +0 -0
  47. {deepdoctection-1.0.4 → deepdoctection-1.0.6}/src/deepdoctection/pipe/sub_layout.py +0 -0
  48. {deepdoctection-1.0.4 → deepdoctection-1.0.6}/src/deepdoctection/pipe/text.py +0 -0
  49. {deepdoctection-1.0.4 → deepdoctection-1.0.6}/src/deepdoctection/pipe/transform.py +0 -0
  50. {deepdoctection-1.0.4 → deepdoctection-1.0.6}/src/deepdoctection/py.typed +0 -0
  51. {deepdoctection-1.0.4 → deepdoctection-1.0.6}/src/deepdoctection/train/__init__.py +0 -0
  52. {deepdoctection-1.0.4 → deepdoctection-1.0.6}/src/deepdoctection/train/d2_frcnn_train.py +0 -0
  53. {deepdoctection-1.0.4 → deepdoctection-1.0.6}/src/deepdoctection/train/hf_detr_train.py +0 -0
  54. {deepdoctection-1.0.4 → deepdoctection-1.0.6}/src/deepdoctection/train/hf_layoutlm_train.py +0 -0
  55. {deepdoctection-1.0.4 → deepdoctection-1.0.6}/src/deepdoctection.egg-info/SOURCES.txt +0 -0
  56. {deepdoctection-1.0.4 → deepdoctection-1.0.6}/src/deepdoctection.egg-info/dependency_links.txt +0 -0
  57. {deepdoctection-1.0.4 → deepdoctection-1.0.6}/src/deepdoctection.egg-info/requires.txt +0 -0
  58. {deepdoctection-1.0.4 → deepdoctection-1.0.6}/src/deepdoctection.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: deepdoctection
3
- Version: 1.0.4
3
+ Version: 1.0.6
4
4
  Summary: Repository for Document AI - server/inference core package
5
5
  Author: Dr. Janis Meyer
6
6
  License: Apache License 2.0
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "deepdoctection"
7
- version = "1.0.4"
7
+ version = "1.0.6"
8
8
  authors = [
9
9
  {name = "Dr. Janis Meyer"}
10
10
  ]
@@ -12,7 +12,7 @@ from dd_core.utils.env_info import collect_env_info
12
12
  from dd_core.utils.file_utils import _LazyModule
13
13
  from dd_core.utils.logger import LoggingRecord, logger
14
14
 
15
- __version__ = "1.0.4"
15
+ __version__ = "1.0.6"
16
16
  _IMPORT_STRUCTURE = {
17
17
  "analyzer": ["config_sanity_checks", "get_dd_analyzer", "ServiceFactory", "update_cfg_from_defaults"],
18
18
  "eval": [
@@ -512,6 +512,7 @@ class TokenClassResult:
512
512
  bio_tag: bio tag
513
513
  score: prediction score
514
514
  successor_uuid: uuid of the next token in the sequence
515
+ ambiguous: boolean flag indicating whether this token is ambiguous
515
516
  """
516
517
 
517
518
  uuid: str
@@ -523,6 +524,7 @@ class TokenClassResult:
523
524
  score: Optional[float] = None
524
525
  token_id: Optional[int] = None
525
526
  successor_uuid: Optional[str] = None
527
+ ambiguous: bool = False
526
528
 
527
529
 
528
530
  @dataclass
@@ -18,8 +18,9 @@
18
18
  """
19
19
  Datapoint manager
20
20
  """
21
+ from collections import deque
21
22
  from dataclasses import asdict
22
- from typing import Optional, Sequence, Union
23
+ from typing import Any, Optional, Sequence, Union
23
24
 
24
25
  import numpy as np
25
26
 
@@ -40,10 +41,29 @@ class DatapointManager:
40
41
  When the image is transferred, the annotations are stored in a cache dictionary so that access via the annotation ID
41
42
  can be performed efficiently.
42
43
 
44
+ Datapoint caching (FIFO):
45
+ The manager can keep a bounded FIFO cache of previously assigned datapoints. The cache is controlled by
46
+ `num_cached_datapoints`:
47
+ - If `num_cached_datapoints` is 0, caching is disabled.
48
+ - If `num_cached_datapoints` is > 0, whenever a new datapoint is assigned via the `datapoint` setter, the
49
+ previously set datapoint (if any) is appended to an internal FIFO cache.
50
+ - If the cache grows beyond `num_cached_datapoints`, the oldest cached datapoints are evicted first (FIFO).
51
+
52
+ When `remove_pixel_values_from_cache` is True, an `Image` being added to the cache is light-weighted to reduce
53
+ memory usage by calling:
54
+ - `image.clear_image()`
55
+ - `image.remove_image_from_lower_hierarchy(pixel_values_only=True)`
56
+
43
57
  The manager is part of each `PipelineComponent`.
44
58
  """
45
59
 
46
- def __init__(self, service_id: str, model_id: Optional[str] = None) -> None:
60
+ def __init__(
61
+ self,
62
+ service_id: str,
63
+ model_id: Optional[str] = None,
64
+ num_cached_datapoints: int = 0,
65
+ remove_pixel_values_from_cache: bool = True,
66
+ ) -> None:
47
67
  self._datapoint: Optional[Image] = None
48
68
  self._cache_anns: dict[str, ImageAnnotation] = {}
49
69
  self.datapoint_is_passed: bool = False
@@ -51,6 +71,27 @@ class DatapointManager:
51
71
  self.model_id = model_id
52
72
  self.session_id: Optional[str] = None
53
73
 
74
+ if num_cached_datapoints < 0:
75
+ raise ValueError("num_cached_datapoints must be >= 0")
76
+ self.num_cached_datapoints = num_cached_datapoints
77
+ self.remove_pixel_values_from_cache = remove_pixel_values_from_cache
78
+ self._cached_datapoints: deque[Image] = deque()
79
+
80
+ def _maybe_cache_datapoint(self, image: Optional[Image]) -> None:
81
+ if image is None:
82
+ return
83
+ if self.num_cached_datapoints <= 0:
84
+ return
85
+
86
+ if self.remove_pixel_values_from_cache:
87
+ image.clear_image()
88
+ image.remove_image_from_lower_hierarchy(pixel_values_only=True)
89
+
90
+ self._cached_datapoints.append(image)
91
+
92
+ while len(self._cached_datapoints) > self.num_cached_datapoints:
93
+ self._cached_datapoints.popleft()
94
+
54
95
  @property
55
96
  def datapoint(self) -> Image:
56
97
  """
@@ -74,6 +115,8 @@ class DatapointManager:
74
115
  Args:
75
116
  dp: The datapoint to set.
76
117
  """
118
+ self._maybe_cache_datapoint(self._datapoint)
119
+
77
120
  self._datapoint = dp
78
121
  self._cache_anns = {ann.annotation_id: ann for ann in dp.get_annotation()}
79
122
  self.datapoint_is_passed = True
@@ -323,7 +366,7 @@ class DatapointManager:
323
366
  summary_key: ObjectTypes,
324
367
  summary_name: ObjectTypes,
325
368
  summary_number: Optional[int] = None,
326
- summary_value: Optional[str] = None,
369
+ summary_value: Optional[Union[str, int, float, list[str], dict[str, Any]]] = None,
327
370
  summary_score: Optional[float] = None,
328
371
  annotation_id: Optional[str] = None,
329
372
  ) -> Optional[str]:
@@ -357,7 +400,7 @@ class DatapointManager:
357
400
  summary_annotation={
358
401
  "summary_key": summary_key.value,
359
402
  "summary_name": summary_name.value,
360
- "summary_value": summary_value,
403
+ "summary_value": str(summary_value),
361
404
  "annotation_id": annotation_id,
362
405
  },
363
406
  ) as annotation_context:
@@ -420,3 +463,22 @@ class DatapointManager:
420
463
  The `ImageAnnotation` corresponding to the given `annotation_id`.
421
464
  """
422
465
  return self._cache_anns[annotation_id]
466
+
467
+ def get_cached_datapoints(self, last_k: int) -> tuple[Image, ...]:
468
+ """
469
+ Returns a snapshot of the last `last_k` cached datapoints without removing them.
470
+
471
+ Args:
472
+ last_k: Number of most recently cached datapoints to return. Must be >= 0.
473
+
474
+ Returns:
475
+ A tuple containing up to the last `last_k` cached `Image` objects, ordered from older -> newer.
476
+ If `last_k` exceeds the number of cached datapoints, all cached datapoints are returned.
477
+ """
478
+ if last_k < 0:
479
+ raise ValueError("last_k must be >= 0")
480
+ if last_k == 0 or not self._cached_datapoints:
481
+ return tuple()
482
+
483
+ k = min(last_k, len(self._cached_datapoints))
484
+ return tuple(list(self._cached_datapoints)[-k:])
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: deepdoctection
3
- Version: 1.0.4
3
+ Version: 1.0.6
4
4
  Summary: Repository for Document AI - server/inference core package
5
5
  Author: Dr. Janis Meyer
6
6
  License: Apache License 2.0
File without changes
File without changes