tao.mo

MinerU源码上传

mt
2025年10月31日14:20:47
# 解决 numpy>=1.21.6 安装错误
## 问题描述
在安装 MinerU 项目依赖时遇到错误:
```
ERROR: Could not find a version that satisfies the requirement numpy>=1.21.6
```
## 解决方案
### 方案 1:使用 --user 选项安装(推荐)
由于 Windows 权限问题,推荐使用 `--user` 选项安装到用户目录:
```bash
python -m pip install --user --upgrade pip
python -m pip install --user numpy>=1.21.6
```
### 方案 2:使用国内镜像源(推荐中国用户)
如果网络较慢,可以使用国内镜像源加速安装:
#### 临时使用镜像源:
```bash
# 使用清华大学镜像源
python -m pip install --user -i https://pypi.tuna.tsinghua.edu.cn/simple numpy>=1.21.6
# 或者使用阿里云镜像源
python -m pip install --user -i https://mirrors.aliyun.com/pypi/simple/ numpy>=1.21.6
# 或者使用中科大镜像源
python -m pip install --user -i https://pypi.mirrors.ustc.edu.cn/simple/ numpy>=1.21.6
```
#### 永久配置镜像源:
创建或编辑 pip 配置文件:
- Windows: `%APPDATA%\pip\pip.ini`
- 或在用户目录下创建 `pip.ini`
添加以下内容:
```ini
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
[install]
trusted-host = pypi.tuna.tsinghua.edu.cn
```
### 方案 3:安装完整项目依赖
如果需要安装整个 MinerU 项目,可以:
```bash
# 使用 --user 选项
python -m pip install --user -e .
# 或使用国内镜像源
python -m pip install --user -i https://pypi.tuna.tsinghua.edu.cn/simple -e .
```
### 方案 4:修复 pip 警告(可选)
如果看到如下警告:
```
WARNING: Ignoring invalid distribution ~ip (C:\Python312\Lib\site-packages)
```
可以尝试修复:
```bash
# 找到损坏的包目录(通常是 ~ip 或 ~ 开头)
# 然后手动删除它们,或运行:
python -m pip cache purge
```
### 方案 5:以管理员权限运行(如果上述方案都不行)
1. 右键点击命令提示符或 PowerShell
2. 选择"以管理员身份运行"
3. 然后执行安装命令
## 验证安装
安装完成后,可以验证:
```bash
python -c "import numpy; print(numpy.__version__)"
```
应该输出类似:`2.3.4` 或更高版本
## 注意事项
1. **Python 版本要求**:MinerU 要求 Python >=3.10,<3.14,当前版本 3.12.1 符合要求
2. **权限问题**:Windows 上安装全局包可能需要管理员权限,推荐使用 `--user` 选项
3. **网络问题**:如果下载速度慢,强烈建议使用国内镜像源
4. **PATH 配置**:升级 pip 后,如果提示 PATH 问题,可以手动添加到环境变量,或使用 `python -m pip` 代替 `pip`
## 常用镜像源
- 清华大学:https://pypi.tuna.tsinghua.edu.cn/simple
- 阿里云:https://mirrors.aliyun.com/pypi/simple/
- 中科大:https://pypi.mirrors.ustc.edu.cn/simple
- 豆瓣:https://pypi.douban.com/simple/
Metadata-Version: 2.4
Name: mineru
Version: 2.6.2
Summary: A practical tool for converting PDF to Markdown
License: AGPL-3.0
Project-URL: homepage, https://mineru.net/
Project-URL: documentation, https://opendatalab.github.io/MinerU/
Project-URL: repository, https://github.com/opendatalab/MinerU
Project-URL: issues, https://github.com/opendatalab/MinerU/issues
Keywords: magic-pdf,mineru,MinerU,convert,pdf,markdown
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Requires-Python: <3.14,>=3.10
Description-Content-Type: text/markdown
License-File: LICENSE.md
Requires-Dist: boto3>=1.28.43
Requires-Dist: click>=8.1.7
Requires-Dist: loguru>=0.7.2
Requires-Dist: numpy>=1.21.6
Requires-Dist: pdfminer.six==20250506
Requires-Dist: tqdm>=4.67.1
Requires-Dist: requests
Requires-Dist: httpx
Requires-Dist: pillow>=11.0.0
Requires-Dist: pypdfium2>=4.30.0
Requires-Dist: pypdf>=5.6.0
Requires-Dist: reportlab
Requires-Dist: pdftext>=0.6.2
Requires-Dist: modelscope>=1.26.0
Requires-Dist: huggingface-hub>=0.32.4
Requires-Dist: json-repair>=0.46.2
Requires-Dist: opencv-python>=4.11.0.86
Requires-Dist: fast-langdetect<0.3.0,>=0.2.3
Requires-Dist: scikit-image<1.0.0,>=0.25.0
Requires-Dist: openai<3,>=1.70.0
Requires-Dist: beautifulsoup4<5,>=4.13.5
Requires-Dist: magika<0.7.0,>=0.6.2
Requires-Dist: mineru-vl-utils<1,>=0.1.14
Provides-Extra: test
Requires-Dist: mineru[core]; extra == "test"
Requires-Dist: pytest; extra == "test"
Requires-Dist: pytest-cov; extra == "test"
Requires-Dist: coverage; extra == "test"
Requires-Dist: fuzzywuzzy; extra == "test"
Provides-Extra: vlm
Requires-Dist: torch<3,>=2.6.0; extra == "vlm"
Requires-Dist: transformers<5.0.0,>=4.51.1; extra == "vlm"
Requires-Dist: accelerate>=1.5.1; extra == "vlm"
Provides-Extra: vllm
Requires-Dist: vllm<0.12,>=0.10.1.1; extra == "vllm"
Provides-Extra: pipeline
Requires-Dist: matplotlib<4,>=3.10; extra == "pipeline"
Requires-Dist: ultralytics<9,>=8.3.48; extra == "pipeline"
Requires-Dist: doclayout_yolo==0.0.4; extra == "pipeline"
Requires-Dist: dill<1,>=0.3.8; extra == "pipeline"
Requires-Dist: PyYAML<7,>=6.0.2; extra == "pipeline"
Requires-Dist: ftfy<7,>=6.3.1; extra == "pipeline"
Requires-Dist: shapely<3,>=2.0.7; extra == "pipeline"
Requires-Dist: pyclipper<2,>=1.3.0; extra == "pipeline"
Requires-Dist: omegaconf<3,>=2.3.0; extra == "pipeline"
Requires-Dist: torch<3,>=2.6.0; extra == "pipeline"
Requires-Dist: torchvision; extra == "pipeline"
Requires-Dist: transformers!=4.51.0,<5.0.0,>=4.49.0; extra == "pipeline"
Requires-Dist: onnxruntime>1.17.0; extra == "pipeline"
Provides-Extra: api
Requires-Dist: fastapi; extra == "api"
Requires-Dist: python-multipart; extra == "api"
Requires-Dist: uvicorn; extra == "api"
Provides-Extra: gradio
Requires-Dist: gradio<6,>=5.34; extra == "gradio"
Requires-Dist: gradio-pdf>=0.0.22; extra == "gradio"
Provides-Extra: core
Requires-Dist: mineru[vlm]; extra == "core"
Requires-Dist: mineru[pipeline]; extra == "core"
Requires-Dist: mineru[api]; extra == "core"
Requires-Dist: mineru[gradio]; extra == "core"
Provides-Extra: all
Requires-Dist: mineru[core]; extra == "all"
Requires-Dist: mineru[vllm]; extra == "all"
Dynamic: license-file
<div align="center" xmlns="http://www.w3.org/1999/html">
<!-- logo -->
<p align="center">
<img src="https://gcore.jsdelivr.net/gh/opendatalab/MinerU@master/docs/images/MinerU-logo.png" width="300px" style="vertical-align:middle;">
</p>
<!-- icon -->
[![stars](https://img.shields.io/github/stars/opendatalab/MinerU.svg)](https://github.com/opendatalab/MinerU)
[![forks](https://img.shields.io/github/forks/opendatalab/MinerU.svg)](https://github.com/opendatalab/MinerU)
[![open issues](https://img.shields.io/github/issues-raw/opendatalab/MinerU)](https://github.com/opendatalab/MinerU/issues)
[![issue resolution](https://img.shields.io/github/issues-closed-raw/opendatalab/MinerU)](https://github.com/opendatalab/MinerU/issues)
[![PyPI version](https://img.shields.io/pypi/v/mineru)](https://pypi.org/project/mineru/)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/mineru)](https://pypi.org/project/mineru/)
[![Downloads](https://static.pepy.tech/badge/mineru)](https://pepy.tech/project/mineru)
[![Downloads](https://static.pepy.tech/badge/mineru/month)](https://pepy.tech/project/mineru)
[![OpenDataLab](https://img.shields.io/badge/webapp_on_mineru.net-blue?logo=data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTM0IiBoZWlnaHQ9IjEzNCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cGF0aCBkPSJtMTIyLDljMCw1LTQsOS05LDlzLTktNC05LTksNC05LDktOSw5LDQsOSw5eiIgZmlsbD0idXJsKCNhKSIvPjxwYXRoIGQ9Im0xMjIsOWMwLDUtNCw5LTksOXMtOS00LTktOSw0LTksOS05LDksNCw5LDl6IiBmaWxsPSIjMDEwMTAxIi8+PHBhdGggZD0ibTkxLDE4YzAsNS00LDktOSw5cy05LTQtOS05LDQtOSw5LTksOSw0LDksOXoiIGZpbGw9InVybCgjYikiLz48cGF0aCBkP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MyZTJlMmUiLz48L2xpbmVhckdyYWRpZW50PjxsaW5lYXJHcmFkaWVudCBpZD0iYiIgeDE9Ijg0IiB5MT0iNDEiIHgyPSI3NSIgeTI9IjEyMCIgZ3JhZGllbnRVbml0cz0idXNlclNwYWNlT25Vc2UiPjxzdG9wIHN0b3AtY29sb3I9IiNmZmYiLz48c3RvcCBvZmZzZXQ9IjEiIHN0b3AtY29sb3I9IiMyZTJlMmUiLz48L2xpbmVhckdyYWRpZW50PjxsaW5lYXJHcmFkaWVudCBpZD0iYyIgeDE9Ijg0IiB5MT0iNDEiIHgyPSI3NSIgeTI9IjEyMCIgZ3JhZGllbnRVbml0cz0idXNlclNwYWNlT25Vc2UiPjxzdG9wIHN0b3AtY29sb3I9IiNmZmYiLz48c3RvcCBvZmZzZXQ9IjEiIHN0b3AtY29sb3I9IiMyZTJlMmUiLz48L2xpbmVhckdyYWRpZW50PjwvZGVmcz48L3N2Zz4=&labelColor=white)](https://mineru.net/OpenSourceTools/Extractor?source=github)
[![HuggingFace](https://img.shields.io/badge/Demo_on_HuggingFace-yellow.svg?logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAF8AAABYCAMAAACkl9t/AAAAk1BMVEVHcEz/nQv/nQv/nQr/nQv/nQr/nQv/nQv/nQr/wRf/txT/pg7/yRr/rBD/zRz/ngv/oAz/zhz/nwv/txT/ngv/0B3+zBz/nQv/0h7/wxn/vRb/thXkuiT/rxH/pxD/ogzcqyf/nQvTlSz/czCxky7/SjifdjT/Mj3+Mj3wMj15aTnDNz+DSD9RTUBsP0FRO0Q6O0WyIxEIAAAAGHRSTlMADB8zSWF3krDDw8TJ1NbX5efv8ff9/fxKDJ9uAAAGKklEQVR42u2Z63qjOAyGC4RwCOfB2JAGqrSb2WnTw/1f3UaWcSGYNKTdf/P+mOkTrE+yJBulvfvLT2A5ruenaVHyIks33npl/6C4s/ZLAM45SOi/1FtZPyFur1OYofBX3w7d54Bxm+E8db+nDr12ttmESZ4zludJEG5S7T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RudRzGQ8jVOL2qDVjjI8K1gc3TIJ5KiFZ1q+gdsARPB4NQS4AjwVSt72DSoXNyOWUrU5mQ9nRYyjp89Xo7oRI6Bga9QNT1mQ/ptaJq5T/7WcgAZywR/XlPGAUDdet3LE+qS0TI+g+aJU8MIqjo0Kx8Ly+maxLjJmjQ18rA0YCkxLQbUZP1WqdmyQGJLUm7VnQFqodmXSqmRrdVpqdzk5LvmvgtEcW8PMGdaS23EOWyDVbACZzUJPaqMbjDxpA3Qrgl0AikimGDbqmyT8P8NOYiqrldF8rX+YN7TopX4UoHuSCYY7cgX4gHwclQKl1zhx0THf+tCAUValzjI7Wg9EhptrkIcfIJjA94evOn8B2eHaVzvBrnl2ig0So6hvPaz0IGcOvTHvUIlE2+prqAxLSQxZlU2stql1NqCCLdIiIN/i1DBEHUoElM9dBravbiAnKqgpi4IBkw+utSPIoBijDXJipSVV7MpOEJUAc5Qmm3BnUN+w3hteEieYKfRZSIUcXKMVf0u5wD4EwsUNVvZOtUT7A2GkffHjByWpHqvRBYrTV72a6j8zZ6W0DTE86Hn04bmyWX3Ri9WH7ZU6Q7h+ZHo0nHUAcsQvVhXRDZHChwiyi/hnPuOsSEF6Exk3o6Y9DT1eZ+6cASXk2Y9k+6EOQMDGm6WBK10wOQJCBwren86cPPWUcRAnTVjGcU1LBgs9FURiX/e6479yZcLwCBmTxiawEwrOcleuu12t3tbLv/N4RLYIBhYexm7Fcn4OJcn0+zc+s8/VfPeddZHAGN6TT8eGczHdR/Gts1/MzDkThr23zqrVfAMFT33Nx1RJsx1k5zuWILLnG/vsH+Fv5D4NTVcp1Gzo8AAAAAElFTkSuQmCC&labelColor=white)](https://huggingface.co/spaces/opendatalab/MinerU)
[![ModelScope](https://img.shields.io/badge/Demo_on_ModelScope-purple?logo=data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjIzIiBoZWlnaHQ9IjIwMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KCiA8Zz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tNDcuODRsLTQ3Ljg0LDB6Ii8+CiAgPHBhdGggaWQ9InN2Z18yMiIgZmlsbD0iIzM2Y2ZkMSIgZD0ibTczLjQ5LDg5Ljg0bDI1LjY1LDBsMCwyNS42NDk5OWwtMjUuNjUsMGwwLC0yNS42NDk5OXoiLz4KICA8cGF0aCBpZD0ic3ZnXzIzIiBmaWxsPSIjNjI0YWZmIiBkPSJtNDcuODQsNjQuMTlsMjUuNjUsMGwwLC0yMi4xOWwtNDcuODQsMGwwLDQ3Ljg0bDIyLjE5LDBsMCwtMjUuNjV6Ii8+CiAgPHBhdGggaWQ9InN2Z18yNCIgZmlsbD0iIzYyNGFmZiIgZD0ibTQ3Ljg0LDExNS40OWwtMjIuMTksMGwwLDQ3Ljg0bDQ3Ljg0LDBsMCwtMjIuMTlsLTI1LjY1LDBsMCwtMjUuNjV6Ii8+CiA8L2c+Cjwvc3ZnPg==&labelColor=white)](https://www.modelscope.cn/studios/OpenDataLab/MinerU)
[![Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/gist/myhloli/a3cb16570ab3cfeadf9d8f0ac91b4fca/mineru_demo.ipynb)
[![arXiv](https://img.shields.io/badge/MinerU-Technical%20Report-b31b1b.svg?logo=arXiv)](https://arxiv.org/abs/2409.18839)
[![arXiv](https://img.shields.io/badge/MinerU2.5-Technical%20Report-b31b1b.svg?logo=arXiv)](https://arxiv.org/abs/2509.22186)
[![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/opendatalab/MinerU)
<a href="https://trendshift.io/repositories/11174" target="_blank"><img src="https://trendshift.io/api/badge/repositories/11174" alt="opendatalab%2FMinerU | Trendshift" style="width: 250px; height: 55px;" width="250" height="55"/></a>
<!-- language -->
[English](README.md) | [简体中文](README_zh-CN.md)
<!-- hot link -->
<p align="center">
🚀<a href="https://mineru.net/?source=github">Access MinerU Now→✅ Zero-Install Web Version ✅ Full-Featured Desktop Client ✅ Instant API Access; Skip deployment headaches – get all product formats in one click. Developers, dive in!</a>
</p>
<!-- join us -->
<p align="center">
👋 join us on <a href="https://discord.gg/Tdedn9GTXq" target="_blank">Discord</a> and <a href="https://mineru.net/community-portal/?aliasId=3c430f94" target="_blank">WeChat</a>
</p>
</div>
# Changelog
- 2025/10/24 2.6.2 Release
- `pipeline` backend optimizations
- Added experimental support for Chinese formulas, which can be enabled by setting the environment variable `export MINERU_FORMULA_CH_SUPPORT=1`. This feature may cause a slight decrease in MFR speed and failures in recognizing some long formulas. It is recommended to enable it only when parsing Chinese formulas is needed. To disable this feature, set the environment variable to `0`.
- `OCR` speed significantly improved by 200%~300%, thanks to the optimization solution provided by [@cjsdurj](https://github.com/cjsdurj)
- `OCR` models optimized for improved accuracy and coverage of Latin script recognition, and updated Cyrillic, Arabic, Devanagari, Telugu (te), and Tamil (ta) language systems to `ppocr-v5` version, with accuracy improved by over 40% compared to previous models
- `vlm` backend optimizations
- `table_caption` and `table_footnote` matching logic optimized to improve the accuracy of table caption and footnote matching and reading order rationality in scenarios with multiple consecutive tables on a page
- Optimized CPU resource usage during high concurrency when using `vllm` backend, reducing server pressure
- Adapted to `vllm` version 0.11.0
- General optimizations
- Cross-page table merging effect optimized, added support for cross-page continuation table merging, improving table merging effectiveness in multi-column merge scenarios
- Added environment variable configuration option `MINERU_TABLE_MERGE_ENABLE` for table merging feature. Table merging is enabled by default and can be disabled by setting this variable to `0`
- 2025/09/26 2.5.4 released
- 🎉🎉 The MinerU2.5 [Technical Report](https://arxiv.org/abs/2509.22186) is now available! We welcome you to read it for a comprehensive overview of its model architecture, training strategy, data engineering and evaluation results.
- Fixed an issue where some `PDF` files were mistakenly identified as `AI` files, causing parsing failures
- 2025/09/20 2.5.3 Released
- Dependency version range adjustment to enable Turing and earlier architecture GPUs to use vLLM acceleration for MinerU2.5 model inference.
- `pipeline` backend compatibility fixes for torch 2.8.0.
- Reduced default concurrency for vLLM async backend to lower server pressure and avoid connection closure issues caused by high load.
- More compatibility-related details can be found in the [announcement](https://github.com/opendatalab/MinerU/discussions/3548)
- 2025/09/19 2.5.2 Released
We are officially releasing MinerU2.5, currently the most powerful multimodal large model for document parsing.
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.
The model has been released on [HuggingFace](https://huggingface.co/opendatalab/MinerU2.5-2509-1.2B) and [ModelScope](https://modelscope.cn/models/opendatalab/MinerU2.5-2509-1.2B) platforms. Welcome to download and use!
- Core Highlights:
- SOTA Performance with Extreme Efficiency: As a 1.2B model, it achieves State-of-the-Art (SOTA) results that exceed models in the 10B and 100B+ classes, redefining the performance-per-parameter standard in document AI.
- Advanced Architecture for Across-the-Board Leadership: By combining a two-stage inference pipeline (decoupling layout analysis from content recognition) with a native high-resolution architecture, it achieves SOTA performance across five key areas: layout analysis, text recognition, formula recognition, table recognition, and reading order.
- Key Capability Enhancements:
- Layout Detection: Delivers more complete results by accurately covering non-body content like headers, footers, and page numbers. It also provides more precise element localization and natural format reconstruction for lists and references.
- Table Parsing: Drastically improves parsing for challenging cases, including rotated tables, borderless/semi-structured tables, and long/complex tables.
- Formula Recognition: Significantly boosts accuracy for complex, long-form, and hybrid Chinese-English formulas, greatly enhancing the parsing capability for mathematical documents.
Additionally, with the release of vlm 2.5, we have made some adjustments to the repository:
- The vlm backend has been upgraded to version 2.5, supporting the MinerU2.5 model and no longer compatible with the MinerU2.0-2505-0.9B model. The last version supporting the 2.0 model is mineru-2.2.2.
- VLM inference-related code has been moved to [mineru_vl_utils](https://github.com/opendatalab/mineru-vl-utils), reducing coupling with the main mineru repository and facilitating independent iteration in the future.
- The vlm accelerated inference framework has been switched from `sglang` to `vllm`, achieving full compatibility with the vllm ecosystem, allowing users to use the MinerU2.5 model and accelerated inference on any platform that supports the vllm framework.
- Due to major upgrades in the vlm model supporting more layout types, we have made some adjustments to the structure of the parsing intermediate file `middle.json` and result file `content_list.json`. Please refer to the [documentation](https://opendatalab.github.io/MinerU/reference/output_files/) for details.
Other repository optimizations:
- Removed file extension whitelist validation for input files. When input files are PDF documents or images, there are no longer requirements for file extensions, improving usability.
<details>
<summary>History Log</summary>
<details>
<summary>2025/09/10 2.2.2 Released</summary>
<ul>
<li>Fixed the issue where the new table recognition model would affect the overall parsing task when some table parsing failed</li>
</ul>
</details>
<details>
<summary>2025/09/08 2.2.1 Released</summary>
<ul>
<li>Fixed the issue where some newly added models were not downloaded when using the model download command.</li>
</ul>
</details>
<details>
<summary>2025/09/05 2.2.0 Released</summary>
<ul>
<li>
Major Updates
<ul>
<li>In this version, we focused on improving table parsing accuracy by introducing a new <a href="https://github.com/RapidAI/TableStructureRec">wired table recognition model</a> and a brand-new hybrid table structure parsing algorithm, significantly enhancing the table recognition capabilities of the <code>pipeline</code> backend.</li>
<li>We also added support for cross-page table merging, which is supported by both <code>pipeline</code> and <code>vlm</code> backends, further improving the completeness and accuracy of table parsing.</li>
</ul>
</li>
<li>
Other Updates
<ul>
<li>The <code>pipeline</code> backend now supports 270-degree rotated table parsing, bringing support for table parsing in 0/90/270-degree orientations</li>
<li><code>pipeline</code> added OCR capability support for Thai and Greek, and updated the English OCR model to the latest version. English recognition accuracy improved by 11%, Thai recognition model accuracy is 82.68%, and Greek recognition model accuracy is 89.28% (by PPOCRv5)</li>
<li>Added <code>bbox</code> field (mapped to 0-1000 range) in the output <code>content_list.json</code>, making it convenient for users to directly obtain position information for each content block</li>
<li>Removed the <code>pipeline_old_linux</code> installation option, no longer supporting legacy Linux systems such as <code>CentOS 7</code>, to provide better support for <code>uv</code>'s <code>sync</code>/<code>run</code> commands</li>
</ul>
</li>
</ul>
</details>
<details>
<summary>2025/08/01 2.1.10 Released</summary>
<ul>
<li>Fixed an issue in the <code>pipeline</code> backend where block overlap caused the parsing results to deviate from expectations #3232</li>
</ul>
</details>
<details>
<summary>2025/07/30 2.1.9 Released</summary>
<ul>
<li><code>transformers</code> 4.54.1 version adaptation</li>
</ul>
</details>
<details>
<summary>2025/07/28 2.1.8 Released</summary>
<ul>
<li><code>sglang</code> 0.4.9.post5 version adaptation</li>
</ul>
</details>
<details>
<summary>2025/07/27 2.1.7 Released</summary>
<ul>
<li><code>transformers</code> 4.54.0 version adaptation</li>
</ul>
</details>
<details>
<summary>2025/07/26 2.1.6 Released</summary>
<ul>
<li>Fixed table parsing issues in handwritten documents when using <code>vlm</code> backend</li>
<li>Fixed visualization box position drift issue when document is rotated #3175</li>
</ul>
</details>
<details>
<summary>2025/07/24 2.1.5 Released</summary>
<ul>
<li><code>sglang</code> 0.4.9 version adaptation, synchronously upgrading the dockerfile base image to sglang 0.4.9.post3</li>
</ul>
</details>
<details>
<summary>2025/07/23 2.1.4 Released</summary>
<ul>
<li><strong>Bug Fixes</strong>
<ul>
<li>Fixed the issue of excessive memory consumption during the <code>MFR</code> step in the <code>pipeline</code> backend under certain scenarios #2771</li>
<li>Fixed the inaccurate matching between <code>image</code>/<code>table</code> and <code>caption</code>/<code>footnote</code> under certain conditions #3129</li>
</ul>
</li>
</ul>
</details>
<details>
<summary>2025/07/16 2.1.1 Released</summary>
<ul>
<li><strong>Bug fixes</strong>
<ul>
<li>Fixed text block content loss issue that could occur in certain <code>pipeline</code> scenarios #3005</li>
<li>Fixed issue where <code>sglang-client</code> required unnecessary packages like <code>torch</code> #2968</li>
<li>Updated <code>dockerfile</code> to fix incomplete text content parsing due to missing fonts in Linux #2915</li>
</ul>
</li>
<li><strong>Usability improvements</strong>
<ul>
<li>Updated <code>compose.yaml</code> to facilitate direct startup of <code>sglang-server</code>, <code>mineru-api</code>, and <code>mineru-gradio</code> services</li>
<li>Launched brand new <a href="https://opendatalab.github.io/MinerU/">online documentation site</a>, simplified readme, providing better documentation experience</li>
</ul>
</li>
</ul>
</details>
<details>
<summary>2025/07/05 2.1.0 Released</summary>
<ul>
<li>This is the first major update of MinerU 2, which includes a large number of new features and improvements, covering significant performance optimizations, user experience enhancements, and bug fixes. The detailed update contents are as follows:</li>
<li><strong>Performance Optimizations:</strong>
<ul>
<li>Significantly improved preprocessing speed for documents with specific resolutions (around 2000 pixels on the long side).</li>
<li>Greatly enhanced post-processing speed when the <code>pipeline</code> backend handles batch processing of documents with fewer pages (&lt;10 pages).</li>
<li>Layout analysis speed of the <code>pipeline</code> backend has been increased by approximately 20%.</li>
</ul>
</li>
<li><strong>Experience Enhancements:</strong>
<ul>
<li>Built-in ready-to-use <code>fastapi service</code> and <code>gradio webui</code>. For detailed usage instructions, please refer to <a href="https://opendatalab.github.io/MinerU/usage/quick_usage/#advanced-usage-via-api-webui-sglang-clientserver">Documentation</a>.</li>
<li>Adapted to <code>sglang</code> version <code>0.4.8</code>, significantly reducing the GPU memory requirements for the <code>vlm-sglang</code> backend. It can now run on graphics cards with as little as <code>8GB GPU memory</code> (Turing architecture or newer).</li>
<li>Added transparent parameter passing for all commands related to <code>sglang</code>, allowing the <code>sglang-engine</code> backend to receive all <code>sglang</code> parameters consistently with the <code>sglang-server</code>.</li>
<li>Supports feature extensions based on configuration files, including <code>custom formula delimiters</code>, <code>enabling heading classification</code>, and <code>customizing local model directories</code>. For detailed usage instructions, please refer to <a href="https://opendatalab.github.io/MinerU/usage/quick_usage/#extending-mineru-functionality-with-configuration-files">Documentation</a>.</li>
</ul>
</li>
<li><strong>New Features:</strong>
<ul>
<li>Updated the <code>pipeline</code> backend with the PP-OCRv5 multilingual text recognition model, supporting text recognition in 37 languages such as French, Spanish, Portuguese, Russian, and Korean, with an average accuracy improvement of over 30%. <a href="https://paddlepaddle.github.io/PaddleOCR/latest/en/version3.x/algorithm/PP-OCRv5/PP-OCRv5_multi_languages.html">Details</a></li>
<li>Introduced limited support for vertical text layout in the <code>pipeline</code> backend.</li>
</ul>
</li>
</ul>
</details>
<details>
<summary>2025/06/20 2.0.6 Released</summary>
<ul>
<li>Fixed occasional parsing interruptions caused by invalid block content in <code>vlm</code> mode</li>
<li>Fixed parsing interruptions caused by incomplete table structures in <code>vlm</code> mode</li>
</ul>
</details>
<details>
<summary>2025/06/17 2.0.5 Released</summary>
<ul>
<li>Fixed the issue where models were still required to be downloaded in the <code>sglang-client</code> mode</li>
<li>Fixed the issue where the <code>sglang-client</code> mode unnecessarily depended on packages like <code>torch</code> during runtime.</li>
<li>Fixed the issue where only the first instance would take effect when attempting to launch multiple <code>sglang-client</code> instances via multiple URLs within the same process</li>
</ul>
</details>
<details>
<summary>2025/06/15 2.0.3 released</summary>
<ul>
<li>Fixed a configuration file key-value update error that occurred when downloading model type was set to <code>all</code></li>
<li>Fixed the issue where the formula and table feature toggle switches were not working in <code>command line mode</code>, causing the features to remain enabled.</li>
<li>Fixed compatibility issues with sglang version 0.4.7 in the <code>sglang-engine</code> mode.</li>
<li>Updated Dockerfile and installation documentation for deploying the full version of MinerU in sglang environment</li>
</ul>
</details>
<details>
<summary>2025/06/13 2.0.0 Released</summary>
<ul>
<li><strong>New Architecture</strong>: MinerU 2.0 has been deeply restructured in code organization and interaction methods, significantly improving system usability, maintainability, and extensibility.
<ul>
<li><strong>Removal of Third-party Dependency Limitations</strong>: Completely eliminated the dependency on <code>pymupdf</code>, moving the project toward a more open and compliant open-source direction.</li>
<li><strong>Ready-to-use, Easy Configuration</strong>: No need to manually edit JSON configuration files; most parameters can now be set directly via command line or API.</li>
<li><strong>Automatic Model Management</strong>: Added automatic model download and update mechanisms, allowing users to complete model deployment without manual intervention.</li>
<li><strong>Offline Deployment Friendly</strong>: Provides built-in model download commands, supporting deployment requirements in completely offline environments.</li>
<li><strong>Streamlined Code Structure</strong>: Removed thousands of lines of redundant code, simplified class inheritance logic, significantly improving code readability and development efficiency.</li>
<li><strong>Unified Intermediate Format Output</strong>: Adopted standardized <code>middle_json</code> format, compatible with most secondary development scenarios based on this format, ensuring seamless ecosystem business migration.</li>
</ul>
</li>
<li><strong>New Model</strong>: MinerU 2.0 integrates our latest small-parameter, high-performance multimodal document parsing model, achieving end-to-end high-speed, high-precision document understanding.
<ul>
<li><strong>Small Model, Big Capabilities</strong>: With parameters under 1B, yet surpassing traditional 72B-level vision-language models (VLMs) in parsing accuracy.</li>
<li><strong>Multiple Functions in One</strong>: A single model covers multilingual recognition, handwriting recognition, layout analysis, table parsing, formula recognition, reading order sorting, and other core tasks.</li>
<li><strong>Ultimate Inference Speed</strong>: Achieves peak throughput exceeding 10,000 tokens/s through <code>sglang</code> acceleration on a single NVIDIA 4090 card, easily handling large-scale document processing requirements.</li>
<li><strong>Online Experience</strong>: You can experience our brand-new VLM model on <a href="https://mineru.net/OpenSourceTools/Extractor">MinerU.net</a>, <a href="https://huggingface.co/spaces/opendatalab/MinerU">Hugging Face</a>, and <a href="https://www.modelscope.cn/studios/OpenDataLab/MinerU">ModelScope</a>.</li>
</ul>
</li>
<li><strong>Incompatible Changes Notice</strong>: To improve overall architectural rationality and long-term maintainability, this version contains some incompatible changes:
<ul>
<li>Python package name changed from <code>magic-pdf</code> to <code>mineru</code>, and the command-line tool changed from <code>magic-pdf</code> to <code>mineru</code>. Please update your scripts and command calls accordingly.</li>
<li>For modular system design and ecosystem consistency considerations, MinerU 2.0 no longer includes the LibreOffice document conversion module. If you need to process Office documents, we recommend converting them to PDF format through an independently deployed LibreOffice service before proceeding with subsequent parsing operations.</li>
</ul>
</li>
</ul>
</details>
<details>
<summary>2025/05/24 Release 1.3.12</summary>
<ul>
<li>Added support for PPOCRv5 models, updated <code>ch_server</code> model to <code>PP-OCRv5_rec_server</code>, and <code>ch_lite</code> model to <code>PP-OCRv5_rec_mobile</code> (model update required)
<ul>
<li>In testing, we found that PPOCRv5(server) has some improvement for handwritten documents, but has slightly lower accuracy than v4_server_doc for other document types, so the default ch model remains unchanged as <code>PP-OCRv4_server_rec_doc</code>.</li>
<li>Since PPOCRv5 has enhanced recognition capabilities for handwriting and special characters, you can manually choose the PPOCRv5 model for Japanese-Traditional Chinese mixed scenarios and handwritten documents</li>
<li>You can select the appropriate model through the lang parameter <code>lang='ch_server'</code> (Python API) or <code>--lang ch_server</code> (command line):
<ul>
<li><code>ch</code>: <code>PP-OCRv4_server_rec_doc</code> (default) (Chinese/English/Japanese/Traditional Chinese mixed/15K dictionary)</li>
<li><code>ch_server</code>: <code>PP-OCRv5_rec_server</code> (Chinese/English/Japanese/Traditional Chinese mixed + handwriting/18K dictionary)</li>
<li><code>ch_lite</code>: <code>PP-OCRv5_rec_mobile</code> (Chinese/English/Japanese/Traditional Chinese mixed + handwriting/18K dictionary)</li>
<li><code>ch_server_v4</code>: <code>PP-OCRv4_rec_server</code> (Chinese/English mixed/6K dictionary)</li>
<li><code>ch_lite_v4</code>: <code>PP-OCRv4_rec_mobile</code> (Chinese/English mixed/6K dictionary)</li>
</ul>
</li>
</ul>
</li>
<li>Added support for handwritten documents through optimized layout recognition of handwritten text areas
<ul>
<li>This feature is supported by default, no additional configuration required</li>
<li>You can refer to the instructions above to manually select the PPOCRv5 model for better handwritten document parsing results</li>
</ul>
</li>
<li>The <code>huggingface</code> and <code>modelscope</code> demos have been updated to versions that support handwriting recognition and PPOCRv5 models, which you can experience online</li>
</ul>
</details>
<details>
<summary>2025/04/29 Release 1.3.10</summary>
<ul>
<li>Added support for custom formula delimiters, which can be configured by modifying the <code>latex-delimiter-config</code> section in the <code>magic-pdf.json</code> file in your user directory.</li>
</ul>
</details>
<details>
<summary>2025/04/27 Release 1.3.9</summary>
<ul>
<li>Optimized formula parsing functionality, improved formula rendering success rate</li>
</ul>
</details>
<details>
<summary>2025/04/23 Release 1.3.8</summary>
<ul>
<li>The default <code>ocr</code> model (<code>ch</code>) has been updated to <code>PP-OCRv4_server_rec_doc</code> (model update required)
<ul>
<li><code>PP-OCRv4_server_rec_doc</code> is trained on a mixture of more Chinese document data and PP-OCR training data based on <code>PP-OCRv4_server_rec</code>, adding recognition capabilities for some traditional Chinese characters, Japanese, and special characters. It can recognize over 15,000 characters and improves both document-specific and general text recognition abilities.</li>
<li><a href="https://paddlepaddle.github.io/PaddleX/latest/module_usage/tutorials/ocr_modules/text_recognition.html#_3">Performance comparison of PP-OCRv4_server_rec_doc/PP-OCRv4_server_rec/PP-OCRv4_mobile_rec</a></li>
<li>After verification, the <code>PP-OCRv4_server_rec_doc</code> model shows significant accuracy improvements in Chinese/English/Japanese/Traditional Chinese in both single language and mixed language scenarios, with comparable speed to <code>PP-OCRv4_server_rec</code>, making it suitable for most use cases.</li>
<li>In some pure English scenarios, <code>PP-OCRv4_server_rec_doc</code> may have word adhesion issues, while <code>PP-OCRv4_server_rec</code> performs better in these cases. Therefore, we've kept the <code>PP-OCRv4_server_rec</code> model, which users can access by adding the parameter <code>lang='ch_server'</code> (Python API) or <code>--lang ch_server</code> (command line).</li>
</ul>
</li>
</ul>
</details>
<details>
<summary>2025/04/22 Release 1.3.7</summary>
<ul>
<li>Fixed the issue where the lang parameter was ineffective during table parsing model initialization</li>
<li>Fixed the significant speed reduction of OCR and table parsing in <code>cpu</code> mode</li>
</ul>
</details>
<details>
<summary>2025/04/16 Release 1.3.4</summary>
<ul>
<li>Slightly improved OCR-det speed by removing some unnecessary blocks</li>
<li>Fixed page-internal sorting errors caused by footnotes in certain cases</li>
</ul>
</details>
<details>
<summary>2025/04/12 Release 1.3.2</summary>
<ul>
<li>Fixed dependency version incompatibility issues when installing on Windows with Python 3.13</li>
<li>Optimized memory usage during batch inference</li>
<li>Improved parsing of tables rotated 90 degrees</li>
<li>Enhanced parsing of oversized tables in financial report samples</li>
<li>Fixed the occasional word adhesion issue in English text areas when OCR language is not specified (model update required)</li>
</ul>
</details>
<details>
<summary>2025/04/08 Release 1.3.1</summary>
<ul>
<li>Fixed several compatibility issues
<ul>
<li>Added support for Python 3.13</li>
<li>Made final adaptations for outdated Linux systems (such as CentOS 7) with no guarantee of continued support in future versions, <a href="https://github.com/opendatalab/MinerU/issues/1004">installation instructions</a></li>
</ul>
</li>
</ul>
</details>
<details>
<summary>2025/04/03 Release 1.3.0</summary>
<ul>
<li>Installation and compatibility optimizations
<ul>
<li>Resolved compatibility issues caused by <code>detectron2</code> by removing <code>layoutlmv3</code> usage in layout</li>
<li>Extended torch version compatibility to 2.2~2.6 (excluding 2.5)</li>
<li>Added CUDA compatibility for versions 11.8/12.4/12.6/12.8 (CUDA version determined by torch), solving compatibility issues for users with 50-series and H-series GPUs</li>
<li>Extended Python compatibility to versions 3.10~3.12, fixing the issue of automatic downgrade to version 0.6.1 when installing in non-3.10 environments</li>
<li>Optimized offline deployment process, eliminating the need to download any model files after successful deployment</li>
</ul>
</li>
<li>Performance optimizations
<ul>
<li>Enhanced parsing speed for batches of small files by supporting batch processing of multiple PDF files (<a href="demo/batch_demo.py">script example</a>), with formula parsing speed improved by up to 1400% and overall parsing speed improved by up to 500% compared to version 1.0.1</li>
<li>Reduced memory usage and improved parsing speed by optimizing MFR model loading and usage (requires re-running the <a href="docs/how_to_download_models_zh_cn.md">model download process</a> to get incremental updates to model files)</li>
<li>Optimized GPU memory usage, requiring only 6GB minimum to run this project</li>
<li>Improved running speed on MPS devices</li>
</ul>
</li>
<li>Parsing effect optimizations
<ul>
<li>Updated MFR model to <code>unimernet(2503)</code>, fixing line break loss issues in multi-line formulas</li>
</ul>
</li>
<li>Usability optimizations
<ul>
<li>Completely replaced the <code>paddle</code> framework and <code>paddleocr</code> in the project by using <code>paddleocr2torch</code>, resolving conflicts between <code>paddle</code> and <code>torch</code>, as well as thread safety issues caused by the <code>paddle</code> framework</li>
<li>Added real-time progress bar display during parsing, allowing precise tracking of parsing progress and making the waiting process more bearable</li>
</ul>
</li>
</ul>
</details>
<details>
<summary>2025/03/03 1.2.1 released</summary>
<ul>
<li>Fixed the impact on punctuation marks during full-width to half-width conversion of letters and numbers</li>
<li>Fixed caption matching inaccuracies in certain scenarios</li>
<li>Fixed formula span loss issues in certain scenarios</li>
</ul>
</details>
<details>
<summary>2025/02/24 1.2.0 released</summary>
<p>This version includes several fixes and improvements to enhance parsing efficiency and accuracy:</p>
<ul>
<li><strong>Performance Optimization</strong>
<ul>
<li>Increased classification speed for PDF documents in auto mode.</li>
</ul>
</li>
<li><strong>Parsing Optimization</strong>
<ul>
<li>Improved parsing logic for documents containing watermarks, significantly enhancing the parsing results for such documents.</li>
<li>Enhanced the matching logic for multiple images/tables and captions within a single page, improving the accuracy of image-text matching in complex layouts.</li>
</ul>
</li>
<li><strong>Bug Fixes</strong>
<ul>
<li>Fixed an issue where image/table spans were incorrectly filled into text blocks under certain conditions.</li>
<li>Resolved an issue where title blocks were empty in some cases.</li>
</ul>
</li>
</ul>
</details>
<details>
<summary>2025/01/22 1.1.0 released</summary>
<p>In this version we have focused on improving parsing accuracy and efficiency:</p>
<ul>
<li><strong>Model capability upgrade</strong> (requires re-executing the <a href="https://github.com/opendatalab/MinerU/blob/master/docs/how_to_download_models_en.md">model download process</a> to obtain incremental updates of model files)
<ul>
<li>The layout recognition model has been upgraded to the latest <code>doclayout_yolo(2501)</code> model, improving layout recognition accuracy.</li>
<li>The formula parsing model has been upgraded to the latest <code>unimernet(2501)</code> model, improving formula recognition accuracy.</li>
</ul>
</li>
<li><strong>Performance optimization</strong>
<ul>
<li>On devices that meet certain configuration requirements (16GB+ VRAM), by optimizing resource usage and restructuring the processing pipeline, overall parsing speed has been increased by more than 50%.</li>
</ul>
</li>
<li><strong>Parsing effect optimization</strong>
<ul>
<li>Added a new heading classification feature (testing version, enabled by default) to the online demo (<a href="https://mineru.net/OpenSourceTools/Extractor">mineru.net</a>/<a href="https://huggingface.co/spaces/opendatalab/MinerU">huggingface</a>/<a href="https://www.modelscope.cn/studios/OpenDataLab/MinerU">modelscope</a>), which supports hierarchical classification of headings, thereby enhancing document structuring.</li>
</ul>
</li>
</ul>
</details>
<details>
<summary>2025/01/10 1.0.1 released</summary>
<p>This is our first official release, where we have introduced a completely new API interface and enhanced compatibility through extensive refactoring, as well as a brand new automatic language identification feature:</p>
<ul>
<li><strong>New API Interface</strong>
<ul>
<li>For the data-side API, we have introduced the Dataset class, designed to provide a robust and flexible data processing framework. This framework currently supports a variety of document formats, including images (.jpg and .png), PDFs, Word documents (.doc and .docx), and PowerPoint presentations (.ppt and .pptx). It ensures effective support for data processing tasks ranging from simple to complex.</li>
<li>For the user-side API, we have meticulously designed the MinerU processing workflow as a series of composable Stages. Each Stage represents a specific processing step, allowing users to define new Stages according to their needs and creatively combine these stages to customize their data processing workflows.</li>
</ul>
</li>
<li><strong>Enhanced Compatibility</strong>
<ul>
<li>By optimizing the dependency environment and configuration items, we ensure stable and efficient operation on ARM architecture Linux systems.</li>
<li>We have deeply integrated with Huawei Ascend NPU acceleration, providing autonomous and controllable high-performance computing capabilities. This supports the localization and development of AI application platforms in China. <a href="https://github.com/opendatalab/MinerU/blob/master/docs/README_Ascend_NPU_Acceleration_zh_CN.md">Ascend NPU Acceleration</a></li>
</ul>
</li>
<li><strong>Automatic Language Identification</strong>
<ul>
<li>By introducing a new language recognition model, setting the <code>lang</code> configuration to <code>auto</code> during document parsing will automatically select the appropriate OCR language model, improving the accuracy of scanned document parsing.</li>
</ul>
</li>
</ul>
</details>
<details>
<summary>2024/11/22 0.10.0 released</summary>
<p>Introducing hybrid OCR text extraction capabilities:</p>
<ul>
<li>Significantly improved parsing performance in complex text distribution scenarios such as dense formulas, irregular span regions, and text represented by images.</li>
<li>Combines the dual advantages of accurate content extraction and faster speed in text mode, and more precise span/line region recognition in OCR mode.</li>
</ul>
</details>
<details>
<summary>2024/11/15 0.9.3 released</summary>
<p>Integrated <a href="https://github.com/RapidAI/RapidTable">RapidTable</a> for table recognition, improving single-table parsing speed by more than 10 times, with higher accuracy and lower GPU memory usage.</p>
</details>
<details>
<summary>2024/11/06 0.9.2 released</summary>
<p>Integrated the <a href="https://huggingface.co/U4R/StructTable-InternVL2-1B">StructTable-InternVL2-1B</a> model for table recognition functionality.</p>
</details>
<details>
<summary>2024/10/31 0.9.0 released</summary>
<p>This is a major new version with extensive code refactoring, addressing numerous issues, improving performance, reducing hardware requirements, and enhancing usability:</p>
<ul>
<li>Refactored the sorting module code to use <a href="https://github.com/ppaanngggg/layoutreader">layoutreader</a> for reading order sorting, ensuring high accuracy in various layouts.</li>
<li>Refactored the paragraph concatenation module to achieve good results in cross-column, cross-page, cross-figure, and cross-table scenarios.</li>
<li>Refactored the list and table of contents recognition functions, significantly improving the accuracy of list blocks and table of contents blocks, as well as the parsing of corresponding text paragraphs.</li>
<li>Refactored the matching logic for figures, tables, and descriptive text, greatly enhancing the accuracy of matching captions and footnotes to figures and tables, and reducing the loss rate of descriptive text to near zero.</li>
<li>Added multi-language support for OCR, supporting detection and recognition of 84 languages. For the list of supported languages, see <a href="https://paddlepaddle.github.io/PaddleOCR/latest/en/ppocr/blog/multi_languages.html#5-support-languages-and-abbreviations">OCR Language Support List</a>.</li>
<li>Added memory recycling logic and other memory optimization measures, significantly reducing memory usage. The memory requirement for enabling all acceleration features except table acceleration (layout/formula/OCR) has been reduced from 16GB to 8GB, and the memory requirement for enabling all acceleration features has been reduced from 24GB to 10GB.</li>
<li>Optimized configuration file feature switches, adding an independent formula detection switch to significantly improve speed and parsing results when formula detection is not needed.</li>
<li>Integrated <a href="https://github.com/opendatalab/PDF-Extract-Kit">PDF-Extract-Kit 1.0</a>:
<ul>
<li>Added the self-developed <code>doclayout_yolo</code> model, which speeds up processing by more than 10 times compared to the original solution while maintaining similar parsing effects, and can be freely switched with <code>layoutlmv3</code> via the configuration file.</li>
<li>Upgraded formula parsing to <code>unimernet 0.2.1</code>, improving formula parsing accuracy while significantly reducing memory usage.</li>
<li>Due to the repository change for <code>PDF-Extract-Kit 1.0</code>, you need to re-download the model. Please refer to <a href="https://github.com/opendatalab/MinerU/blob/master/docs/how_to_download_models_en.md">How to Download Models</a> for detailed steps.</li>
</ul>
</li>
</ul>
</details>
<details>
<summary>2024/09/27 Version 0.8.1 released</summary>
<p>Fixed some bugs, and providing a <a href="https://github.com/opendatalab/MinerU/blob/master/projects/web_demo/README.md">localized deployment version</a> of the <a href="https://opendatalab.com/OpenSourceTools/Extractor/PDF/">online demo</a> and the <a href="https://github.com/opendatalab/MinerU/blob/master/projects/web/README.md">front-end interface</a>.</p>
</details>
<details>
<summary>2024/09/09 Version 0.8.0 released</summary>
<p>Supporting fast deployment with Dockerfile, and launching demos on Huggingface and Modelscope.</p>
</details>
<details>
<summary>2024/08/30 Version 0.7.1 released</summary>
<p>Add paddle tablemaster table recognition option</p>
</details>
<details>
<summary>2024/08/09 Version 0.7.0b1 released</summary>
<p>Simplified installation process, added table recognition functionality</p>
</details>
<details>
<summary>2024/08/01 Version 0.6.2b1 released</summary>
<p>Optimized dependency conflict issues and installation documentation</p>
</details>
<details>
<summary>2024/07/05 Initial open-source release</summary>
</details>
</details>
# MinerU
## Project Introduction
MinerU is a tool that converts PDFs into machine-readable formats (e.g., markdown, JSON), allowing for easy extraction into any format.
MinerU was born during the pre-training process of [InternLM](https://github.com/InternLM/InternLM). We focus on solving symbol conversion issues in scientific literature and hope to contribute to technological development in the era of large models.
Compared to well-known commercial products, MinerU is still young. If you encounter any issues or if the results are not as expected, please submit an issue on [issue](https://github.com/opendatalab/MinerU/issues) and **attach the relevant PDF**.
https://github.com/user-attachments/assets/4bea02c9-6d54-4cd6-97ed-dff14340982c
## Key Features
- Remove headers, footers, footnotes, page numbers, etc., to ensure semantic coherence.
- Output text in human-readable order, suitable for single-column, multi-column, and complex layouts.
- Preserve the structure of the original document, including headings, paragraphs, lists, etc.
- Extract images, image descriptions, tables, table titles, and footnotes.
- Automatically recognize and convert formulas in the document to LaTeX format.
- Automatically recognize and convert tables in the document to HTML format.
- Automatically detect scanned PDFs and garbled PDFs and enable OCR functionality.
- OCR supports detection and recognition of 84 languages.
- Supports multiple output formats, such as multimodal and NLP Markdown, JSON sorted by reading order, and rich intermediate formats.
- Supports various visualization results, including layout visualization and span visualization, for efficient confirmation of output quality.
- Supports running in a pure CPU environment, and also supports GPU(CUDA)/NPU(CANN)/MPS acceleration
- Compatible with Windows, Linux, and Mac platforms.
# Quick Start
If you encounter any installation issues, please first consult the <a href="#faq">FAQ</a>. </br>
If the parsing results are not as expected, refer to the <a href="#known-issues">Known Issues</a>. </br>
## Online Experience
### Official online web application
The official online version has the same functionality as the client, with a beautiful interface and rich features, requires login to use
- [![OpenDataLab](https://img.shields.io/badge/webapp_on_mineru.net-blue?logo=data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTM0IiBoZWlnaHQ9IjEzNCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cGF0aCBkPSJtMTIyLDljMCw1LTQsOS05LDlzLTktNC05LTksNC05LDktOSw5LDQsOSw5eiIgZmlsbD0idXJsKCNhKSIvPjxwYXRoIGQ9Im0xMjIsOWMwLDUtNCw5LTksOXMtOS00LTktOSw0LTksOS05LDksNCw5LDl6IiBmaWxsPSIjMDEwMTAxIi8+PHBhdGggZD0ibTkxLDE4YzAsNS00LDktOSw5cy05LTQtOS05LDQtOSw5LTksOSw0LDksOXoiIGZpbGw9InVybCgjYikiLz48cGF0aCBkPSJtOTEsMThjMCw1LTQsOS05LDlzLTktNC05LTksNC05LDktOSw5LDQsOSw5eiIgZmlsbD0iIzAxMDEwMSIvPjxwYXRoIGZpbGwtcnVsZT0iZXZlbm9kZCIgY2xpcC1ydWxlPSJldmVub2RkIiBkPSJtMzksNjJjMCwxNiw4LDMwLDIwLDM4LDctNiwxMi0xNiwxMi0yNlY0OWMwLTQsMy03LDYtOGw0Ni0xMmM1LTEsMTEsMywxMSw4djMxYzAsMzctMzAsNjYtNjYsNjYtMzcsMC02Ni0zMC02Ni02NlY0NmMwLTQsMy03LDYtOGwyMC02YzUtMSwxMSwzLDExLDh2MjF6bS0yOSw2YzAsMTYsNiwzMCwxNyw0MCwzLDEsNSwxLDgsMSw1LDAsMTAtMSwxNS0zQzM3LDk1LDI5LDc5LDI5LDYyVjQybC0xOSw1djIweiIgZmlsbD0idXJsKCNjKSIvPjxwYXRoIGZpbGwtcnVsZT0iZXZlbm9kZCIgY2xpcC1ydWxlPSJldmVub2RkIiBkPSJtMzksNjJjMCwxNiw4LDMwLDIwLDM4LDctNiwxMi0xNiwxMi0yNlY0OWMwLTQsMy03LDYtOGw0Ni0xMmM1LTEsMTEsMywxMSw4djMxYzAsMzctMzAsNjYtNjYsNjYtMzcsMC02Ni0zMC02Ni02NlY0NmMwLTQsMy03LDYtOGwyMC02YzUtMSwxMSwzLDExLDh2MjF6bS0yOSw2YzAsMTYsNiwzMCwxNyw0MCwzLDEsNSwxLDgsMSw1LDAsMTAtMSwxNS0zQzM3LDk1LDI5LDc5LDI5LDYyVjQybC0xOSw1djIweiIgZmlsbD0iIzAxMDEwMSIvPjxkZWZzPjxsaW5lYXJHcmFkaWVudCBpZD0iYSIgeDE9Ijg0IiB5MT0iNDEiIHgyPSI3NSIgeTI9IjEyMCIgZ3JhZGllbnRVbml0cz0idXNlclNwYWNlT25Vc2UiPjxzdG9wIHN0b3AtY29sb3I9IiNmZmYiLz48c3RvcCBvZmZzZXQ9IjEiIHN0b3AtY29sb3I9IiMyZTJlMmUiLz48L2xpbmVhckdyYWRpZW50PjxsaW5lYXJHcmFkaWVudCBpZD0iYiIgeDE9Ijg0IiB5MT0iNDEiIHgyPSI3NSIgeTI9IjEyMCIgZ3JhZGllbnRVbml0cz0idXNlclNwYWNlT25Vc2UiPjxzdG9wIHN0b3AtY29sb3I9IiNmZmYiLz48c3RvcCBvZmZzZXQ9IjEiIHN0b3AtY29sb3I9IiMyZTJlMmUiLz48L2xpbmVhckdyYWRpZW50PjxsaW5lYXJHcmFkaWVudCBpZD0iYyIgeDE9Ijg0IiB5MT0iNDEiIHgyPSI3NSIgeTI9IjEyMCIgZ3JhZGllbnRVbml0cz0idXNlclNwYWNlT25Vc2UiPjxzdG9wIHN0b3AtY29sb3I9IiNmZmYiLz48c3RvcCBvZmZzZXQ9IjEiIHN0b3AtY29sb3I9IiMyZTJlMmUiLz48L2xpbmVhckdyYWRpZW50PjwvZGVmcz48L3N2Zz4=&labelColor=white)](https://mineru.net/OpenSourceTools/Extractor?source=github)
### Gradio-based online demo
A WebUI developed based on Gradio, with a simple interface and only core parsing functionality, no login required
- [![ModelScope](https://img.shields.io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ShkZXe9QdO/uOvHofxjrV/TNS6iMJS+4TcSTgk9n5agJdBQbB//IfF/HpvPt3Tbi7b6I6K0R72p6ajryEJrENW2bbeVUGjfgoals4L443c7BEE4mJO2SpbRngxQrAKRudRzGQ8jVOL2qDVjjI8K1gc3TIJ5KiFZ1q+gdsARPB4NQS4AjwVSt72DSoXNyOWUrU5mQ9nRYyjp89Xo7oRI6Bga9QNT1mQ/ptaJq5T/7WcgAZywR/XlPGAUDdet3LE+qS0TI+g+aJU8MIqjo0Kx8Ly+maxLjJmjQ18rA0YCkxLQbUZP1WqdmyQGJLUm7VnQFqodmXSqmRrdVpqdzk5LvmvgtEcW8PMGdaS23EOWyDVbACZzUJPaqMbjDxpA3Qrgl0AikimGDbqmyT8P8NOYiqrldF8rX+YN7TopX4UoHuSCYY7cgX4gHwclQKl1zhx0THf+tCAUValzjI7Wg9EhptrkIcfIJjA94evOn8B2eHaVzvBrnl2ig0So6hvPaz0IGcOvTHvUIlE2+prqAxLSQxZlU2stql1NqCCLdIiIN/i1DBEHUoElM9dBravbiAnKqgpi4IBkw+utSPIoBijDXJipSVV7MpOEJUAc5Qmm3BnUN+w3hteEieYKfRZSIUcXKMVf0u5wD4EwsUNVvZOtUT7A2GkffHjByWpHqvRBYrTV72a6j8zZ6W0DTE86Hn04bmyWX3Ri9WH7ZU6Q7h+ZHo0nHUAcsQvVhXRDZHChwiyi/hnPuOsSEF6Exk3o6Y9DT1eZ+6cASXk2Y9k+6EOQMDGm6WBK10wOQJCBwren86cPPWUcRAnTVjGcU1LBgs9FURiX/e6479yZcLwCBmTxiawEwrOcleuu12t3tbLv/N4RLYIBhYexm7Fcn4OJcn0+zc+s8/VfPeddZHAGN6TT8eGczHdR/Gts1/MzDkThr23zqrVfAMFT33Nx1RJsx1k5zuWILLnG/vsH+Fv5D4NTVcp1Gzo8AAAAAElFTkSuQmCC&labelColor=white)](https://huggingface.co/spaces/opendatalab/MinerU)
## Local Deployment
> [!WARNING]
> **Pre-installation Notice—Hardware and Software Environment Support**
>
> To ensure the stability and reliability of the project, we only optimize and test for specific hardware and software environments during development. This ensures that users deploying and running the project on recommended system configurations will get the best performance with the fewest compatibility issues.
>
> By focusing resources on the mainline environment, our team can more efficiently resolve potential bugs and develop new features.
>
> In non-mainline environments, due to the diversity of hardware and software configurations, as well as third-party dependency compatibility issues, we cannot guarantee 100% project availability. Therefore, for users who wish to use this project in non-recommended environments, we suggest carefully reading the documentation and FAQ first. Most issues already have corresponding solutions in the FAQ. We also encourage community feedback to help us gradually expand support.
<table>
<tr>
<td>Parsing Backend</td>
<td>pipeline</td>
<td>vlm-transformers</td>
<td>vlm-vllm</td>
</tr>
<tr>
<td>Operating System</td>
<td>Linux / Windows / macOS</td>
<td>Linux / Windows</td>
<td>Linux / Windows (via WSL2)</td>
</tr>
<tr>
<td>CPU Inference Support</td>
<td>✅</td>
<td colspan="2">❌</td>
</tr>
<tr>
<td>GPU Requirements</td>
<td>Turing architecture and later, 6GB+ VRAM or Apple Silicon</td>
<td colspan="2">Turing architecture and later, 8GB+ VRAM</td>
</tr>
<tr>
<td>Memory Requirements</td>
<td colspan="3">Minimum 16GB+, recommended 32GB+</td>
</tr>
<tr>
<td>Disk Space Requirements</td>
<td colspan="3">20GB+, SSD recommended</td>
</tr>
<tr>
<td>Python Version</td>
<td colspan="3">3.10-3.13</td>
</tr>
</table>
### Install MinerU
#### Install MinerU using pip or uv
```bash
pip install --upgrade pip
pip install uv
uv pip install -U "mineru[core]"
```
#### Install MinerU from source code
```bash
git clone https://github.com/opendatalab/MinerU.git
cd MinerU
uv pip install -e .[core]
```
> [!TIP]
> `mineru[core]` includes all core features except `vLLM` acceleration, compatible with Windows / Linux / macOS systems, suitable for most users.
> If you need to use `vLLM` acceleration for VLM model inference or install a lightweight client on edge devices, please refer to the documentation [Extension Modules Installation Guide](https://opendatalab.github.io/MinerU/quick_start/extension_modules/).
---
#### Deploy MinerU using Docker
MinerU provides a convenient Docker deployment method, which helps quickly set up the environment and solve some tricky environment compatibility issues.
You can get the [Docker Deployment Instructions](https://opendatalab.github.io/MinerU/quick_start/docker_deployment/) in the documentation.
---
### Using MinerU
The simplest command line invocation is:
```bash
mineru -p <input_path> -o <output_path>
```
You can use MinerU for PDF parsing through various methods such as command line, API, and WebUI. For detailed instructions, please refer to the [Usage Guide](https://opendatalab.github.io/MinerU/usage/).
# TODO
- [x] Reading order based on the model
- [x] Recognition of `index` and `list` in the main text
- [x] Table recognition
- [x] Heading Classification
- [x] Handwritten Text Recognition
- [x] Vertical Text Recognition
- [x] Latin Accent Mark Recognition
- [x] Code block recognition in the main text
- [x] [Chemical formula recognition](docs/chemical_knowledge_introduction/introduction.pdf)(mineru.net)
- [ ] Geometric shape recognition
# Known Issues
- Reading order is determined by the model based on the spatial distribution of readable content, and may be out of order in some areas under extremely complex layouts.
- Limited support for vertical text.
- Tables of contents and lists are recognized through rules, and some uncommon list formats may not be recognized.
- Code blocks are not yet supported in the layout model.
- Comic books, art albums, primary school textbooks, and exercises cannot be parsed well.
- Table recognition may result in row/column recognition errors in complex tables.
- OCR recognition may produce inaccurate characters in PDFs of lesser-known languages (e.g., diacritical marks in Latin script, easily confused characters in Arabic script).
- Some formulas may not render correctly in Markdown.
# FAQ
- If you encounter any issues during usage, you can first check the [FAQ](https://opendatalab.github.io/MinerU/faq/) for solutions.
- If your issue remains unresolved, you may also use [DeepWiki](https://deepwiki.com/opendatalab/MinerU) to interact with an AI assistant, which can address most common problems.
- If you still cannot resolve the issue, you are welcome to join our community via [Discord](https://discord.gg/Tdedn9GTXq) or [WeChat](https://mineru.net/community-portal/?aliasId=3c430f94) to discuss with other users and developers.
# All Thanks To Our Contributors
<a href="https://github.com/opendatalab/MinerU/graphs/contributors">
<img src="https://contrib.rocks/image?repo=opendatalab/MinerU" />
</a>
# License Information
[LICENSE.md](LICENSE.md)
Currently, some models in this project are trained based on YOLO. However, since YOLO follows the AGPL license, it may impose restrictions on certain use cases. In future iterations, we plan to explore and replace these with models under more permissive licenses to enhance user-friendliness and flexibility.
# Acknowledgments
- [PDF-Extract-Kit](https://github.com/opendatalab/PDF-Extract-Kit)
- [DocLayout-YOLO](https://github.com/opendatalab/DocLayout-YOLO)
- [UniMERNet](https://github.com/opendatalab/UniMERNet)
- [RapidTable](https://github.com/RapidAI/RapidTable)
- [TableStructureRec](https://github.com/RapidAI/TableStructureRec)
- [PaddleOCR](https://github.com/PaddlePaddle/PaddleOCR)
- [PaddleOCR2Pytorch](https://github.com/frotms/PaddleOCR2Pytorch)
- [layoutreader](https://github.com/ppaanngggg/layoutreader)
- [xy-cut](https://github.com/Sanster/xy-cut)
- [fast-langdetect](https://github.com/LlmKira/fast-langdetect)
- [pypdfium2](https://github.com/pypdfium2-team/pypdfium2)
- [pdftext](https://github.com/datalab-to/pdftext)
- [pdfminer.six](https://github.com/pdfminer/pdfminer.six)
- [pypdf](https://github.com/py-pdf/pypdf)
- [magika](https://github.com/google/magika)
# Citation
```bibtex
@misc{niu2025mineru25decoupledvisionlanguagemodel,
title={MinerU2.5: A Decoupled Vision-Language Model for Efficient High-Resolution Document Parsing},
author={Junbo Niu and Zheng Liu and Zhuangcheng Gu and Bin Wang and Linke Ouyang and Zhiyuan Zhao and Tao Chu and Tianyao He and Fan Wu and Qintong Zhang and Zhenjiang Jin and Guang Liang and Rui Zhang and Wenzheng Zhang and Yuan Qu and Zhifei Ren and Yuefeng Sun and Yuanhong Zheng and Dongsheng Ma and Zirui Tang and Boyu Niu and Ziyang Miao and Hejun Dong and Siyi Qian and Junyuan Zhang and Jingzhou Chen and Fangdong Wang and Xiaomeng Zhao and Liqun Wei and Wei Li and Shasha Wang and Ruiliang Xu and Yuanyuan Cao and Lu Chen and Qianqian Wu and Huaiyu Gu and Lindong Lu and Keming Wang and Dechen Lin and Guanlin Shen and Xuanhe Zhou and Linfeng Zhang and Yuhang Zang and Xiaoyi Dong and Jiaqi Wang and Bo Zhang and Lei Bai and Pei Chu and Weijia Li and Jiang Wu and Lijun Wu and Zhenxiang Li and Guangyu Wang and Zhongying Tu and Chao Xu and Kai Chen and Yu Qiao and Bowen Zhou and Dahua Lin and Wentao Zhang and Conghui He},
year={2025},
eprint={2509.22186},
archivePrefix={arXiv},
primaryClass={cs.CV},
url={https://arxiv.org/abs/2509.22186},
}
@misc{wang2024mineruopensourcesolutionprecise,
title={MinerU: An Open-Source Solution for Precise Document Content Extraction},
author={Bin Wang and Chao Xu and Xiaomeng Zhao and Linke Ouyang and Fan Wu and Zhiyuan Zhao and Rui Xu and Kaiwen Liu and Yuan Qu and Fukai Shang and Bo Zhang and Liqun Wei and Zhihao Sui and Wei Li and Botian Shi and Yu Qiao and Dahua Lin and Conghui He},
year={2024},
eprint={2409.18839},
archivePrefix={arXiv},
primaryClass={cs.CV},
url={https://arxiv.org/abs/2409.18839},
}
@article{he2024opendatalab,
title={Opendatalab: Empowering general artificial intelligence with open datasets},
author={He, Conghui and Li, Wei and Jin, Zhenjiang and Xu, Chao and Wang, Bin and Lin, Dahua},
journal={arXiv preprint arXiv:2407.13773},
year={2024}
}
```
# Star History
<a>
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=opendatalab/MinerU&type=Date&theme=dark" />
<source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/svg?repos=opendatalab/MinerU&type=Date" />
<img alt="Star History Chart" src="https://api.star-history.com/svg?repos=opendatalab/MinerU&type=Date" />
</picture>
</a>
# Links
- [Easy Data Preparation with latest LLMs-based Operators and Pipelines](https://github.com/OpenDCAI/DataFlow)
- [Vis3 (OSS browser based on s3)](https://github.com/opendatalab/Vis3)
- [LabelU (A Lightweight Multi-modal Data Annotation Tool)](https://github.com/opendatalab/labelU)
- [LabelLLM (An Open-source LLM Dialogue Annotation Platform)](https://github.com/opendatalab/LabelLLM)
- [PDF-Extract-Kit (A Comprehensive Toolkit for High-Quality PDF Content Extraction)](https://github.com/opendatalab/PDF-Extract-Kit)
- [OmniDocBench (A Comprehensive Benchmark for Document Parsing and Evaluation)](https://github.com/opendatalab/OmniDocBench)
- [Magic-HTML (Mixed web page extraction tool)](https://github.com/opendatalab/magic-html)
- [Magic-Doc (Fast speed ppt/pptx/doc/docx/pdf extraction tool)](https://github.com/InternLM/magic-doc)
- [Dingo: A Comprehensive AI Data Quality Evaluation Tool](https://github.com/MigoXLab/dingo)
LICENSE.md
README.md
pyproject.toml
mineru/__init__.py
mineru/version.py
mineru.egg-info/PKG-INFO
mineru.egg-info/SOURCES.txt
mineru.egg-info/dependency_links.txt
mineru.egg-info/entry_points.txt
mineru.egg-info/not-zip-safe
mineru.egg-info/requires.txt
mineru.egg-info/top_level.txt
mineru/backend/__init__.py
mineru/backend/utils.py
mineru/backend/customs/__init__.py
mineru/backend/customs/exporter.py
mineru/backend/pipeline/__init__.py
mineru/backend/pipeline/batch_analyze.py
mineru/backend/pipeline/model_init.py
mineru/backend/pipeline/model_json_to_middle_json.py
mineru/backend/pipeline/model_list.py
mineru/backend/pipeline/para_split.py
mineru/backend/pipeline/pipeline_analyze.py
mineru/backend/pipeline/pipeline_magic_model.py
mineru/backend/pipeline/pipeline_middle_json_mkcontent.py
mineru/backend/vlm/__init__.py
mineru/backend/vlm/model_output_to_middle_json.py
mineru/backend/vlm/utils.py
mineru/backend/vlm/vlm_analyze.py
mineru/backend/vlm/vlm_magic_model.py
mineru/backend/vlm/vlm_middle_json_mkcontent.py
mineru/cli/__init__.py
mineru/cli/client.py
mineru/cli/common.py
mineru/cli/fast_api.py
mineru/cli/gradio_app.py
mineru/cli/models_download.py
mineru/cli/vlm_vllm_server.py
mineru/data/__init__.py
mineru/data/data_reader_writer/__init__.py
mineru/data/data_reader_writer/base.py
mineru/data/data_reader_writer/dummy.py
mineru/data/data_reader_writer/filebase.py
mineru/data/data_reader_writer/multi_bucket_s3.py
mineru/data/data_reader_writer/s3.py
mineru/data/io/__init__.py
mineru/data/io/base.py
mineru/data/io/http.py
mineru/data/io/s3.py
mineru/data/utils/__init__.py
mineru/data/utils/exceptions.py
mineru/data/utils/path_utils.py
mineru/data/utils/schemas.py
mineru/model/__init__.py
mineru/model/layout/__init__.py
mineru/model/layout/doclayoutyolo.py
mineru/model/mfd/__init__.py
mineru/model/mfd/yolo_v8.py
mineru/model/mfr/__init__.py
mineru/model/mfr/utils.py
mineru/model/mfr/pp_formulanet_plus_m/__init__.py
mineru/model/mfr/pp_formulanet_plus_m/predict_formula.py
mineru/model/mfr/pp_formulanet_plus_m/processors.py
mineru/model/mfr/unimernet/Unimernet.py
mineru/model/mfr/unimernet/__init__.py
mineru/model/mfr/unimernet/unimernet_hf/__init__.py
mineru/model/mfr/unimernet/unimernet_hf/modeling_unimernet.py
mineru/model/mfr/unimernet/unimernet_hf/unimer_mbart/__init__.py
mineru/model/mfr/unimernet/unimernet_hf/unimer_mbart/configuration_unimer_mbart.py
mineru/model/mfr/unimernet/unimernet_hf/unimer_mbart/modeling_unimer_mbart.py
mineru/model/mfr/unimernet/unimernet_hf/unimer_mbart/tokenization_unimer_mbart.py
mineru/model/mfr/unimernet/unimernet_hf/unimer_swin/__init__.py
mineru/model/mfr/unimernet/unimernet_hf/unimer_swin/configuration_unimer_swin.py
mineru/model/mfr/unimernet/unimernet_hf/unimer_swin/image_processing_unimer_swin.py
mineru/model/mfr/unimernet/unimernet_hf/unimer_swin/modeling_unimer_swin.py
mineru/model/ocr/__init__.py
mineru/model/ocr/paddleocr2pytorch/__init__.py
mineru/model/ocr/paddleocr2pytorch/pytorch_paddle.py
mineru/model/ori_cls/__init__.py
mineru/model/ori_cls/paddle_ori_cls.py
mineru/model/reading_order/__init__.py
mineru/model/reading_order/layout_reader.py
mineru/model/reading_order/xycut.py
mineru/model/table/__init__.py
mineru/model/table/cls/__init__.py
mineru/model/table/cls/paddle_table_cls.py
mineru/model/table/rec/RapidTable.py
mineru/model/table/rec/__init__.py
mineru/model/table/rec/slanet_plus/__init__.py
mineru/model/table/rec/slanet_plus/main.py
mineru/model/table/rec/slanet_plus/matcher.py
mineru/model/table/rec/slanet_plus/matcher_utils.py
mineru/model/table/rec/slanet_plus/table_structure.py
mineru/model/table/rec/slanet_plus/table_structure_utils.py
mineru/model/table/rec/unet_table/__init__.py
mineru/model/table/rec/unet_table/main.py
mineru/model/table/rec/unet_table/table_recover.py
mineru/model/table/rec/unet_table/table_structure_unet.py
mineru/model/table/rec/unet_table/utils.py
mineru/model/table/rec/unet_table/utils_table_line_rec.py
mineru/model/table/rec/unet_table/utils_table_recover.py
mineru/model/utils/__init__.py
mineru/model/utils/pytorchocr/__init__.py
mineru/model/utils/pytorchocr/base_ocr_v20.py
mineru/model/utils/pytorchocr/data/__init__.py
mineru/model/utils/pytorchocr/data/imaug/__init__.py
mineru/model/utils/pytorchocr/data/imaug/operators.py
mineru/model/utils/pytorchocr/modeling/__init__.py
mineru/model/utils/pytorchocr/modeling/common.py
mineru/model/utils/pytorchocr/modeling/architectures/__init__.py
mineru/model/utils/pytorchocr/modeling/architectures/base_model.py
mineru/model/utils/pytorchocr/modeling/backbones/__init__.py
mineru/model/utils/pytorchocr/modeling/backbones/det_mobilenet_v3.py
mineru/model/utils/pytorchocr/modeling/backbones/rec_donut_swin.py
mineru/model/utils/pytorchocr/modeling/backbones/rec_hgnet.py
mineru/model/utils/pytorchocr/modeling/backbones/rec_lcnetv3.py
mineru/model/utils/pytorchocr/modeling/backbones/rec_mobilenet_v3.py
mineru/model/utils/pytorchocr/modeling/backbones/rec_mv1_enhance.py
mineru/model/utils/pytorchocr/modeling/backbones/rec_pphgnetv2.py
mineru/model/utils/pytorchocr/modeling/backbones/rec_svtrnet.py
mineru/model/utils/pytorchocr/modeling/heads/__init__.py
mineru/model/utils/pytorchocr/modeling/heads/cls_head.py
mineru/model/utils/pytorchocr/modeling/heads/det_db_head.py
mineru/model/utils/pytorchocr/modeling/heads/rec_ctc_head.py
mineru/model/utils/pytorchocr/modeling/heads/rec_multi_head.py
mineru/model/utils/pytorchocr/modeling/heads/rec_ppformulanet_head.py
mineru/model/utils/pytorchocr/modeling/heads/rec_unimernet_head.py
mineru/model/utils/pytorchocr/modeling/necks/__init__.py
mineru/model/utils/pytorchocr/modeling/necks/db_fpn.py
mineru/model/utils/pytorchocr/modeling/necks/intracl.py
mineru/model/utils/pytorchocr/modeling/necks/rnn.py
mineru/model/utils/pytorchocr/postprocess/__init__.py
mineru/model/utils/pytorchocr/postprocess/cls_postprocess.py
mineru/model/utils/pytorchocr/postprocess/db_postprocess.py
mineru/model/utils/pytorchocr/postprocess/rec_postprocess.py
mineru/model/utils/pytorchocr/utils/__init__.py
mineru/model/utils/pytorchocr/utils/resources/arch_config.yaml
mineru/model/utils/pytorchocr/utils/resources/models_config.yml
mineru/model/utils/pytorchocr/utils/resources/pp_formulanet_arch_config.yaml
mineru/model/utils/pytorchocr/utils/resources/dict/ka_dict.txt
mineru/model/utils/pytorchocr/utils/resources/dict/ppocrv4_doc_dict.txt
mineru/model/utils/pytorchocr/utils/resources/dict/ppocrv5_arabic_dict.txt
mineru/model/utils/pytorchocr/utils/resources/dict/ppocrv5_cyrillic_dict.txt
mineru/model/utils/pytorchocr/utils/resources/dict/ppocrv5_devanagari_dict.txt
mineru/model/utils/pytorchocr/utils/resources/dict/ppocrv5_dict.txt
mineru/model/utils/pytorchocr/utils/resources/dict/ppocrv5_el_dict.txt
mineru/model/utils/pytorchocr/utils/resources/dict/ppocrv5_en_dict.txt
mineru/model/utils/pytorchocr/utils/resources/dict/ppocrv5_eslav_dict.txt
mineru/model/utils/pytorchocr/utils/resources/dict/ppocrv5_korean_dict.txt
mineru/model/utils/pytorchocr/utils/resources/dict/ppocrv5_latin_dict.txt
mineru/model/utils/pytorchocr/utils/resources/dict/ppocrv5_ta_dict.txt
mineru/model/utils/pytorchocr/utils/resources/dict/ppocrv5_te_dict.txt
mineru/model/utils/pytorchocr/utils/resources/dict/ppocrv5_th_dict.txt
mineru/model/utils/tools/__init__.py
mineru/model/utils/tools/infer/__init__.py
mineru/model/utils/tools/infer/predict_cls.py
mineru/model/utils/tools/infer/predict_det.py
mineru/model/utils/tools/infer/predict_rec.py
mineru/model/utils/tools/infer/predict_system.py
mineru/model/utils/tools/infer/pytorchocr_utility.py
mineru/model/vlm_vllm_model/__init__.py
mineru/model/vlm_vllm_model/server.py
mineru/resources/header.html
mineru/resources/fasttext-langdetect/lid.176.ftz
mineru/utils/__init__.py
mineru/utils/block_pre_proc.py
mineru/utils/block_sort.py
mineru/utils/boxbase.py
mineru/utils/cli_parser.py
mineru/utils/config_reader.py
mineru/utils/cut_image.py
mineru/utils/draw_bbox.py
mineru/utils/enum_class.py
mineru/utils/format_utils.py
mineru/utils/guess_suffix_or_lang.py
mineru/utils/hash_utils.py
mineru/utils/language.py
mineru/utils/llm_aided.py
mineru/utils/magic_model_utils.py
mineru/utils/model_utils.py
mineru/utils/models_download_utils.py
mineru/utils/ocr_utils.py
mineru/utils/pdf_classify.py
mineru/utils/pdf_image_tools.py
mineru/utils/pdf_reader.py
mineru/utils/pdf_text_tool.py
mineru/utils/run_async.py
mineru/utils/span_block_fix.py
mineru/utils/span_pre_proc.py
mineru/utils/table_merge.py
\ No newline at end of file
[console_scripts]
mineru = mineru.cli:client.main
mineru-api = mineru.cli.fast_api:main
mineru-gradio = mineru.cli.gradio_app:main
mineru-models-download = mineru.cli.models_download:download_models
mineru-vllm-server = mineru.cli.vlm_vllm_server:main
boto3>=1.28.43
click>=8.1.7
loguru>=0.7.2
numpy>=1.21.6
pdfminer.six==20250506
tqdm>=4.67.1
requests
httpx
pillow>=11.0.0
pypdfium2>=4.30.0
pypdf>=5.6.0
reportlab
pdftext>=0.6.2
modelscope>=1.26.0
huggingface-hub>=0.32.4
json-repair>=0.46.2
opencv-python>=4.11.0.86
fast-langdetect<0.3.0,>=0.2.3
scikit-image<1.0.0,>=0.25.0
openai<3,>=1.70.0
beautifulsoup4<5,>=4.13.5
magika<0.7.0,>=0.6.2
mineru-vl-utils<1,>=0.1.14
[all]
mineru[core]
mineru[vllm]
[api]
fastapi
python-multipart
uvicorn
[core]
mineru[vlm]
mineru[pipeline]
mineru[api]
mineru[gradio]
[gradio]
gradio<6,>=5.34
gradio-pdf>=0.0.22
[pipeline]
matplotlib<4,>=3.10
ultralytics<9,>=8.3.48
doclayout_yolo==0.0.4
dill<1,>=0.3.8
PyYAML<7,>=6.0.2
ftfy<7,>=6.3.1
shapely<3,>=2.0.7
pyclipper<2,>=1.3.0
omegaconf<3,>=2.3.0
torch<3,>=2.6.0
torchvision
transformers!=4.51.0,<5.0.0,>=4.49.0
onnxruntime>1.17.0
[test]
mineru[core]
pytest
pytest-cov
coverage
fuzzywuzzy
[vllm]
vllm<0.12,>=0.10.1.1
[vlm]
torch<3,>=2.6.0
transformers<5.0.0,>=4.51.1
accelerate>=1.5.1
......@@ -13,6 +13,7 @@ from ...utils.model_utils import crop_img, get_res_list_from_layout_res, clean_v
from ...utils.ocr_utils import merge_det_boxes, update_det_boxes, sorted_boxes
from ...utils.ocr_utils import get_adjusted_mfdetrec_res, get_ocr_result_list, OcrConfidence, get_rotate_crop_image
from ...utils.pdf_image_tools import get_crop_np_img
from ...utils.table_cell_bbox import compute_table_cells
YOLO_LAYOUT_BASE_BATCH_SIZE = 1
MFD_BASE_BATCH_SIZE = 1
......@@ -106,6 +107,7 @@ class BatchAnalyze:
'lang':_lang,
'table_img':wireless_table_img,
'wired_table_img':wired_table_img,
'page_index': index, # 记录页码索引,用于后续关联
})
# 表格识别 table recognition
......@@ -234,6 +236,81 @@ class BatchAnalyze:
start_index = html_code.find("<table>")
end_index = html_code.rfind("</table>") + len("</table>")
table_res_dict["table_res"]["html"] = html_code[start_index:end_index]
# 计算表格单元格的bbox和score
try:
html_final = table_res_dict["table_res"].get("html", "")
if html_final:
# 获取表格bbox(从poly转换为[x1, y1, x2, y2])
table_res = table_res_dict.get("table_res", {})
poly = table_res.get("poly", [])
x_coords = None
y_coords = None
# 安全地检查poly长度和处理numpy数组
try:
poly_len = len(poly) if hasattr(poly, '__len__') else 0
if poly_len >= 8:
# 转换为列表并提取坐标,确保处理numpy数组
poly_list = list(poly) if not isinstance(poly, list) else poly
x_coords = [float(poly_list[0]), float(poly_list[2]), float(poly_list[4]), float(poly_list[6])]
y_coords = [float(poly_list[1]), float(poly_list[3]), float(poly_list[5]), float(poly_list[7])]
table_bbox = [min(x_coords), min(y_coords), max(x_coords), max(y_coords)]
else:
# 如果没有poly,尝试从bbox字段获取
bbox_list = table_res.get("bbox", [])
if hasattr(bbox_list, '__len__') and len(bbox_list) >= 4:
table_bbox = [float(bbox_list[0]), float(bbox_list[1]), float(bbox_list[2]), float(bbox_list[3])]
else:
table_bbox = [0, 0, 0, 0]
except (ValueError, TypeError, IndexError) as e:
logger.warning(f"Error processing table bbox from poly: {e}")
# 回退到bbox字段
bbox_list = table_res.get("bbox", [])
if hasattr(bbox_list, '__len__') and len(bbox_list) >= 4:
table_bbox = [float(bbox_list[0]), float(bbox_list[1]), float(bbox_list[2]), float(bbox_list[3])]
else:
table_bbox = [0, 0, 0, 0]
# 获取score
# 如果score未定义或为0,使用合理的默认值
raw_score = table_res.get("score", 0.8)
span_score = float(raw_score)
# 如果score为0或未定义,使用默认值
if span_score <= 0:
logger.warning(f"Invalid table score: {span_score}, using default 0.8")
span_score = 0.8
# 获取OCR结果
ocr_result = table_res_dict.get("ocr_result", None)
# 计算裁剪偏移量(OCR结果坐标是相对于裁剪后的表格图像的)
crop_info = None
if x_coords is not None and y_coords is not None:
try:
crop_info = {
'crop_xmin': min(x_coords),
'crop_ymin': min(y_coords),
}
except Exception as e:
logger.warning(f"Error creating crop_info: {e}")
crop_info = None
# 计算cells
cells = compute_table_cells(
html_final,
table_bbox,
span_score,
ocr_result,
crop_info=crop_info
)
# 将cells添加到table_res中(table_res是layout_res中table项的引用,会自动同步)
table_res_dict["table_res"]["cells"] = cells
except Exception as e:
logger.warning(f"Failed to compute table cells: {e}")
table_res_dict["table_res"]["cells"] = []
# OCR det
if self.enable_ocr_det_batch:
......
......@@ -338,6 +338,10 @@ class MagicModel:
span['latex'] = latex
elif html:
span['html'] = html
# 获取单元格级信息(bbox和score)
cells = layout_det.get('cells', None)
if cells:
span['cells'] = cells
span['type'] = ContentType.TABLE
elif category_id == CategoryId.InlineEquation:
span['content'] = layout_det['latex']
......
# Copyright (c) Opendatalab. All rights reserved.
"""
计算表格HTML中每个td单元格的bbox和score
"""
import re
from typing import List, Dict, Optional, Tuple
try:
from bs4 import BeautifulSoup
except ImportError:
BeautifulSoup = None
from loguru import logger
import numpy as np
def parse_html_to_grid(html: str) -> List[Dict]:
"""解析HTML表格,返回行列结构"""
if BeautifulSoup is None:
logger.warning("BeautifulSoup not available, using simple regex parsing")
return _parse_html_simple(html)
try:
soup = BeautifulSoup(html, 'html.parser')
rows = []
row_idx = -1
for tr in soup.find_all('tr'):
row_idx += 1
cols = []
col_idx = 0
for cell in tr.find_all(['td', 'th']):
text = cell.get_text(strip=True)
rowspan = int(cell.get('rowspan', 1))
colspan = int(cell.get('colspan', 1))
cols.append({
'col_index': col_idx,
'rowspan': rowspan,
'colspan': colspan,
'text': text
})
col_idx += 1
if cols:
rows.append({
'row_index': row_idx,
'cols': cols
})
return rows
except Exception as e:
logger.warning(f"Failed to parse HTML with BeautifulSoup: {e}, using simple parser")
return _parse_html_simple(html)
def _parse_html_simple(html: str) -> List[Dict]:
"""简单的正则解析作为备选"""
rows = []
row_idx = -1
# 提取所有tr块
tr_pattern = r'<tr>(.*?)</tr>'
tr_matches = re.findall(tr_pattern, html, re.DOTALL)
for tr_content in tr_matches:
row_idx += 1
cols = []
col_idx = 0
# 提取td/th
td_pattern = r'<t[dh](?:\s+[^>]*)?>(.*?)</t[dh]>'
td_matches = re.findall(td_pattern, tr_content, re.DOTALL)
# 提取rowspan和colspan
td_full_pattern = r'<t[dh]([^>]*)>(.*?)</t[dh]>'
td_full_matches = re.findall(td_full_pattern, tr_content, re.DOTALL)
for attr_str, content in td_full_matches:
rowspan = 1
colspan = 1
rowspan_match = re.search(r'rowspan\s*=\s*(\d+)', attr_str)
if rowspan_match:
rowspan = int(rowspan_match.group(1))
colspan_match = re.search(r'colspan\s*=\s*(\d+)', attr_str)
if colspan_match:
colspan = int(colspan_match.group(1))
text = re.sub(r'<[^>]+>', '', content).strip()
cols.append({
'col_index': col_idx,
'rowspan': rowspan,
'colspan': colspan,
'text': text
})
col_idx += 1
if cols:
rows.append({
'row_index': row_idx,
'cols': cols
})
return rows
def infer_max_row_col(rows: List[Dict]) -> Tuple[int, int]:
"""推断表格的最大行列数"""
max_row = len(rows)
max_col = 0
for row in rows:
last_col = row['cols'][-1] if row['cols'] else None
if last_col:
max_col = max(max_col, last_col['col_index'] + last_col['colspan'])
return max_row, max_col
def uniform_bounds(start: float, end: float, count: int) -> List[float]:
"""均匀分割区间"""
if count <= 0:
return [start, end]
step = (end - start) / count
bounds = [start + i * step for i in range(count + 1)]
return bounds
def map_ocr_boxes_to_page(ocr_result: List, table_bbox: List, crop_info: Dict = None) -> List[Dict]:
"""将OCR检测框从表格子图坐标映射到页面坐标"""
if not ocr_result:
return []
# 提取表格裁剪信息
# 如果crop_info为None,说明OCR坐标已经是页面坐标(无需转换)
if crop_info is None:
crop_xmin = 0
crop_ymin = 0
else:
crop_xmin = crop_info.get('crop_xmin', 0)
crop_ymin = crop_info.get('crop_ymin', 0)
page_boxes = []
for item in ocr_result:
if len(item) < 3:
continue
dt_box = item[0]
text = item[1] if len(item) > 1 else ""
score = item[2] if len(item) > 2 else 0.0
# dt_box可能是多边形或bbox
if isinstance(dt_box, (list, np.ndarray)):
box_array = np.array(dt_box)
# 检查数组形状和大小
if box_array.ndim == 1 and len(box_array) == 4: # [x1, y1, x2, y2]
x1, y1, x2, y2 = float(box_array[0]), float(box_array[1]), float(box_array[2]), float(box_array[3])
elif box_array.ndim == 2 and box_array.shape[0] == 4 and box_array.shape[1] == 2: # [[x1,y1], [x2,y1], [x2,y2], [x1,y2]]
x1, y1 = float(box_array[0][0]), float(box_array[0][1])
x2, y2 = float(box_array[2][0]), float(box_array[2][1])
else:
continue
# 映射到页面坐标
page_x1 = crop_xmin + x1
page_y1 = crop_ymin + y1
page_x2 = crop_xmin + x2
page_y2 = crop_ymin + y2
page_boxes.append({
'bbox': [page_x1, page_y1, page_x2, page_y2],
'text': text,
'score': float(score) if isinstance(score, (int, float)) else 0.0,
'center_x': (page_x1 + page_x2) / 2,
'center_y': (page_y1 + page_y2) / 2
})
return page_boxes
def infer_row_boundaries_from_ocr(page_boxes: List[Dict], max_row: int) -> List[float]:
"""从OCR框推断行边界"""
if not page_boxes or max_row <= 0:
return []
# 收集所有y坐标
y_centers = [box['center_y'] for box in page_boxes]
if not y_centers:
return []
y_centers = sorted(y_centers)
# 简单的K-means聚类来分组(或使用更简单的分位数方法)
if max_row <= 1:
return [min(y_centers), max(y_centers)]
# 使用分位数方法:将y坐标分成max_row组
y_sorted = sorted(y_centers)
step = len(y_sorted) / max_row
boundaries = []
for i in range(max_row + 1):
idx = int(i * step)
if idx >= len(y_sorted):
idx = len(y_sorted) - 1
if i == 0:
boundaries.append(y_sorted[idx] - 5) # 向上扩展一点
elif i == max_row:
boundaries.append(y_sorted[idx] + 5) # 向下扩展一点
else:
boundaries.append(y_sorted[idx])
return sorted(boundaries)
def infer_col_boundaries_from_ocr(page_boxes: List[Dict], max_col: int) -> List[float]:
"""从OCR框推断列边界"""
if not page_boxes or max_col <= 0:
return []
x_centers = [box['center_x'] for box in page_boxes]
if not x_centers:
return []
x_sorted = sorted(x_centers)
if max_col <= 1:
return [min(x_sorted), max(x_sorted)]
step = len(x_sorted) / max_col
boundaries = []
for i in range(max_col + 1):
idx = int(i * step)
if idx >= len(x_sorted):
idx = len(x_sorted) - 1
if i == 0:
boundaries.append(x_sorted[idx] - 5)
elif i == max_col:
boundaries.append(x_sorted[idx] + 5)
else:
boundaries.append(x_sorted[idx])
return sorted(boundaries)
def calculate_iou(bbox1: List[float], bbox2: List[float]) -> float:
"""计算两个bbox的交并比(IoU)"""
x1_1, y1_1, x2_1, y2_1 = bbox1[:4]
x1_2, y1_2, x2_2, y2_2 = bbox2[:4]
# 计算交集
inter_x1 = max(x1_1, x1_2)
inter_y1 = max(y1_1, y1_2)
inter_x2 = min(x2_1, x2_2)
inter_y2 = min(y2_1, y2_2)
if inter_x2 <= inter_x1 or inter_y2 <= inter_y1:
return 0.0
inter_area = (inter_x2 - inter_x1) * (inter_y2 - inter_y1)
# 计算并集
area1 = (x2_1 - x1_1) * (y2_1 - y1_1)
area2 = (x2_2 - x1_2) * (y2_2 - y1_2)
union_area = area1 + area2 - inter_area
if union_area <= 0:
return 0.0
return inter_area / union_area
def aggregate_ocr_scores_in_bbox(page_boxes: List[Dict], bbox: List[float], default_score: float = 0.0) -> float:
"""聚合bbox区域内的OCR框的score,使用IoU加权平均"""
if not page_boxes:
# 如果没有OCR框,使用提供的default_score(应该是span_score)
return default_score
# 如果default_score为0或太小,使用更合理的默认值
if default_score <= 0:
default_score = 0.8
x1, y1, x2, y2 = bbox[:4]
weighted_scores = []
total_weight = 0.0
for box in page_boxes:
box_x1, box_y1, box_x2, box_y2 = box['bbox'][:4]
# 计算IoU作为权重
iou = calculate_iou(bbox, [box_x1, box_y1, box_x2, box_y2])
# 只考虑有重叠的框(IoU > 0)
if iou > 0:
weight = iou
box_score = box['score'] if 'score' in box and box['score'] > 0 else default_score
weighted_scores.append(box_score * weight)
total_weight += weight
if total_weight > 0 and weighted_scores:
# 返回加权平均分
weighted_avg = sum(weighted_scores) / total_weight
return float(weighted_avg)
return default_score
def compute_table_cells(
html: str,
table_bbox: List[float],
span_score: float = 0.0,
ocr_result: Optional[List] = None,
crop_info: Optional[Dict] = None
) -> List[Dict]:
"""
计算表格HTML中每个td单元格的bbox和score
Args:
html: 表格HTML字符串
table_bbox: 表格在页面中的bbox [x1, y1, x2, y2]
span_score: 表格整体的score
ocr_result: OCR结果列表(可选),格式为 [[dt_box, text, score], ...]
crop_info: 裁剪信息(可选),包含crop_xmin, crop_ymin等
Returns:
单元格列表,每个包含:row_index, col_index, rowspan, colspan, text, bbox, score
"""
if not html:
return []
# 安全地检查table_bbox长度
try:
bbox_len = len(table_bbox) if hasattr(table_bbox, '__len__') else 0
if bbox_len < 4:
return []
except (TypeError, ValueError):
return []
# 解析HTML
rows = parse_html_to_grid(html)
if not rows:
return []
max_row, max_col = infer_max_row_col(rows)
if max_row == 0 or max_col == 0:
return []
# 安全地提取坐标,处理numpy数组
try:
bbox_list = list(table_bbox[:4]) if not isinstance(table_bbox, list) else table_bbox[:4]
x1, y1, x2, y2 = float(bbox_list[0]), float(bbox_list[1]), float(bbox_list[2]), float(bbox_list[3])
except (ValueError, TypeError, IndexError) as e:
logger.warning(f"Error extracting table bbox coordinates: {e}")
return []
# 计算行边界和列边界
if ocr_result:
# 方法B: OCR引导的分割
page_boxes = map_ocr_boxes_to_page(ocr_result, table_bbox, crop_info)
if page_boxes:
row_bounds = infer_row_boundaries_from_ocr(page_boxes, max_row)
col_bounds = infer_col_boundaries_from_ocr(page_boxes, max_col)
else:
# 回退到均匀分割
row_bounds = uniform_bounds(y1, y2, max_row)
col_bounds = uniform_bounds(x1, x2, max_col)
else:
# 方法A: 均匀分割
row_bounds = uniform_bounds(y1, y2, max_row)
col_bounds = uniform_bounds(x1, x2, max_col)
# 如果边界数量不足,补充
while len(row_bounds) < max_row + 1:
if len(row_bounds) == 0:
row_bounds = [y1, y2]
else:
step = (y2 - y1) / max_row
row_bounds = [y1 + i * step for i in range(max_row + 1)]
break
while len(col_bounds) < max_col + 1:
if len(col_bounds) == 0:
col_bounds = [x1, x2]
else:
step = (x2 - x1) / max_col
col_bounds = [x1 + i * step for i in range(max_col + 1)]
break
# 生成单元格bbox和score
cells = []
page_boxes_cache = map_ocr_boxes_to_page(ocr_result, table_bbox, crop_info) if ocr_result else []
for row in rows:
for col in row['cols']:
row_idx = row['row_index']
col_idx = col['col_index']
# 计算bbox(保留为整数)
try:
row_start = row_idx
row_end = min(row_idx + col['rowspan'], len(row_bounds) - 1)
col_start = col_idx
col_end = min(col_idx + col['colspan'], len(col_bounds) - 1)
cell_y1 = row_bounds[row_start] if row_start < len(row_bounds) else y1
cell_y2 = row_bounds[row_end] if row_end < len(row_bounds) else y2
cell_x1 = col_bounds[col_start] if col_start < len(col_bounds) else x1
cell_x2 = col_bounds[col_end] if col_end < len(col_bounds) else x2
# bbox坐标四舍五入为整数
cell_bbox = [
int(round(cell_x1)),
int(round(cell_y1)),
int(round(cell_x2)),
int(round(cell_y2))
]
except (IndexError, ValueError) as e:
logger.warning(f"Error calculating cell bbox: {e}, using table bbox")
cell_bbox = [
int(round(x1)),
int(round(y1)),
int(round(x2)),
int(round(y2))
]
# ============================================
# 单元格score计算逻辑
# ============================================
# 基于spans['score']的计算公式调整cell['score']
#
# 公式说明:
# cell_score = base_score * content_factor * structure_factor * quality_factor
#
# 其中:
# base_score: 基于spans['score']的基础置信度(通过IoU加权OCR或直接继承)
# content_factor: 内容因子(根据文本内容调整)
# structure_factor: 结构因子(根据单元格结构合理性调整)
# quality_factor: 质量因子(根据单元格bbox质量调整)
# ============================================
# 先使用临时浮点bbox计算score(用于IoU计算)
temp_bbox = [float(cell_bbox[0]), float(cell_bbox[1]), float(cell_bbox[2]), float(cell_bbox[3])]
# 获取单元格文本
cell_text = col['text'].strip()
# -----------------------------------------------------
# 步骤1: 计算base_score(基础置信度)
# -----------------------------------------------------
# 基于spans['score']的逻辑:spans['score'] = layout_det['score']
# 对于cells,我们使用表格整体的span_score作为基准
# 然后通过OCR结果(如果有)进行细粒度调整
# -----------------------------------------------------
# 处理span_score为0或未定义的情况,使用合理的默认值
if span_score <= 0:
logger.warning(f"Invalid span_score: {span_score}, using default 0.8")
span_score = 0.8 # 使用合理的默认值
if page_boxes_cache:
# 如果有OCR结果,使用IoU加权平均(与方法中spans的处理逻辑一致)
base_score = aggregate_ocr_scores_in_bbox(page_boxes_cache, temp_bbox, span_score)
else:
# 如果没有OCR结果,直接使用span_score(类似于spans的处理)
base_score = span_score
# -----------------------------------------------------
# 步骤2: 计算content_factor(内容因子)
# -----------------------------------------------------
# 根据单元格是否有文本内容调整置信度
# 有文本 -> 置信度更高,空单元格 -> 置信度较低
# -----------------------------------------------------
if cell_text:
# 有文本:保持或稍微提升置信度
# 文本越短,可能是标题或标签,置信度稍低
# 文本较长,可能是内容单元格,置信度稍高
text_length = len(cell_text)
if text_length < 3:
content_factor = 0.9 # 超短文本(可能是编号、符号等)
elif text_length < 10:
content_factor = 1.0 # 短文本(标题、标签等)
else:
content_factor = 1.05 # 长文本(内容单元格)
# 限制content_factor在合理范围
content_factor = min(1.1, content_factor)
else:
# 空单元格:显著降低置信度(但不为0,因为空单元格也可能是合理的)
content_factor = 0.35
# -----------------------------------------------------
# 步骤3: 计算structure_factor(结构因子)
# -----------------------------------------------------
# 根据单元格的跨行跨列情况调整置信度
# 跨行列的单元格通常结构更复杂,可能需要不同的置信度
# -----------------------------------------------------
if col['rowspan'] > 1 or col['colspan'] > 1:
# 跨行列单元格:保持正常置信度
structure_factor = 1.0
else:
# 普通单元格:保持正常置信度
structure_factor = 1.0
# -----------------------------------------------------
# 步骤4: 计算quality_factor(质量因子)
# -----------------------------------------------------
# 根据单元格bbox大小和质量调整置信度
# 太小的单元格可能是噪声,置信度降低
# -----------------------------------------------------
cell_width = cell_bbox[2] - cell_bbox[0]
cell_height = cell_bbox[3] - cell_bbox[1]
cell_area = cell_width * cell_height
# 单元格bbox质量评估
if cell_area < 100: # 面积小于100像素 -> 噪声可能性高
quality_factor = 0.5
elif cell_area < 400: # 面积在100-400像素 -> 可疑
quality_factor = 0.75
else: # 面积>=400像素 -> 正常
quality_factor = 1.0
# -----------------------------------------------------
# 步骤5: 综合计算最终cell_score
# -----------------------------------------------------
# 应用公式:cell_score = base_score * content_factor * structure_factor * quality_factor
# 然后限制在[0.0, 1.0]范围内
# -----------------------------------------------------
cell_score = base_score * content_factor * structure_factor * quality_factor
# 确保score在合理范围内 [0.0, 1.0]
cell_score = max(0.0, min(1.0, float(cell_score)))
# 调试日志(第一个单元格)
if row_idx == 0 and col_idx == 0:
logger.debug(f"Cell score calculation: base={base_score:.4f}, "
f"content={content_factor:.4f}, quality={quality_factor:.4f}, "
f"final={cell_score:.4f}, text='{cell_text[:20]}'")
# -----------------------------------------------------
# 计算公式总结
# -----------------------------------------------------
# cell_score = base_score * content_factor * structure_factor * quality_factor
#
# 参数说明:
# - base_score:
# * 有OCR: IoU加权的OCR score(继承spans逻辑)
# * 无OCR: span_score(直接继承)
# - content_factor:
# * 空单元格: 0.35
# * 超短文本(<3): 0.9
# * 短文本(3-10): 1.0
# * 长文本(>=10): 1.05 (上限1.1)
# - structure_factor: 1.0 (当前统一,可根据需要调整)
# - quality_factor:
# * area < 100: 0.5
# * 100 <= area < 400: 0.75
# * area >= 400: 1.0
# -----------------------------------------------------
cells.append({
'row_index': row_idx,
'col_index': col_idx,
'rowspan': col['rowspan'],
'colspan': col['colspan'],
'text': col['text'],
'bbox': cell_bbox, # 已经是整数列表
'score': round(cell_score, 4) # 保留4位小数
})
return cells