doc-page-extractor 0.2.1__py3-none-any.whl → 0.2.2__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 doc-page-extractor might be problematic. Click here for more details.
- doc_page_extractor/__init__.py +1 -0
- doc_page_extractor/extractor.py +7 -0
- doc_page_extractor/model.py +33 -22
- {doc_page_extractor-0.2.1.dist-info → doc_page_extractor-0.2.2.dist-info}/METADATA +1 -1
- {doc_page_extractor-0.2.1.dist-info → doc_page_extractor-0.2.2.dist-info}/RECORD +8 -8
- {doc_page_extractor-0.2.1.dist-info → doc_page_extractor-0.2.2.dist-info}/WHEEL +0 -0
- {doc_page_extractor-0.2.1.dist-info → doc_page_extractor-0.2.2.dist-info}/licenses/LICENSE +0 -0
- {doc_page_extractor-0.2.1.dist-info → doc_page_extractor-0.2.2.dist-info}/top_level.txt +0 -0
doc_page_extractor/__init__.py
CHANGED
doc_page_extractor/extractor.py
CHANGED
|
@@ -52,6 +52,13 @@ class DocExtractor:
|
|
|
52
52
|
self._latex: LaTeX = LaTeX(device, model)
|
|
53
53
|
self._layout_order: LayoutOrder = LayoutOrder(device, model)
|
|
54
54
|
|
|
55
|
+
def prepare_models(self):
|
|
56
|
+
self._model.get_onnx_ocr_path()
|
|
57
|
+
self._model.get_yolo_path()
|
|
58
|
+
self._model.get_layoutreader_path()
|
|
59
|
+
self._model.get_struct_eqtable_path()
|
|
60
|
+
self._model.get_latex_path()
|
|
61
|
+
|
|
55
62
|
def extract(
|
|
56
63
|
self,
|
|
57
64
|
image: Image,
|
doc_page_extractor/model.py
CHANGED
|
@@ -31,9 +31,10 @@ class HuggingfaceModel(Model):
|
|
|
31
31
|
def get_onnx_ocr_path(self) -> Path:
|
|
32
32
|
return self._get_model_path(
|
|
33
33
|
repo_id="moskize/OnnxOCR",
|
|
34
|
-
filename=
|
|
34
|
+
filename="README.md",
|
|
35
35
|
repo_type=None,
|
|
36
|
-
is_snapshot=True
|
|
36
|
+
is_snapshot=True,
|
|
37
|
+
wanna_dir_path=True,
|
|
37
38
|
)
|
|
38
39
|
|
|
39
40
|
def get_yolo_path(self) -> Path:
|
|
@@ -42,14 +43,16 @@ class HuggingfaceModel(Model):
|
|
|
42
43
|
filename="models/Layout/YOLO/doclayout_yolo_ft.pt",
|
|
43
44
|
repo_type=None,
|
|
44
45
|
is_snapshot=False,
|
|
46
|
+
wanna_dir_path=False,
|
|
45
47
|
)
|
|
46
48
|
|
|
47
49
|
def get_layoutreader_path(self) -> Path:
|
|
48
50
|
return self._get_model_path(
|
|
49
51
|
repo_id="hantian/layoutreader",
|
|
50
|
-
filename=
|
|
52
|
+
filename="model.safetensors",
|
|
51
53
|
repo_type=None,
|
|
52
54
|
is_snapshot=True,
|
|
55
|
+
wanna_dir_path=True,
|
|
53
56
|
)
|
|
54
57
|
|
|
55
58
|
def get_struct_eqtable_path(self) -> Path:
|
|
@@ -58,6 +61,7 @@ class HuggingfaceModel(Model):
|
|
|
58
61
|
filename="model.safetensors",
|
|
59
62
|
repo_type=None,
|
|
60
63
|
is_snapshot=True,
|
|
64
|
+
wanna_dir_path=True,
|
|
61
65
|
)
|
|
62
66
|
|
|
63
67
|
def get_latex_path(self) -> Path:
|
|
@@ -66,38 +70,45 @@ class HuggingfaceModel(Model):
|
|
|
66
70
|
filename="checkpoints/weights.pth",
|
|
67
71
|
repo_type="space",
|
|
68
72
|
is_snapshot=True,
|
|
73
|
+
wanna_dir_path=True,
|
|
69
74
|
)
|
|
70
75
|
|
|
71
76
|
def _get_model_path(
|
|
72
77
|
self,
|
|
73
78
|
repo_id: str,
|
|
74
|
-
filename: str
|
|
79
|
+
filename: str,
|
|
75
80
|
repo_type: str | None,
|
|
76
81
|
is_snapshot: bool,
|
|
82
|
+
wanna_dir_path: bool,
|
|
77
83
|
) -> Path:
|
|
84
|
+
|
|
78
85
|
with self._lock:
|
|
79
|
-
cache_filename = "README.md"
|
|
80
|
-
if filename is not None:
|
|
81
|
-
cache_filename = filename
|
|
82
86
|
model_path = try_to_load_from_cache(
|
|
83
87
|
repo_id=repo_id,
|
|
84
|
-
filename=
|
|
88
|
+
filename=filename,
|
|
85
89
|
repo_type=repo_type,
|
|
86
90
|
cache_dir=self._model_cache_dir
|
|
87
91
|
)
|
|
88
92
|
if isinstance(model_path, str):
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
cache_dir=self._model_cache_dir,
|
|
95
|
-
repo_id=repo_id,
|
|
96
|
-
)
|
|
93
|
+
model_path = Path(model_path)
|
|
94
|
+
if wanna_dir_path:
|
|
95
|
+
for _ in Path(filename).parts:
|
|
96
|
+
model_path = model_path.parent
|
|
97
|
+
|
|
97
98
|
else:
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
99
|
+
if is_snapshot:
|
|
100
|
+
model_path = snapshot_download(
|
|
101
|
+
cache_dir=self._model_cache_dir,
|
|
102
|
+
repo_id=repo_id,
|
|
103
|
+
repo_type=repo_type,
|
|
104
|
+
)
|
|
105
|
+
else:
|
|
106
|
+
model_path = hf_hub_download(
|
|
107
|
+
cache_dir=self._model_cache_dir,
|
|
108
|
+
repo_id=repo_id,
|
|
109
|
+
repo_type=repo_type,
|
|
110
|
+
filename=filename,
|
|
111
|
+
)
|
|
112
|
+
model_path = Path(model_path)
|
|
113
|
+
|
|
114
|
+
return model_path
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
doc_page_extractor/__init__.py,sha256=
|
|
1
|
+
doc_page_extractor/__init__.py,sha256=rt_XALcqNNg3iVkMTUHltWxvdweH2FY6Y_olU2TkVBY,355
|
|
2
2
|
doc_page_extractor/clipper.py,sha256=5S1TI0aqMebwlPv_Ih4Nxpp6MchEjOih-CiZfMWUAhI,3201
|
|
3
3
|
doc_page_extractor/downloader.py,sha256=NbGN9ARnER8-gd4T1uc3W98WMEClVxMrqnShq8HibTw,455
|
|
4
|
-
doc_page_extractor/extractor.py,sha256=
|
|
4
|
+
doc_page_extractor/extractor.py,sha256=7dJ1N4d2_9tB49XAfKBIJjEUvNtjf0CGqcm2uf6BMPg,7205
|
|
5
5
|
doc_page_extractor/latex.py,sha256=kD3NIzZTEGUFIAqqyHYmNcfyTrlu77GB1YSFgzbFb7A,1024
|
|
6
6
|
doc_page_extractor/layout_order.py,sha256=lm_rXzRZ3AtufaRwxqZPfM9vplwaOlE2pnTNc7Z_oLM,7435
|
|
7
7
|
doc_page_extractor/layoutreader.py,sha256=BdC4oPbtpXoLmYhjuSFrKn6SNoT2zWw_gi95sGAUwrk,4031
|
|
8
|
-
doc_page_extractor/model.py,sha256=
|
|
8
|
+
doc_page_extractor/model.py,sha256=yQhLz28rQ0aCHKs1AQgKdUIT9UkJtpA0HP2cpWN-rls,2891
|
|
9
9
|
doc_page_extractor/ocr.py,sha256=niZY4ZgbbbV-IeTrtF3Y8LPPrynU2wvZKRVYbBP1Dog,5586
|
|
10
10
|
doc_page_extractor/ocr_corrector.py,sha256=RfRA1jESEuqC8_a2kUEvHblT_B4xBjE0OApLMl1JiRg,3917
|
|
11
11
|
doc_page_extractor/overlap.py,sha256=z1DF4_2OPvauDHwmz1SC1WosULkE84HKaRfNEgexPzc,5337
|
|
@@ -36,10 +36,10 @@ doc_page_extractor/struct_eqtable/internvl/internvl_lmdeploy.py,sha256=ACHxFntxS
|
|
|
36
36
|
doc_page_extractor/struct_eqtable/pix2s/__init__.py,sha256=cXRo4eg6u1-TXktZ8rQf0HIzLmmScIwYQhbxMKl-MyA,76
|
|
37
37
|
doc_page_extractor/struct_eqtable/pix2s/pix2s.py,sha256=fCNve8PNeJ3-AWJIhSeGtp-mYKoMXfW0CIpszkQnAaA,2535
|
|
38
38
|
doc_page_extractor/struct_eqtable/pix2s/pix2s_trt.py,sha256=zSGw45JhWdZ3iuJel5Chsy-NzsOHx9QyPQIUAzzCjFE,43880
|
|
39
|
-
doc_page_extractor-0.2.
|
|
39
|
+
doc_page_extractor-0.2.2.dist-info/licenses/LICENSE,sha256=TfPDBt3ar0uv_f9cqCDMZ5rIzW3CY8anRRd4PkL6ejs,34522
|
|
40
40
|
tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
41
41
|
tests/test_history_bus.py,sha256=g-bpDIiebyEHKDH0YS5OHF2ONfhZt3-EFLZhWJn94WE,2534
|
|
42
|
-
doc_page_extractor-0.2.
|
|
43
|
-
doc_page_extractor-0.2.
|
|
44
|
-
doc_page_extractor-0.2.
|
|
45
|
-
doc_page_extractor-0.2.
|
|
42
|
+
doc_page_extractor-0.2.2.dist-info/METADATA,sha256=SATSntedRznSoTzLUsKWBHNwiD3CDujgc9FEvK_Fbg4,2480
|
|
43
|
+
doc_page_extractor-0.2.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
44
|
+
doc_page_extractor-0.2.2.dist-info/top_level.txt,sha256=ErNybD_lBzAmw8mVBAK4htsAH_hp14jioZVex-tUqvM,25
|
|
45
|
+
doc_page_extractor-0.2.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|