mineru 2.5.1__py3-none-any.whl → 2.5.3__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.
@@ -116,9 +116,14 @@ class BatchAnalyze:
116
116
  atom_model_name=AtomicModel.ImgOrientationCls,
117
117
  )
118
118
  try:
119
- img_orientation_cls_model.batch_predict(table_res_list_all_page,
120
- det_batch_size=self.batch_ratio * OCR_DET_BASE_BATCH_SIZE,
121
- batch_size=TABLE_ORI_CLS_BATCH_SIZE)
119
+ if self.enable_ocr_det_batch:
120
+ img_orientation_cls_model.batch_predict(table_res_list_all_page,
121
+ det_batch_size=self.batch_ratio * OCR_DET_BASE_BATCH_SIZE,
122
+ batch_size=TABLE_ORI_CLS_BATCH_SIZE)
123
+ else:
124
+ for table_res in table_res_list_all_page:
125
+ rotate_label = img_orientation_cls_model.predict(table_res['table_img'])
126
+ img_orientation_cls_model.img_rotate(table_res, rotate_label)
122
127
  except Exception as e:
123
128
  logger.warning(
124
129
  f"Image orientation classification failed: {e}, using original image"
@@ -0,0 +1,41 @@
1
+ import os
2
+
3
+ from loguru import logger
4
+ from packaging import version
5
+
6
+
7
+ def enable_custom_logits_processors():
8
+ import torch
9
+ from vllm import __version__ as vllm_version
10
+
11
+ if not torch.cuda.is_available():
12
+ logger.info("CUDA not available, disabling custom_logits_processors")
13
+ return False
14
+
15
+ major, minor = torch.cuda.get_device_capability()
16
+ # 正确计算Compute Capability
17
+ compute_capability = f"{major}.{minor}"
18
+
19
+ # 安全地处理环境变量
20
+ vllm_use_v1_str = os.getenv('VLLM_USE_V1', "1")
21
+ if vllm_use_v1_str.isdigit():
22
+ vllm_use_v1 = int(vllm_use_v1_str)
23
+ else:
24
+ vllm_use_v1 = 1
25
+
26
+ if vllm_use_v1 == 0:
27
+ logger.info("VLLM_USE_V1 is set to 0, disabling custom_logits_processors")
28
+ return False
29
+ elif version.parse(vllm_version) < version.parse("0.10.1"):
30
+ logger.info(f"vllm version: {vllm_version} < 0.10.1, disable custom_logits_processors")
31
+ return False
32
+ elif version.parse(compute_capability) < version.parse("8.0"):
33
+ if version.parse(vllm_version) >= version.parse("0.10.2"):
34
+ logger.info(f"compute_capability: {compute_capability} < 8.0, but vllm version: {vllm_version} >= 0.10.2, enable custom_logits_processors")
35
+ return True
36
+ else:
37
+ logger.info(f"compute_capability: {compute_capability} < 8.0 and vllm version: {vllm_version} < 0.10.2, disable custom_logits_processors")
38
+ return False
39
+ else:
40
+ logger.info(f"compute_capability: {compute_capability} >= 8.0 and vllm version: {vllm_version} >= 0.10.1, enable custom_logits_processors")
41
+ return True
@@ -4,6 +4,7 @@ import time
4
4
 
5
5
  from loguru import logger
6
6
 
7
+ from .custom_logits_processors import enable_custom_logits_processors
7
8
  from .model_output_to_middle_json import result_to_middle_json
8
9
  from ...data.data_reader_writer import DataWriter
9
10
  from mineru.utils.pdf_image_tools import load_images_from_pdf
@@ -88,7 +89,6 @@ class ModelSingleton:
88
89
  elif backend == "vllm-engine":
89
90
  try:
90
91
  import vllm
91
- vllm_version = vllm.__version__
92
92
  from mineru_vl_utils import MinerULogitsProcessor
93
93
  except ImportError:
94
94
  raise ImportError("Please install vllm to use the vllm-engine backend.")
@@ -96,7 +96,7 @@ class ModelSingleton:
96
96
  kwargs["gpu_memory_utilization"] = 0.5
97
97
  if "model" not in kwargs:
98
98
  kwargs["model"] = model_path
99
- if version.parse(vllm_version) >= version.parse("0.10.1") and "logits_processors" not in kwargs:
99
+ if enable_custom_logits_processors() and ("logits_processors" not in kwargs):
100
100
  kwargs["logits_processors"] = [MinerULogitsProcessor]
101
101
  # 使用kwargs为 vllm初始化参数
102
102
  vllm_llm = vllm.LLM(**kwargs)
@@ -104,7 +104,6 @@ class ModelSingleton:
104
104
  try:
105
105
  from vllm.engine.arg_utils import AsyncEngineArgs
106
106
  from vllm.v1.engine.async_llm import AsyncLLM
107
- from vllm import __version__ as vllm_version
108
107
  from mineru_vl_utils import MinerULogitsProcessor
109
108
  except ImportError:
110
109
  raise ImportError("Please install vllm to use the vllm-async-engine backend.")
@@ -112,7 +111,7 @@ class ModelSingleton:
112
111
  kwargs["gpu_memory_utilization"] = 0.5
113
112
  if "model" not in kwargs:
114
113
  kwargs["model"] = model_path
115
- if version.parse(vllm_version) >= version.parse("0.10.1") and "logits_processors" not in kwargs:
114
+ if enable_custom_logits_processors() and ("logits_processors" not in kwargs):
116
115
  kwargs["logits_processors"] = [MinerULogitsProcessor]
117
116
  # 使用kwargs为 vllm初始化参数
118
117
  vllm_async_llm = AsyncLLM.from_engine_args(AsyncEngineArgs(**kwargs))
@@ -54,7 +54,7 @@ def mk_blocks_to_markdown(para_blocks, make_mode, formula_enable, table_enable,
54
54
  elif para_type == BlockType.LIST:
55
55
  for block in para_block['blocks']:
56
56
  item_text = merge_para_with_text(block, formula_enable=formula_enable, img_buket_path=img_buket_path)
57
- para_text += f"{item_text}\n"
57
+ para_text += f"{item_text} \n"
58
58
  elif para_type == BlockType.TITLE:
59
59
  title_level = get_title_level(para_block)
60
60
  para_text = f'{"#" * title_level} {merge_para_with_text(para_block)}'
@@ -255,25 +255,28 @@ class PaddleOrientationClsModel:
255
255
  results = self.sess.run(None, {"x": x})
256
256
  for img_info, res in zip(rotated_imgs, results[0]):
257
257
  label = self.labels[np.argmax(res)]
258
- if label == "270":
259
- img_info["table_img"] = cv2.rotate(
260
- np.asarray(img_info["table_img"]),
261
- cv2.ROTATE_90_CLOCKWISE,
262
- )
263
- img_info["wired_table_img"] = cv2.rotate(
264
- np.asarray(img_info["wired_table_img"]),
265
- cv2.ROTATE_90_CLOCKWISE,
266
- )
267
- elif label == "90":
268
- img_info["table_img"] = cv2.rotate(
269
- np.asarray(img_info["table_img"]),
270
- cv2.ROTATE_90_COUNTERCLOCKWISE,
271
- )
272
- img_info["wired_table_img"] = cv2.rotate(
273
- np.asarray(img_info["wired_table_img"]),
274
- cv2.ROTATE_90_COUNTERCLOCKWISE,
275
- )
276
- else:
277
- # 180度和0度不做处理
278
- pass
258
+ self.img_rotate(img_info, label)
279
259
  pbar.update(1)
260
+
261
+ def img_rotate(self, img_info, label):
262
+ if label == "270":
263
+ img_info["table_img"] = cv2.rotate(
264
+ np.asarray(img_info["table_img"]),
265
+ cv2.ROTATE_90_CLOCKWISE,
266
+ )
267
+ img_info["wired_table_img"] = cv2.rotate(
268
+ np.asarray(img_info["wired_table_img"]),
269
+ cv2.ROTATE_90_CLOCKWISE,
270
+ )
271
+ elif label == "90":
272
+ img_info["table_img"] = cv2.rotate(
273
+ np.asarray(img_info["table_img"]),
274
+ cv2.ROTATE_90_COUNTERCLOCKWISE,
275
+ )
276
+ img_info["wired_table_img"] = cv2.rotate(
277
+ np.asarray(img_info["wired_table_img"]),
278
+ cv2.ROTATE_90_COUNTERCLOCKWISE,
279
+ )
280
+ else:
281
+ # 180度和0度不做处理
282
+ pass
@@ -1,10 +1,9 @@
1
1
  import sys
2
2
 
3
+ from mineru.backend.vlm.custom_logits_processors import enable_custom_logits_processors
3
4
  from mineru.utils.models_download_utils import auto_download_and_get_model_root_path
4
5
 
5
6
  from vllm.entrypoints.cli.main import main as vllm_main
6
- from vllm import __version__ as vllm_version
7
- from packaging import version
8
7
 
9
8
 
10
9
  def main():
@@ -37,6 +36,8 @@ def main():
37
36
  for index in sorted(model_arg_indices, reverse=True):
38
37
  args.pop(index)
39
38
 
39
+ custom_logits_processors = enable_custom_logits_processors()
40
+
40
41
  # 添加默认参数
41
42
  if not has_port_arg:
42
43
  args.extend(["--port", "30000"])
@@ -44,7 +45,7 @@ def main():
44
45
  args.extend(["--gpu-memory-utilization", "0.5"])
45
46
  if not model_path:
46
47
  model_path = auto_download_and_get_model_root_path("/", "vlm")
47
- if not has_logits_processors_arg and version.parse(vllm_version) >= version.parse("0.10.1"):
48
+ if (not has_logits_processors_arg) and custom_logits_processors:
48
49
  args.extend(["--logits-processors", "mineru_vl_utils:MinerULogitsProcessor"])
49
50
 
50
51
  # 重构参数,将模型路径作为位置参数
mineru/version.py CHANGED
@@ -1 +1 @@
1
- __version__ = "2.5.1"
1
+ __version__ = "2.5.3"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mineru
3
- Version: 2.5.1
3
+ Version: 2.5.3
4
4
  Summary: A practical tool for converting PDF to Markdown
5
5
  License: AGPL-3.0
6
6
  Project-URL: homepage, https://mineru.net/
@@ -37,7 +37,7 @@ Requires-Dist: scikit-image<1.0.0,>=0.25.0
37
37
  Requires-Dist: openai<2,>=1.70.0
38
38
  Requires-Dist: beautifulsoup4<5,>=4.13.5
39
39
  Requires-Dist: magika<0.7.0,>=0.6.2
40
- Requires-Dist: mineru-vl-utils<1,>=0.1.7
40
+ Requires-Dist: mineru-vl-utils<1,>=0.1.8
41
41
  Provides-Extra: test
42
42
  Requires-Dist: mineru[core]; extra == "test"
43
43
  Requires-Dist: pytest; extra == "test"
@@ -45,11 +45,11 @@ Requires-Dist: pytest-cov; extra == "test"
45
45
  Requires-Dist: coverage; extra == "test"
46
46
  Requires-Dist: fuzzywuzzy; extra == "test"
47
47
  Provides-Extra: vlm
48
- Requires-Dist: torch<2.8.0,>=2.6.0; extra == "vlm"
48
+ Requires-Dist: torch<3,>=2.6.0; extra == "vlm"
49
49
  Requires-Dist: transformers<5.0.0,>=4.51.1; extra == "vlm"
50
50
  Requires-Dist: accelerate>=1.5.1; extra == "vlm"
51
51
  Provides-Extra: vllm
52
- Requires-Dist: vllm==0.10.1.1; extra == "vllm"
52
+ Requires-Dist: vllm<0.11,>=0.10.1.1; extra == "vllm"
53
53
  Provides-Extra: pipeline
54
54
  Requires-Dist: matplotlib<4,>=3.10; extra == "pipeline"
55
55
  Requires-Dist: ultralytics<9,>=8.3.48; extra == "pipeline"
@@ -60,7 +60,7 @@ Requires-Dist: ftfy<7,>=6.3.1; extra == "pipeline"
60
60
  Requires-Dist: shapely<3,>=2.0.7; extra == "pipeline"
61
61
  Requires-Dist: pyclipper<2,>=1.3.0; extra == "pipeline"
62
62
  Requires-Dist: omegaconf<3,>=2.3.0; extra == "pipeline"
63
- Requires-Dist: torch<2.8.0,>=2.6.0; extra == "pipeline"
63
+ Requires-Dist: torch<3,>=2.6.0; extra == "pipeline"
64
64
  Requires-Dist: torchvision; extra == "pipeline"
65
65
  Requires-Dist: transformers!=4.51.0,<5.0.0,>=4.49.0; extra == "pipeline"
66
66
  Requires-Dist: onnxruntime>1.17.0; extra == "pipeline"
@@ -127,7 +127,13 @@ Dynamic: license-file
127
127
 
128
128
  # Changelog
129
129
 
130
- - 2025/09/19 2.5.1 Released
130
+ - 2025/09/20 2.5.3 Released
131
+ - Dependency version range adjustment to enable Turing and earlier architecture GPUs to use vLLM acceleration for MinerU2.5 model inference.
132
+ - `pipeline` backend compatibility fixes for torch 2.8.0.
133
+ - Reduced default concurrency for vLLM async backend to lower server pressure and avoid connection closure issues caused by high load.
134
+ - More compatibility-related details can be found in the [announcement](https://github.com/opendatalab/MinerU/discussions/3548)
135
+
136
+ - 2025/09/19 2.5.2 Released
131
137
 
132
138
  We are officially releasing MinerU2.5, currently the most powerful multimodal large model for document parsing.
133
139
  With only 1.2B parameters, MinerU2.5's accuracy on the OmniDocBench benchmark comprehensively surpasses top-tier multimodal models like Gemini 2.5 Pro, GPT-4o, and Qwen2.5-VL-72B. It also significantly outperforms leading specialized models such as dots.ocr, MonkeyOCR, and PP-StructureV3.
@@ -1,8 +1,8 @@
1
1
  mineru/__init__.py,sha256=8CRrCQVuExa0BttRFh3Z40lFy2K5jN0sp67KWjOlj5c,50
2
- mineru/version.py,sha256=PfQ9ThOuZlUZhThya-_PpR02LjazRR6LNSivpta03mM,22
2
+ mineru/version.py,sha256=9As6EseYF3Vi8VWUZnZuuTi-kW5fYIv8u6cHK0RidGo,22
3
3
  mineru/backend/__init__.py,sha256=8CRrCQVuExa0BttRFh3Z40lFy2K5jN0sp67KWjOlj5c,50
4
4
  mineru/backend/pipeline/__init__.py,sha256=8CRrCQVuExa0BttRFh3Z40lFy2K5jN0sp67KWjOlj5c,50
5
- mineru/backend/pipeline/batch_analyze.py,sha256=rp9nHYmuBBytlJIc3oRwqTtgFd5mhRak5UMhQ4mu02Y,21896
5
+ mineru/backend/pipeline/batch_analyze.py,sha256=dOnktvOMjfg84w1H34YlJg6N9_x6Yfvf14NIpOQcZqQ,22221
6
6
  mineru/backend/pipeline/model_init.py,sha256=tb0kOqXrSJ9HuS65Z3tr7C84P43fOIc_zlnVY5TEvXI,8440
7
7
  mineru/backend/pipeline/model_json_to_middle_json.py,sha256=i0Kmd31gR1kp0-UGtQIS7byiRRQBm2q7G-zpYIL1lwo,10898
8
8
  mineru/backend/pipeline/model_list.py,sha256=62_61GQ9ZgS5YmNSpzRkts9kLtbSu8dYrfn-Cs4Hr8I,223
@@ -11,10 +11,11 @@ mineru/backend/pipeline/pipeline_analyze.py,sha256=rbO5AetOdnxR5ctkoDzFCFoElkz7J
11
11
  mineru/backend/pipeline/pipeline_magic_model.py,sha256=w8jGx8f6yZN0Wf2yPP3L9rYKc9rogxreZCrUJzJvPO8,14974
12
12
  mineru/backend/pipeline/pipeline_middle_json_mkcontent.py,sha256=xWWOFmYL6hB8PLrxQFyRJ72dAmTIDHtqiWV-WFUfR44,14081
13
13
  mineru/backend/vlm/__init__.py,sha256=8CRrCQVuExa0BttRFh3Z40lFy2K5jN0sp67KWjOlj5c,50
14
+ mineru/backend/vlm/custom_logits_processors.py,sha256=ShdWaCjCcoP1NxAq1U5LuyD391NmcnLDdZ6jm5RjDHk,1634
14
15
  mineru/backend/vlm/model_output_to_middle_json.py,sha256=e4Yc98_Cth2cjVPybPGehD5cpjGcTka4D2qKKrP_qqo,5121
15
- mineru/backend/vlm/vlm_analyze.py,sha256=jR5DTHT0qtOLVos5-qSGPvlRCdYREoAshFej98FY5ao,8282
16
+ mineru/backend/vlm/vlm_analyze.py,sha256=ZUXM7LSNlNhEAL7JPu8jMb8X_wurmixnlkHr0buAcI8,8189
16
17
  mineru/backend/vlm/vlm_magic_model.py,sha256=o1WKwgArV0f4lp7ufmSq9zRZaM5bnfOdx1AQtKnosro,16379
17
- mineru/backend/vlm/vlm_middle_json_mkcontent.py,sha256=DX2TRpfSIqpuhWqou5QXNtCW40ddQi0kdQxXi4QgzKs,13375
18
+ mineru/backend/vlm/vlm_middle_json_mkcontent.py,sha256=Ie95XpwTgi7EmidcwE_scvXMRQjE2xASU_Rm_F8EP-I,13377
18
19
  mineru/cli/__init__.py,sha256=8CRrCQVuExa0BttRFh3Z40lFy2K5jN0sp67KWjOlj5c,50
19
20
  mineru/cli/client.py,sha256=uo7db9Wqj1Mc11MYuaM-bi54BfKKU3SFB9Urc8md5X4,6641
20
21
  mineru/cli/common.py,sha256=yJPdrwSYVidl2hTJ2Hn2YhnfH97GJ-QZi20dGFz7h5c,14025
@@ -120,7 +121,7 @@ mineru/model/ocr/paddleocr2pytorch/tools/infer/predict_rec.py,sha256=q3l32JbBlqN
120
121
  mineru/model/ocr/paddleocr2pytorch/tools/infer/predict_system.py,sha256=hkegkn6hq2v2zqHVAP615-k-fkTS8swRYSbZeoqmSI8,3822
121
122
  mineru/model/ocr/paddleocr2pytorch/tools/infer/pytorchocr_utility.py,sha256=i1PFN-_kefJUUZ4Vk7igs1TU8gfErTDlDXY6-8Uaurw,9323
122
123
  mineru/model/ori_cls/__init__.py,sha256=8CRrCQVuExa0BttRFh3Z40lFy2K5jN0sp67KWjOlj5c,50
123
- mineru/model/ori_cls/paddle_ori_cls.py,sha256=Ct0KFo-LEc_GBMYKdiv6c7DW2rxBkrt-i2uyfExmB5M,12178
124
+ mineru/model/ori_cls/paddle_ori_cls.py,sha256=VIS22IerHST7g60AC9r2PEQIG6NQWeQaH1OrXIxNTsg,11943
124
125
  mineru/model/reading_order/__init__.py,sha256=8CRrCQVuExa0BttRFh3Z40lFy2K5jN0sp67KWjOlj5c,50
125
126
  mineru/model/reading_order/layout_reader.py,sha256=IVUFcNMDF3-kio-BIxjppHnWS3eHPqvvNihIw2fbIFM,4372
126
127
  mineru/model/reading_order/xycut.py,sha256=ezNSq_Y4UXiztB58hbXJsjTJlOBqWIjuW5A2uLSaZSo,7349
@@ -143,7 +144,7 @@ mineru/model/table/rec/unet_table/utils.py,sha256=CYAqJW0wePJk4NAemb8W203N7E32v0
143
144
  mineru/model/table/rec/unet_table/utils_table_line_rec.py,sha256=zrCdPwI4M8nu0FEfd7lRJAe0z8kYq3KFbzwElM82USE,11174
144
145
  mineru/model/table/rec/unet_table/utils_table_recover.py,sha256=XksJsY82ZS0kqUnNT-jvaYzxJ3V3svMSzj0puwIau1k,10651
145
146
  mineru/model/vlm_vllm_model/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
146
- mineru/model/vlm_vllm_model/server.py,sha256=v07x1esggP7Wbw0r8NeAbqG2kuJN9x5Xl2CmE2x0qzk,2003
147
+ mineru/model/vlm_vllm_model/server.py,sha256=0hlM50Mrz9IhhCte1ZDu0hTxKQguxMm7-rtpm6Z0LLM,2054
147
148
  mineru/resources/header.html,sha256=NO8ZZdCYLqu_E72AtNcuRnA2NbFBamScjjGhtg9PKiM,4409
148
149
  mineru/resources/fasttext-langdetect/lid.176.ftz,sha256=jzRyz-hzintgmejpmcPL-uDc0VaWqsfXc4qAOdtgPoM,938013
149
150
  mineru/utils/__init__.py,sha256=8CRrCQVuExa0BttRFh3Z40lFy2K5jN0sp67KWjOlj5c,50
@@ -172,9 +173,9 @@ mineru/utils/run_async.py,sha256=rPeP4BCZerR8VByRDhiYzfZiahLVqoZEBVAS54dAjNg,128
172
173
  mineru/utils/span_block_fix.py,sha256=0eVQjJCrT03woRt9hoh6Uu42Tp1dacfGTv2x3B9qq94,8797
173
174
  mineru/utils/span_pre_proc.py,sha256=h41q2uQajI0xQbc_30hqaju1dv3oVYxBAlKgURl8HIc,13692
174
175
  mineru/utils/table_merge.py,sha256=zYUpYLrfhBCnbHCYZi6rG8-s38NDnTbiNTObvLdYwJk,11494
175
- mineru-2.5.1.dist-info/licenses/LICENSE.md,sha256=jVa0BUaKrRH4erV2P5AeJ24I2WRv9chIGxditreJ6e0,34524
176
- mineru-2.5.1.dist-info/METADATA,sha256=BnhjCe7hE1EMEZdmz-YQgX0Mq5LANyNWHayKFaJztw0,64460
177
- mineru-2.5.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
178
- mineru-2.5.1.dist-info/entry_points.txt,sha256=luXmbhPiZK_tKlRgWuYOaW_V6EFpG-yJcAevVv9MEqE,252
179
- mineru-2.5.1.dist-info/top_level.txt,sha256=zuGQfZcbsHv4I4oKI9gaKPqEWBFm6xJroKuug2LnKP8,7
180
- mineru-2.5.1.dist-info/RECORD,,
176
+ mineru-2.5.3.dist-info/licenses/LICENSE.md,sha256=jVa0BUaKrRH4erV2P5AeJ24I2WRv9chIGxditreJ6e0,34524
177
+ mineru-2.5.3.dist-info/METADATA,sha256=T45OlRf2MarpDXHk36RO4Hx8EN2A15V2UJmmjTd8YCE,64957
178
+ mineru-2.5.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
179
+ mineru-2.5.3.dist-info/entry_points.txt,sha256=luXmbhPiZK_tKlRgWuYOaW_V6EFpG-yJcAevVv9MEqE,252
180
+ mineru-2.5.3.dist-info/top_level.txt,sha256=zuGQfZcbsHv4I4oKI9gaKPqEWBFm6xJroKuug2LnKP8,7
181
+ mineru-2.5.3.dist-info/RECORD,,
File without changes