cells2table 0.2.2__tar.gz → 0.2.3__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.
- {cells2table-0.2.2 → cells2table-0.2.3}/PKG-INFO +1 -1
- cells2table-0.2.3/cells2table/cli.py +49 -0
- {cells2table-0.2.2/src → cells2table-0.2.3}/cells2table/models/PaddlePaddle/cell_detection.py +13 -11
- {cells2table-0.2.2 → cells2table-0.2.3}/pyproject.toml +6 -2
- {cells2table-0.2.2 → cells2table-0.2.3}/LICENSE +0 -0
- {cells2table-0.2.2 → cells2table-0.2.3}/README.md +0 -0
- {cells2table-0.2.2/src → cells2table-0.2.3}/cells2table/__init__.py +0 -0
- {cells2table-0.2.2/src → cells2table-0.2.3}/cells2table/datamodels/__init__.py +0 -0
- {cells2table-0.2.2/src → cells2table-0.2.3}/cells2table/datamodels/bbox.py +0 -0
- {cells2table-0.2.2/src → cells2table-0.2.3}/cells2table/datamodels/table.py +0 -0
- {cells2table-0.2.2/src → cells2table-0.2.3}/cells2table/docling.py +0 -0
- {cells2table-0.2.2/src → cells2table-0.2.3}/cells2table/models/PaddlePaddle/__init__.py +0 -0
- {cells2table-0.2.2/src → cells2table-0.2.3}/cells2table/models/PaddlePaddle/table_classification.py +0 -0
- {cells2table-0.2.2/src → cells2table-0.2.3}/cells2table/models/__init__.py +0 -0
- {cells2table-0.2.2/src → cells2table-0.2.3}/cells2table/models/download.py +0 -0
- {cells2table-0.2.2/src → cells2table-0.2.3}/cells2table/models/runtimes/__init__.py +0 -0
- {cells2table-0.2.2/src → cells2table-0.2.3}/cells2table/models/runtimes/onnx.py +0 -0
- {cells2table-0.2.2/src → cells2table-0.2.3}/cells2table/models/tasks/__init__.py +0 -0
- {cells2table-0.2.2/src → cells2table-0.2.3}/cells2table/models/tasks/base.py +0 -0
- {cells2table-0.2.2/src → cells2table-0.2.3}/cells2table/models/tasks/classification.py +0 -0
- {cells2table-0.2.2/src → cells2table-0.2.3}/cells2table/models/tasks/detection.py +0 -0
- {cells2table-0.2.2/src → cells2table-0.2.3}/cells2table/pipelines/__init__.py +0 -0
- {cells2table-0.2.2/src → cells2table-0.2.3}/cells2table/pipelines/base.py +0 -0
- {cells2table-0.2.2/src → cells2table-0.2.3}/cells2table/pipelines/classification_detection.py +0 -0
- {cells2table-0.2.2/src → cells2table-0.2.3}/cells2table/pipelines/paddlepaddle.py +0 -0
- {cells2table-0.2.2/src → cells2table-0.2.3}/cells2table/py.typed +0 -0
- {cells2table-0.2.2/src → cells2table-0.2.3}/cells2table/utils/__init__.py +0 -0
- {cells2table-0.2.2/src → cells2table-0.2.3}/cells2table/utils/visualize.py +0 -0
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import argparse
|
|
2
|
+
import logging
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
|
|
5
|
+
import cv2
|
|
6
|
+
|
|
7
|
+
from cells2table import DefaultPipeline
|
|
8
|
+
from cells2table.utils.visualize import visualize_table
|
|
9
|
+
|
|
10
|
+
logger = logging.getLogger(__name__)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def main() -> None:
|
|
14
|
+
"""Basic CLI program for testing."""
|
|
15
|
+
|
|
16
|
+
log_format = "%(asctime)s\t%(levelname)s\t%(name)s: %(message)s"
|
|
17
|
+
logging.basicConfig(level=logging.DEBUG, format=log_format)
|
|
18
|
+
|
|
19
|
+
parser = argparse.ArgumentParser(description="Load an image from a given path using OpenCV")
|
|
20
|
+
parser.add_argument("image_path", type=Path, help="Path to the image file")
|
|
21
|
+
|
|
22
|
+
args = parser.parse_args()
|
|
23
|
+
|
|
24
|
+
if not args.image_path.exists():
|
|
25
|
+
raise FileNotFoundError(f"File does not exist: {args.image_path}")
|
|
26
|
+
|
|
27
|
+
image = cv2.imread(str(args.image_path))
|
|
28
|
+
|
|
29
|
+
if image is None:
|
|
30
|
+
raise ValueError(f"Failed to load image: {args.image_path}")
|
|
31
|
+
|
|
32
|
+
logger.info("Image loaded successfully from %s", args.image_path)
|
|
33
|
+
logger.debug(
|
|
34
|
+
"Image proprieties: width=%d, height=%d, channels=%d, datatype=%s",
|
|
35
|
+
image.shape[1],
|
|
36
|
+
image.shape[0],
|
|
37
|
+
image.shape[2],
|
|
38
|
+
str(image.dtype),
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
table_pipeline = DefaultPipeline()
|
|
42
|
+
tables = table_pipeline([image])
|
|
43
|
+
|
|
44
|
+
for table in tables:
|
|
45
|
+
visualize_table(image, table) # type: ignore
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
if __name__ == "__main__":
|
|
49
|
+
main()
|
{cells2table-0.2.2/src → cells2table-0.2.3}/cells2table/models/PaddlePaddle/cell_detection.py
RENAMED
|
@@ -58,22 +58,24 @@ class PaddlePaddleCellDetectionModel(DetectionModel, OnnxModel):
|
|
|
58
58
|
scale_factors: Sequence[tuple[int, int]],
|
|
59
59
|
) -> list[Iterator[DetectionResult]]:
|
|
60
60
|
last_cell_idx = 0
|
|
61
|
-
batch_size = len(pred[1])
|
|
62
|
-
generators = []
|
|
63
61
|
cells = pred[0]
|
|
64
62
|
|
|
65
|
-
|
|
66
|
-
|
|
63
|
+
generators = []
|
|
64
|
+
|
|
65
|
+
for i, count in enumerate(pred[1]):
|
|
66
|
+
c = cells[last_cell_idx : last_cell_idx + count]
|
|
67
67
|
c = c[c[:, 1] > CONFIDENCE_THRESHOLD]
|
|
68
|
+
last_cell_idx += count
|
|
68
69
|
|
|
69
|
-
|
|
70
|
+
if not c.size:
|
|
71
|
+
generators.append(iter([]))
|
|
72
|
+
continue
|
|
70
73
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
boxes[:, [1, 3]] *= sx
|
|
74
|
+
sx, sy = scale_factors[i]
|
|
75
|
+
scores = c[:, 0]
|
|
76
|
+
boxes = c[:, 2:]
|
|
77
|
+
boxes[:, [0, 2]] *= sy
|
|
78
|
+
boxes[:, [1, 3]] *= sx
|
|
77
79
|
|
|
78
80
|
generators.append((DetectionResult(box, score) for box, score in zip(boxes, scores)))
|
|
79
81
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "cells2table"
|
|
3
|
-
version = "0.2.
|
|
3
|
+
version = "0.2.3"
|
|
4
4
|
description = "Table image parsing with cell detection models"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
requires-python = ">=3.12,<4.0"
|
|
@@ -24,7 +24,7 @@ Homepage = "https://github.com/jspast/cells2table"
|
|
|
24
24
|
Issues = "https://github.com/jspast/cells2table/issues"
|
|
25
25
|
|
|
26
26
|
[project.scripts]
|
|
27
|
-
cells2table = "cli:main"
|
|
27
|
+
cells2table = "cells2table.cli:main"
|
|
28
28
|
|
|
29
29
|
[project.entry-points.docling]
|
|
30
30
|
cells2table = "cells2table.docling"
|
|
@@ -69,3 +69,7 @@ conflicts = [
|
|
|
69
69
|
{ extra = "onnx_openvino" }
|
|
70
70
|
]
|
|
71
71
|
]
|
|
72
|
+
|
|
73
|
+
[tool.uv.build-backend]
|
|
74
|
+
module-name = "cells2table"
|
|
75
|
+
module-root = ""
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{cells2table-0.2.2/src → cells2table-0.2.3}/cells2table/models/PaddlePaddle/table_classification.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{cells2table-0.2.2/src → cells2table-0.2.3}/cells2table/pipelines/classification_detection.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|