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.
- deepdoctection/__init__.py +2 -1
- deepdoctection/analyzer/__init__.py +2 -1
- deepdoctection/analyzer/config.py +904 -0
- deepdoctection/analyzer/dd.py +36 -62
- deepdoctection/analyzer/factory.py +311 -141
- deepdoctection/configs/conf_dd_one.yaml +100 -44
- deepdoctection/configs/profiles.jsonl +32 -0
- deepdoctection/dataflow/__init__.py +9 -6
- deepdoctection/dataflow/base.py +33 -15
- deepdoctection/dataflow/common.py +96 -75
- deepdoctection/dataflow/custom.py +36 -29
- deepdoctection/dataflow/custom_serialize.py +135 -91
- deepdoctection/dataflow/parallel_map.py +33 -31
- deepdoctection/dataflow/serialize.py +15 -10
- deepdoctection/dataflow/stats.py +41 -28
- deepdoctection/datapoint/__init__.py +4 -6
- deepdoctection/datapoint/annotation.py +104 -66
- deepdoctection/datapoint/box.py +190 -130
- deepdoctection/datapoint/convert.py +66 -39
- deepdoctection/datapoint/image.py +151 -95
- deepdoctection/datapoint/view.py +383 -236
- deepdoctection/datasets/__init__.py +2 -6
- deepdoctection/datasets/adapter.py +11 -11
- deepdoctection/datasets/base.py +118 -81
- deepdoctection/datasets/dataflow_builder.py +18 -12
- deepdoctection/datasets/info.py +76 -57
- deepdoctection/datasets/instances/__init__.py +6 -2
- deepdoctection/datasets/instances/doclaynet.py +17 -14
- deepdoctection/datasets/instances/fintabnet.py +16 -22
- deepdoctection/datasets/instances/funsd.py +11 -6
- deepdoctection/datasets/instances/iiitar13k.py +9 -9
- deepdoctection/datasets/instances/layouttest.py +9 -9
- deepdoctection/datasets/instances/publaynet.py +9 -9
- deepdoctection/datasets/instances/pubtables1m.py +13 -13
- deepdoctection/datasets/instances/pubtabnet.py +13 -15
- deepdoctection/datasets/instances/rvlcdip.py +8 -8
- deepdoctection/datasets/instances/xfund.py +11 -9
- deepdoctection/datasets/registry.py +18 -11
- deepdoctection/datasets/save.py +12 -11
- deepdoctection/eval/__init__.py +3 -2
- deepdoctection/eval/accmetric.py +72 -52
- deepdoctection/eval/base.py +29 -10
- deepdoctection/eval/cocometric.py +14 -12
- deepdoctection/eval/eval.py +56 -41
- deepdoctection/eval/registry.py +6 -3
- deepdoctection/eval/tedsmetric.py +24 -9
- deepdoctection/eval/tp_eval_callback.py +13 -12
- deepdoctection/extern/__init__.py +1 -1
- deepdoctection/extern/base.py +176 -97
- deepdoctection/extern/d2detect.py +127 -92
- deepdoctection/extern/deskew.py +19 -10
- deepdoctection/extern/doctrocr.py +157 -106
- deepdoctection/extern/fastlang.py +25 -17
- deepdoctection/extern/hfdetr.py +137 -60
- deepdoctection/extern/hflayoutlm.py +329 -248
- deepdoctection/extern/hflm.py +67 -33
- deepdoctection/extern/model.py +108 -762
- deepdoctection/extern/pdftext.py +37 -12
- deepdoctection/extern/pt/nms.py +15 -1
- deepdoctection/extern/pt/ptutils.py +13 -9
- deepdoctection/extern/tessocr.py +87 -54
- deepdoctection/extern/texocr.py +29 -14
- deepdoctection/extern/tp/tfutils.py +36 -8
- deepdoctection/extern/tp/tpcompat.py +54 -16
- deepdoctection/extern/tp/tpfrcnn/config/config.py +20 -4
- deepdoctection/extern/tpdetect.py +4 -2
- deepdoctection/mapper/__init__.py +1 -1
- deepdoctection/mapper/cats.py +117 -76
- deepdoctection/mapper/cocostruct.py +35 -17
- deepdoctection/mapper/d2struct.py +56 -29
- deepdoctection/mapper/hfstruct.py +32 -19
- deepdoctection/mapper/laylmstruct.py +221 -185
- deepdoctection/mapper/maputils.py +71 -35
- deepdoctection/mapper/match.py +76 -62
- deepdoctection/mapper/misc.py +68 -44
- deepdoctection/mapper/pascalstruct.py +13 -12
- deepdoctection/mapper/prodigystruct.py +33 -19
- deepdoctection/mapper/pubstruct.py +42 -32
- deepdoctection/mapper/tpstruct.py +39 -19
- deepdoctection/mapper/xfundstruct.py +20 -13
- deepdoctection/pipe/__init__.py +1 -2
- deepdoctection/pipe/anngen.py +104 -62
- deepdoctection/pipe/base.py +226 -107
- deepdoctection/pipe/common.py +206 -123
- deepdoctection/pipe/concurrency.py +74 -47
- deepdoctection/pipe/doctectionpipe.py +108 -47
- deepdoctection/pipe/language.py +41 -24
- deepdoctection/pipe/layout.py +45 -18
- deepdoctection/pipe/lm.py +146 -78
- deepdoctection/pipe/order.py +196 -113
- deepdoctection/pipe/refine.py +111 -63
- deepdoctection/pipe/registry.py +1 -1
- deepdoctection/pipe/segment.py +213 -142
- deepdoctection/pipe/sub_layout.py +76 -46
- deepdoctection/pipe/text.py +52 -33
- deepdoctection/pipe/transform.py +8 -6
- deepdoctection/train/d2_frcnn_train.py +87 -69
- deepdoctection/train/hf_detr_train.py +72 -40
- deepdoctection/train/hf_layoutlm_train.py +85 -46
- deepdoctection/train/tp_frcnn_train.py +56 -28
- deepdoctection/utils/concurrency.py +59 -16
- deepdoctection/utils/context.py +40 -19
- deepdoctection/utils/develop.py +25 -17
- deepdoctection/utils/env_info.py +85 -36
- deepdoctection/utils/error.py +16 -10
- deepdoctection/utils/file_utils.py +246 -62
- deepdoctection/utils/fs.py +162 -43
- deepdoctection/utils/identifier.py +29 -16
- deepdoctection/utils/logger.py +49 -32
- deepdoctection/utils/metacfg.py +83 -21
- deepdoctection/utils/pdf_utils.py +119 -62
- deepdoctection/utils/settings.py +24 -10
- deepdoctection/utils/tqdm.py +10 -5
- deepdoctection/utils/transform.py +182 -46
- deepdoctection/utils/utils.py +61 -28
- deepdoctection/utils/viz.py +150 -104
- deepdoctection-0.43.dist-info/METADATA +376 -0
- deepdoctection-0.43.dist-info/RECORD +149 -0
- {deepdoctection-0.42.0.dist-info → deepdoctection-0.43.dist-info}/WHEEL +1 -1
- deepdoctection/analyzer/_config.py +0 -146
- deepdoctection-0.42.0.dist-info/METADATA +0 -431
- deepdoctection-0.42.0.dist-info/RECORD +0 -148
- {deepdoctection-0.42.0.dist-info → deepdoctection-0.43.dist-info}/licenses/LICENSE +0 -0
- {deepdoctection-0.42.0.dist-info → deepdoctection-0.43.dist-info}/top_level.txt +0 -0
deepdoctection/utils/context.py
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
# limitations under the License.
|
|
17
17
|
|
|
18
18
|
"""
|
|
19
|
-
|
|
19
|
+
Contextmanagers for various tasks
|
|
20
20
|
"""
|
|
21
21
|
|
|
22
22
|
import subprocess
|
|
@@ -38,15 +38,26 @@ __all__ = ["timeout_manager", "save_tmp_file", "timed_operation"]
|
|
|
38
38
|
|
|
39
39
|
|
|
40
40
|
@contextmanager
|
|
41
|
-
def timeout_manager(proc, seconds: Optional[int] = None) -> Iterator[str]: # type: ignore
|
|
41
|
+
def timeout_manager(proc: Any, seconds: Optional[int] = None) -> Iterator[str]: # type: ignore
|
|
42
42
|
"""
|
|
43
|
-
Manager for time handling while some process being called
|
|
43
|
+
Manager for time handling while some process is being called.
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
Example:
|
|
46
|
+
```python
|
|
47
|
+
with timeout_manager(some_process, 60) as timeout:
|
|
48
|
+
...
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Args:
|
|
52
|
+
proc: Process.
|
|
53
|
+
seconds: Seconds to wait.
|
|
54
|
+
|
|
55
|
+
Yields:
|
|
56
|
+
str: Error string from the process.
|
|
57
|
+
|
|
58
|
+
Raises:
|
|
59
|
+
RuntimeError: If the process times out.
|
|
47
60
|
|
|
48
|
-
:param proc: process
|
|
49
|
-
:param seconds: seconds to wait
|
|
50
61
|
|
|
51
62
|
"""
|
|
52
63
|
try:
|
|
@@ -74,13 +85,20 @@ def timeout_manager(proc, seconds: Optional[int] = None) -> Iterator[str]: # ty
|
|
|
74
85
|
@contextmanager
|
|
75
86
|
def save_tmp_file(image: Union[B64Str, PixelValues, B64], prefix: str) -> Iterator[tuple[str, str]]:
|
|
76
87
|
"""
|
|
77
|
-
Save image temporarily and handle the clean-up once not necessary anymore
|
|
88
|
+
Save image temporarily and handle the clean-up once not necessary anymore.
|
|
78
89
|
|
|
79
|
-
|
|
80
|
-
|
|
90
|
+
Args:
|
|
91
|
+
image: Image as string or `np.array`.
|
|
92
|
+
prefix: Prefix of the temp file name.
|
|
81
93
|
|
|
82
|
-
:
|
|
83
|
-
|
|
94
|
+
Yields:
|
|
95
|
+
Tuple containing the temporary file name and the input file name.
|
|
96
|
+
|
|
97
|
+
Example:
|
|
98
|
+
```python
|
|
99
|
+
with save_tmp_file(some_np_image, "tmp") as (tmp_name, input_file_name):
|
|
100
|
+
...
|
|
101
|
+
```
|
|
84
102
|
"""
|
|
85
103
|
try:
|
|
86
104
|
with NamedTemporaryFile(prefix=prefix, delete=False) as file:
|
|
@@ -112,18 +130,21 @@ def save_tmp_file(image: Union[B64Str, PixelValues, B64], prefix: str) -> Iterat
|
|
|
112
130
|
@contextmanager
|
|
113
131
|
def timed_operation(message: str, log_start: bool = False) -> Generator[Any, None, None]:
|
|
114
132
|
"""
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
... code-block:: python
|
|
133
|
+
Context manager with a timer.
|
|
118
134
|
|
|
135
|
+
Example:
|
|
136
|
+
```python
|
|
119
137
|
with timed_operation(message="Your stdout message", log_start=True):
|
|
120
|
-
|
|
121
138
|
with open("log.txt", "a") as file:
|
|
122
|
-
|
|
139
|
+
...
|
|
140
|
+
```
|
|
123
141
|
|
|
142
|
+
Args:
|
|
143
|
+
message: A log to stdout.
|
|
144
|
+
log_start: Whether to print also the beginning.
|
|
124
145
|
|
|
125
|
-
:
|
|
126
|
-
|
|
146
|
+
Yields:
|
|
147
|
+
None
|
|
127
148
|
"""
|
|
128
149
|
|
|
129
150
|
if log_start:
|
deepdoctection/utils/develop.py
CHANGED
|
@@ -40,12 +40,16 @@ _DEPRECATED_LOG_NUM = defaultdict(int) # type: ignore
|
|
|
40
40
|
|
|
41
41
|
def log_deprecated(name: str, text: str, eos: str = "", max_num_warnings: Optional[int] = None) -> None:
|
|
42
42
|
"""
|
|
43
|
-
|
|
43
|
+
Logs a deprecation warning.
|
|
44
44
|
|
|
45
|
-
:
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
45
|
+
Args:
|
|
46
|
+
name: Name of the deprecated item.
|
|
47
|
+
text: Information about the deprecation.
|
|
48
|
+
eos: End of service date such as "YYYY-MM-DD".
|
|
49
|
+
max_num_warnings: The maximum number of times to print this warning.
|
|
50
|
+
|
|
51
|
+
Note:
|
|
52
|
+
Either `name` or `text` must be provided.
|
|
49
53
|
"""
|
|
50
54
|
assert name or text
|
|
51
55
|
if eos:
|
|
@@ -71,18 +75,22 @@ def deprecated(
|
|
|
71
75
|
text: str = "", eos: str = "", max_num_warnings: Optional[int] = None
|
|
72
76
|
) -> Callable[[Callable[..., T]], Callable[..., T]]:
|
|
73
77
|
"""
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
:
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
78
|
+
Decorator to deprecate a function.
|
|
79
|
+
|
|
80
|
+
Example:
|
|
81
|
+
```python
|
|
82
|
+
@deprecated("Explanation of what to do instead.", "2017-11-4")
|
|
83
|
+
def foo(...):
|
|
84
|
+
pass
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Args:
|
|
88
|
+
text: Same as `log_deprecated`.
|
|
89
|
+
eos: Same as `log_deprecated`.
|
|
90
|
+
max_num_warnings: Same as `log_deprecated`.
|
|
91
|
+
|
|
92
|
+
Returns:
|
|
93
|
+
A decorator which deprecates the function.
|
|
86
94
|
"""
|
|
87
95
|
|
|
88
96
|
def get_location() -> str:
|
deepdoctection/utils/env_info.py
CHANGED
|
@@ -16,41 +16,53 @@
|
|
|
16
16
|
# limitations under the License.
|
|
17
17
|
|
|
18
18
|
"""
|
|
19
|
-
|
|
19
|
+
Function for collecting environment information.
|
|
20
20
|
|
|
21
|
-
This is also the place where we give an overview of
|
|
21
|
+
This is also the place where we give an overview of some environment variables.
|
|
22
22
|
|
|
23
23
|
For env variables with boolean character, use one of the following values:
|
|
24
24
|
|
|
25
|
+
```python
|
|
25
26
|
{"1", "True", "TRUE", "true", "yes"}
|
|
27
|
+
```
|
|
26
28
|
|
|
27
|
-
|
|
29
|
+
```python
|
|
30
|
+
USE_TENSORFLOW
|
|
28
31
|
USE_PYTORCH
|
|
29
32
|
USE_CUDA
|
|
30
|
-
USE_MPS
|
|
33
|
+
USE_MPS
|
|
34
|
+
```
|
|
31
35
|
|
|
32
36
|
are responsible for selecting the predictors based on the installed DL framework and available devices.
|
|
33
37
|
It is not recommended to touch them.
|
|
34
38
|
|
|
35
|
-
|
|
36
|
-
|
|
39
|
+
```python
|
|
40
|
+
USE_DD_PILLOW
|
|
41
|
+
USE_DD_OPENCV
|
|
42
|
+
```
|
|
37
43
|
|
|
38
44
|
decide what image processing library the `viz_handler` should use. The default library is PIL and OpenCV need
|
|
39
45
|
to be installed separately. However, if both libraries have been detected `viz_handler` will opt for OpenCV.
|
|
40
46
|
Use the variables to let choose `viz_handler` according to your preferences.
|
|
41
47
|
|
|
42
|
-
|
|
43
|
-
|
|
48
|
+
```python
|
|
49
|
+
USE_DD_POPPLER
|
|
50
|
+
USE_DD_PDFIUM
|
|
51
|
+
```
|
|
44
52
|
|
|
45
53
|
For PDF rendering we use PyPDFium2 as default but for legacy reasons, we also support Poppler. If you want to enforce
|
|
46
|
-
Poppler set one to `USE_DD_POPPLER=True` and `USE_DD_PDFIUM=False` the other to False
|
|
54
|
+
Poppler set one to `USE_DD_POPPLER=True` and `USE_DD_PDFIUM=False` the other to `False`.
|
|
47
55
|
|
|
48
|
-
|
|
56
|
+
```python
|
|
57
|
+
HF_CREDENTIALS
|
|
58
|
+
```
|
|
49
59
|
|
|
50
60
|
will be used by the `ModelDownloadManager` to pass your credentials if you have a model registered that resides in a
|
|
51
61
|
private repo.
|
|
52
62
|
|
|
53
|
-
|
|
63
|
+
```python
|
|
64
|
+
MODEL_CATALOG
|
|
65
|
+
```
|
|
54
66
|
|
|
55
67
|
can store an (absolute) path to a `.jsonl` file.
|
|
56
68
|
|
|
@@ -108,7 +120,12 @@ ENV_VARS_TRUE: set[str] = {"1", "True", "TRUE", "true", "yes"}
|
|
|
108
120
|
|
|
109
121
|
|
|
110
122
|
def collect_torch_env() -> str:
|
|
111
|
-
"""
|
|
123
|
+
"""
|
|
124
|
+
Wrapper for `torch.utils.collect_env.get_pretty_env_info`.
|
|
125
|
+
|
|
126
|
+
Returns:
|
|
127
|
+
The environment information as a string.
|
|
128
|
+
"""
|
|
112
129
|
try:
|
|
113
130
|
import torch.__config__
|
|
114
131
|
|
|
@@ -121,10 +138,14 @@ def collect_torch_env() -> str:
|
|
|
121
138
|
|
|
122
139
|
|
|
123
140
|
def collect_installed_dependencies(data: KeyValEnvInfos) -> KeyValEnvInfos:
|
|
124
|
-
"""
|
|
141
|
+
"""
|
|
142
|
+
Collect installed dependencies for all third party libraries.
|
|
143
|
+
|
|
144
|
+
Args:
|
|
145
|
+
data: A list of tuples to dump all collected package information such as the name and the version.
|
|
125
146
|
|
|
126
|
-
:
|
|
127
|
-
|
|
147
|
+
Returns:
|
|
148
|
+
A list of tuples containing the name of the library and the version (if available).
|
|
128
149
|
"""
|
|
129
150
|
|
|
130
151
|
if tensorpack_available():
|
|
@@ -249,9 +270,12 @@ def detect_compute_compatibility(cuda_home: Optional[PathLikeOrStr], so_file: Op
|
|
|
249
270
|
"""
|
|
250
271
|
Detect the compute compatibility of a CUDA library.
|
|
251
272
|
|
|
252
|
-
:
|
|
253
|
-
|
|
254
|
-
|
|
273
|
+
Args:
|
|
274
|
+
cuda_home: The path to the CUDA installation.
|
|
275
|
+
so_file: The path to the shared object file.
|
|
276
|
+
|
|
277
|
+
Returns:
|
|
278
|
+
The compute compatibility of the CUDA library.
|
|
255
279
|
"""
|
|
256
280
|
try:
|
|
257
281
|
cuobjdump = os.path.join(cuda_home, "bin", "cuobjdump") # type: ignore
|
|
@@ -272,10 +296,14 @@ def detect_compute_compatibility(cuda_home: Optional[PathLikeOrStr], so_file: Op
|
|
|
272
296
|
|
|
273
297
|
# Copied from https://github.com/tensorpack/tensorpack/blob/master/tensorpack/tfutils/collect_env.py
|
|
274
298
|
def tf_info(data: KeyValEnvInfos) -> KeyValEnvInfos:
|
|
275
|
-
"""
|
|
299
|
+
"""
|
|
300
|
+
Returns a list of (key, value) pairs containing TensorFlow information.
|
|
301
|
+
|
|
302
|
+
Args:
|
|
303
|
+
data: A list of tuples to dump all collected package information such as the name and the version.
|
|
276
304
|
|
|
277
|
-
:
|
|
278
|
-
|
|
305
|
+
Returns:
|
|
306
|
+
A list of tuples containing all the collected information.
|
|
279
307
|
"""
|
|
280
308
|
if tf_available():
|
|
281
309
|
import tensorflow as tf # type: ignore # pylint: disable=E0401
|
|
@@ -329,10 +357,14 @@ def tf_info(data: KeyValEnvInfos) -> KeyValEnvInfos:
|
|
|
329
357
|
|
|
330
358
|
# Heavily inspired by https://github.com/facebookresearch/detectron2/blob/main/detectron2/utils/collect_env.py
|
|
331
359
|
def pt_info(data: KeyValEnvInfos) -> KeyValEnvInfos:
|
|
332
|
-
"""
|
|
360
|
+
"""
|
|
361
|
+
Returns a list of (key, value) pairs containing PyTorch information.
|
|
333
362
|
|
|
334
|
-
:
|
|
335
|
-
|
|
363
|
+
Args:
|
|
364
|
+
data: A list of tuples to dump all collected package information such as the name and the version.
|
|
365
|
+
|
|
366
|
+
Returns:
|
|
367
|
+
A list of tuples containing all the collected information.
|
|
336
368
|
"""
|
|
337
369
|
|
|
338
370
|
if pytorch_available():
|
|
@@ -437,17 +469,19 @@ def pt_info(data: KeyValEnvInfos) -> KeyValEnvInfos:
|
|
|
437
469
|
|
|
438
470
|
|
|
439
471
|
def set_dl_env_vars() -> None:
|
|
440
|
-
"""
|
|
441
|
-
|
|
442
|
-
It is possible that for testing purposes, e.g. on Colab you can find yourself with a pre-installed Tensorflow
|
|
443
|
-
version. If you want to enforce PyTorch you must set:
|
|
444
|
-
|
|
445
|
-
os.environ["DD_USE_TORCH"] = "1"
|
|
446
|
-
os.environ["USE_TORCH"] = "1" # necessary if you make use of DocTr's OCR engine
|
|
447
|
-
os.environ["DD_USE_TF"] = "0"
|
|
448
|
-
os.environ["USE_TF"] = "0" # it's better to explcitly disable Tensorflow
|
|
472
|
+
"""
|
|
473
|
+
Set the environment variables that steer the selection of the DL framework.
|
|
449
474
|
|
|
475
|
+
If both PyTorch and TensorFlow are available, PyTorch will be selected by default. For testing purposes, e.g. on
|
|
476
|
+
Colab, you may find yourself with a pre-installed TensorFlow version. If you want to enforce PyTorch, you must set:
|
|
450
477
|
|
|
478
|
+
Example:
|
|
479
|
+
```python
|
|
480
|
+
os.environ["DD_USE_TORCH"] = "1"
|
|
481
|
+
os.environ["USE_TORCH"] = "1" # necessary if you make use of DocTr's OCR engine
|
|
482
|
+
os.environ["DD_USE_TF"] = "0"
|
|
483
|
+
os.environ["USE_TF"] = "0" # it's better to explicitly disable TensorFlow
|
|
484
|
+
```
|
|
451
485
|
"""
|
|
452
486
|
|
|
453
487
|
if os.environ.get("PYTORCH_AVAILABLE") and os.environ.get("DD_USE_TORCH") is None:
|
|
@@ -474,8 +508,10 @@ def set_dl_env_vars() -> None:
|
|
|
474
508
|
|
|
475
509
|
def collect_env_info() -> str:
|
|
476
510
|
"""
|
|
511
|
+
Collects and returns environment information.
|
|
477
512
|
|
|
478
|
-
:
|
|
513
|
+
Returns:
|
|
514
|
+
A string containing the collected environment information.
|
|
479
515
|
"""
|
|
480
516
|
data = []
|
|
481
517
|
data.append(("sys.platform", sys.platform)) # check-template.yml depends on it
|
|
@@ -531,7 +567,12 @@ def collect_env_info() -> str:
|
|
|
531
567
|
|
|
532
568
|
|
|
533
569
|
def auto_select_viz_library() -> None:
|
|
534
|
-
"""
|
|
570
|
+
"""
|
|
571
|
+
Sets PIL as the default image library if OpenCV is not installed.
|
|
572
|
+
|
|
573
|
+
Note:
|
|
574
|
+
If environment variables are already set, this function will not change them.
|
|
575
|
+
"""
|
|
535
576
|
|
|
536
577
|
# if env variables are already set, don't change them
|
|
537
578
|
if os.environ.get("USE_DD_PILLOW") or os.environ.get("USE_DD_OPENCV"):
|
|
@@ -545,7 +586,15 @@ def auto_select_viz_library() -> None:
|
|
|
545
586
|
|
|
546
587
|
|
|
547
588
|
def auto_select_pdf_render_framework() -> None:
|
|
548
|
-
"""
|
|
589
|
+
"""
|
|
590
|
+
Sets `pdf2image` as the default PDF rendering library if pdfium is not installed.
|
|
591
|
+
|
|
592
|
+
Note:
|
|
593
|
+
If environment variables are already set, this function will not change them.
|
|
594
|
+
|
|
595
|
+
Raises:
|
|
596
|
+
DependencyError: If no PDF rendering library is found. Please install Poppler or pdfium.
|
|
597
|
+
"""
|
|
549
598
|
|
|
550
599
|
# if env variables are already set, don't change them
|
|
551
600
|
if os.environ.get("USE_DD_POPPLER") or os.environ.get("USE_DD_PDFIUM"):
|
deepdoctection/utils/error.py
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
# limitations under the License.
|
|
17
17
|
|
|
18
18
|
"""
|
|
19
|
-
|
|
19
|
+
Custom exceptions
|
|
20
20
|
"""
|
|
21
21
|
|
|
22
22
|
|
|
@@ -37,23 +37,27 @@ class UUIDError(BaseException):
|
|
|
37
37
|
|
|
38
38
|
|
|
39
39
|
class DependencyError(BaseException):
|
|
40
|
-
"""Special exception only for missing dependencies. We do not use the internals ImportError or
|
|
41
|
-
ModuleNotFoundError
|
|
40
|
+
"""Special exception only for missing dependencies. We do not use the internals `ImportError` or
|
|
41
|
+
`ModuleNotFoundError`."""
|
|
42
42
|
|
|
43
43
|
|
|
44
44
|
class DataFlowTerminatedError(BaseException):
|
|
45
45
|
"""
|
|
46
|
-
An exception indicating that the DataFlow is unable to produce any more
|
|
47
|
-
|
|
48
|
-
cannot give a valid iterator
|
|
49
|
-
In most DataFlow this will never be raised.
|
|
46
|
+
An exception indicating that the `DataFlow` is unable to produce any more data.
|
|
47
|
+
|
|
48
|
+
This exception is raised when something wrong happens so that calling `__iter__` cannot give a valid iterator
|
|
49
|
+
anymore. In most `DataFlow` this will never be raised.
|
|
50
50
|
"""
|
|
51
51
|
|
|
52
52
|
|
|
53
53
|
class DataFlowResetStateNotCalledError(BaseException):
|
|
54
54
|
"""
|
|
55
|
-
An exception indicating that `reset_state()` has not been called before starting
|
|
56
|
-
|
|
55
|
+
An exception indicating that `reset_state()` has not been called before starting iteration.
|
|
56
|
+
|
|
57
|
+
Example:
|
|
58
|
+
```python
|
|
59
|
+
raise DataFlowResetStateNotCalledError()
|
|
60
|
+
```
|
|
57
61
|
"""
|
|
58
62
|
|
|
59
63
|
def __init__(self) -> None:
|
|
@@ -62,7 +66,9 @@ class DataFlowResetStateNotCalledError(BaseException):
|
|
|
62
66
|
|
|
63
67
|
class MalformedData(BaseException):
|
|
64
68
|
"""
|
|
65
|
-
Exception class for malformed data.
|
|
69
|
+
Exception class for malformed data.
|
|
70
|
+
|
|
71
|
+
Use this class if something does not look right with the data.
|
|
66
72
|
"""
|
|
67
73
|
|
|
68
74
|
|