magic-pdf 0.8.0__py3-none-any.whl → 0.9.0__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.
Files changed (58) hide show
  1. magic_pdf/config/__init__.py +0 -0
  2. magic_pdf/config/enums.py +7 -0
  3. magic_pdf/config/exceptions.py +32 -0
  4. magic_pdf/data/__init__.py +0 -0
  5. magic_pdf/data/data_reader_writer/__init__.py +12 -0
  6. magic_pdf/data/data_reader_writer/base.py +51 -0
  7. magic_pdf/data/data_reader_writer/filebase.py +59 -0
  8. magic_pdf/data/data_reader_writer/multi_bucket_s3.py +137 -0
  9. magic_pdf/data/data_reader_writer/s3.py +69 -0
  10. magic_pdf/data/dataset.py +194 -0
  11. magic_pdf/data/io/__init__.py +0 -0
  12. magic_pdf/data/io/base.py +42 -0
  13. magic_pdf/data/io/http.py +37 -0
  14. magic_pdf/data/io/s3.py +114 -0
  15. magic_pdf/data/read_api.py +95 -0
  16. magic_pdf/data/schemas.py +15 -0
  17. magic_pdf/data/utils.py +32 -0
  18. magic_pdf/dict2md/ocr_mkcontent.py +74 -234
  19. magic_pdf/libs/Constants.py +21 -8
  20. magic_pdf/libs/MakeContentConfig.py +1 -0
  21. magic_pdf/libs/boxbase.py +54 -0
  22. magic_pdf/libs/clean_memory.py +10 -0
  23. magic_pdf/libs/config_reader.py +53 -23
  24. magic_pdf/libs/draw_bbox.py +150 -65
  25. magic_pdf/libs/ocr_content_type.py +2 -0
  26. magic_pdf/libs/version.py +1 -1
  27. magic_pdf/model/doc_analyze_by_custom_model.py +77 -32
  28. magic_pdf/model/magic_model.py +418 -51
  29. magic_pdf/model/pdf_extract_kit.py +164 -80
  30. magic_pdf/model/pek_sub_modules/structeqtable/StructTableModel.py +8 -1
  31. magic_pdf/model/ppTableModel.py +2 -2
  32. magic_pdf/model/pp_structure_v2.py +5 -2
  33. magic_pdf/model/v3/__init__.py +0 -0
  34. magic_pdf/model/v3/helpers.py +125 -0
  35. magic_pdf/para/para_split_v3.py +296 -0
  36. magic_pdf/pdf_parse_by_ocr.py +6 -3
  37. magic_pdf/pdf_parse_by_txt.py +6 -3
  38. magic_pdf/pdf_parse_union_core_v2.py +644 -0
  39. magic_pdf/pipe/AbsPipe.py +5 -1
  40. magic_pdf/pipe/OCRPipe.py +10 -4
  41. magic_pdf/pipe/TXTPipe.py +10 -4
  42. magic_pdf/pipe/UNIPipe.py +16 -7
  43. magic_pdf/pre_proc/ocr_detect_all_bboxes.py +83 -1
  44. magic_pdf/pre_proc/ocr_dict_merge.py +27 -2
  45. magic_pdf/resources/model_config/UniMERNet/demo.yaml +7 -7
  46. magic_pdf/resources/model_config/model_configs.yaml +5 -13
  47. magic_pdf/tools/cli.py +14 -1
  48. magic_pdf/tools/common.py +19 -9
  49. magic_pdf/user_api.py +25 -6
  50. magic_pdf/utils/__init__.py +0 -0
  51. magic_pdf/utils/annotations.py +11 -0
  52. {magic_pdf-0.8.0.dist-info → magic_pdf-0.9.0.dist-info}/LICENSE.md +1 -0
  53. magic_pdf-0.9.0.dist-info/METADATA +507 -0
  54. {magic_pdf-0.8.0.dist-info → magic_pdf-0.9.0.dist-info}/RECORD +57 -33
  55. magic_pdf-0.8.0.dist-info/METADATA +0 -459
  56. {magic_pdf-0.8.0.dist-info → magic_pdf-0.9.0.dist-info}/WHEEL +0 -0
  57. {magic_pdf-0.8.0.dist-info → magic_pdf-0.9.0.dist-info}/entry_points.txt +0 -0
  58. {magic_pdf-0.8.0.dist-info → magic_pdf-0.9.0.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,507 @@
1
+ Metadata-Version: 2.1
2
+ Name: magic-pdf
3
+ Version: 0.9.0
4
+ Summary: A practical tool for converting PDF to Markdown
5
+ Home-page: https://github.com/opendatalab/MinerU
6
+ Requires-Python: >=3.9
7
+ Description-Content-Type: text/markdown
8
+ License-File: LICENSE.md
9
+ Requires-Dist: boto3>=1.28.43
10
+ Requires-Dist: Brotli>=1.1.0
11
+ Requires-Dist: click>=8.1.7
12
+ Requires-Dist: fast-langdetect==0.2.0
13
+ Requires-Dist: loguru>=0.6.0
14
+ Requires-Dist: numpy<2.0.0,>=1.21.6
15
+ Requires-Dist: pdfminer.six==20231228
16
+ Requires-Dist: pydantic<2.8.0,>=2.7.2
17
+ Requires-Dist: PyMuPDF>=1.24.9
18
+ Requires-Dist: scikit-learn>=1.0.2
19
+ Requires-Dist: torch<=2.3.1,>=2.2.2
20
+ Requires-Dist: transformers
21
+ Provides-Extra: full
22
+ Requires-Dist: unimernet==0.2.1; extra == "full"
23
+ Requires-Dist: ultralytics; extra == "full"
24
+ Requires-Dist: paddleocr==2.7.3; extra == "full"
25
+ Requires-Dist: pypandoc; extra == "full"
26
+ Requires-Dist: struct-eqtable==0.1.0; extra == "full"
27
+ Requires-Dist: doclayout-yolo==0.0.2; extra == "full"
28
+ Requires-Dist: detectron2; extra == "full"
29
+ Requires-Dist: paddlepaddle==3.0.0b1; platform_system == "Linux" and extra == "full"
30
+ Requires-Dist: matplotlib; (platform_system == "Linux" or platform_system == "Darwin") and extra == "full"
31
+ Requires-Dist: matplotlib<=3.9.0; platform_system == "Windows" and extra == "full"
32
+ Requires-Dist: paddlepaddle==2.6.1; (platform_system == "Windows" or platform_system == "Darwin") and extra == "full"
33
+ Provides-Extra: lite
34
+ Requires-Dist: paddleocr==2.7.3; extra == "lite"
35
+ Requires-Dist: paddlepaddle==3.0.0b1; platform_system == "Linux" and extra == "lite"
36
+ Requires-Dist: paddlepaddle==2.6.1; (platform_system == "Windows" or platform_system == "Darwin") and extra == "lite"
37
+
38
+ <div align="center" xmlns="http://www.w3.org/1999/html">
39
+ <!-- logo -->
40
+ <p align="center">
41
+ <img src="docs/images/MinerU-logo.png" width="300px" style="vertical-align:middle;">
42
+ </p>
43
+
44
+ <!-- icon -->
45
+
46
+ [![stars](https://img.shields.io/github/stars/opendatalab/MinerU.svg)](https://github.com/opendatalab/MinerU)
47
+ [![forks](https://img.shields.io/github/forks/opendatalab/MinerU.svg)](https://github.com/opendatalab/MinerU)
48
+ [![open issues](https://img.shields.io/github/issues-raw/opendatalab/MinerU)](https://github.com/opendatalab/MinerU/issues)
49
+ [![issue resolution](https://img.shields.io/github/issues-closed-raw/opendatalab/MinerU)](https://github.com/opendatalab/MinerU/issues)
50
+ [![PyPI version](https://badge.fury.io/py/magic-pdf.svg)](https://badge.fury.io/py/magic-pdf)
51
+ [![Downloads](https://static.pepy.tech/badge/magic-pdf)](https://pepy.tech/project/magic-pdf)
52
+ [![Downloads](https://static.pepy.tech/badge/magic-pdf/month)](https://pepy.tech/project/magic-pdf)
53
+
54
+ [![OpenDataLab](https://img.shields.io/badge/Demo_on_OpenDataLab-blue?logo=data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzAiIGhlaWdodD0iMzAiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgZmlsbD0ibm9uZSI+CiA8ZGVmcz4KICA8bGluZWFyR3JhZGllbnQgeTI9IjAuNTMzNjciIHgyPSIxLjAwMDQiIHkxPSIwLjI5MjE5IiB4MT0iLTAuMTEyNjgiIGlkPSJhIj4KICAgPHN0b3Agc3RvcC1jb2xvcj0iIzE1NDNGRSIvPgogICA8c3RvcCBzdG9wLWNvbG9yPSIjOEM0NkZGIiBvZmZzZXQ9IjEiLz4KICA8L2xpbmVhckdyYWRpZW50PgogIDxsaW5lYXJHcmFkaWVudCB5Mj0iMC41OTc1NyIgeDI9IjEuMDExMzciIHkxPSIwLjExMDIzIiB4MT0iLTAuMDg0NzQiIGlkPSJiIj4KICAgPHN0b3Agc3RvcC1jb2xvcj0iIzE1NDNGRSIvPgogICA8c3RvcCBzdG9wLWNvbG9yPSIjOEM0NkZGIiBvZmZzZXQ9IjEiLz4KICA8L2xpbmVhckdyYWRpZW50PgogPC9kZWZzPgogPGc+CiAgPHRpdGxlPkxheWVyIDE8L3RpdGxlPgogIDxwYXRoIGlkPSJzdmdfMSIgZmlsbD0idXJsKCNhKSI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MC42MWwtMC4wMDEsLTAuMDAxeiIvPgogPC9nPgo8L3N2Zz4=&labelColor=white)](https://opendatalab.com/OpenSourceTools/Extractor/PDF)
55
+ [![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+nDr12ttmESZ4zludJEG5S7TO72YPlKZFyE+YCYUJTBZsMiNS5Sd7NlDmKM2Eg2JQg8awbglfqgbhArjxkS7dgp2RH6hc9AMLdZYUtZN5DJr4molC8BfKrEkPKEnEVjLbgW1fLy77ZVOJagoIcLIl+IxaQZGjiX597HopF5CkaXVMDO9Pyix3AFV3kw4lQLCbHuMovz8FallbcQIJ5Ta0vks9RnolbCK84BtjKRS5uA43hYoZcOBGIG2Epbv6CvFVQ8m8loh66WNySsnN7htL58LNp+NXT8/PhXiBXPMjLSxtwp8W9f/1AngRierBkA+kk/IpUSOeKByzn8y3kAAAfh//0oXgV4roHm/kz4E2z//zRc3/lgwBzbM2mJxQEa5pqgX7d1L0htrhx7LKxOZlKbwcAWyEOWqYSI8YPtgDQVjpB5nvaHaSnBaQSD6hweDi8PosxD6/PT09YY3xQA7LTCTKfYX+QHpA0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Kqgpi4IBkw+utSPIoBijDXJipSVV7MpOEJUAc5Qmm3BnUN+w3hteEieYKfRZSIUcXKMVf0u5wD4EwsUNVvZOtUT7A2GkffHjByWpHqvRBYrTV72a6j8zZ6W0DTE86Hn04bmyWX3Ri9WH7ZU6Q7h+ZHo0nHUAcsQvVhXRDZHChwiyi/hnPuOsSEF6Exk3o6Y9DT1eZ+6cASXk2Y9k+6EOQMDGm6WBK10wOQJCBwren86cPPWUcRAnTVjGcU1LBgs9FURiX/e6479yZcLwCBmTxiawEwrOcleuu12t3tbLv/N4RLYIBhYexm7Fcn4OJcn0+zc+s8/VfPeddZHAGN6TT8eGczHdR/Gts1/MzDkThr23zqrVfAMFT33Nx1RJsx1k5zuWILLnG/vsH+Fv5D4NTVcp1Gzo8AAAAAElFTkSuQmCC&labelColor=white)](https://huggingface.co/spaces/opendatalab/MinerU)
56
+ [![ModelScope](https://img.shields.io/badge/Demo_on_ModelScope-purple?logo=data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjIzIiBoZWlnaHQ9IjIwMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KCiA8Zz4KICA8dGl0bGU+TGF5ZXIgMTwvdGl0bGU+CiAgPHBhdGggaWQ9InN2Z18xNCIgZmlsbD0iIzYyNGFmZiIgZD0ibTAsODkuODRsMjUuNjUsMGwwLDI1LjY0OTk5bC0yNS42NSwwbDAsLTI1LjY0OTk5eiIvPgogIDxwYXRoIGlkPSJzdmdfMTUiIGZpbGw9IiM2MjRhZmYiIGQ9Im05OS4xNCwxMTUuNDlsMjUuNjUsMGwwLDI1LjY1bC0yNS42NSwwbDAsLTI1LjY1eiIvPgogIDxwYXRoIGlkPSJzdmdfMTYiIGZpbGw9IiM2MjRhZmYiIGQ9Im0xNzYuMDksMTQxLjE0bC0yNS42NDk5OSwwbDAsMjIuMTlsNDcuODQsMGwwLC00Ny44NGwtMjIuMTksMGwwLDI1LjY1eiIvPgogIDxwYXRoIGlk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MCwtMjUuNjV6Ii8+CiA8L2c+Cjwvc3ZnPg==&labelColor=white)](https://www.modelscope.cn/studios/OpenDataLab/MinerU)
57
+ [![Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/gist/papayalove/b5f4913389e7ff9883c6b687de156e78/mineru_demo.ipynb)
58
+
59
+ [![Paper](https://img.shields.io/badge/Paper-arXiv-green)](https://arxiv.org/abs/2409.18839)
60
+
61
+
62
+ <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>
63
+
64
+ <!-- language -->
65
+
66
+ [English](README.md) | [简体中文](README_zh-CN.md)
67
+
68
+ <!-- hot link -->
69
+
70
+ <p align="center">
71
+ <a href="https://github.com/opendatalab/PDF-Extract-Kit">PDF-Extract-Kit: High-Quality PDF Extraction Toolkit</a>🔥🔥🔥
72
+ </p>
73
+
74
+ <!-- join us -->
75
+
76
+ <p align="center">
77
+ 👋 join us on <a href="https://discord.gg/Tdedn9GTXq" target="_blank">Discord</a> and <a href="https://cdn.vansin.top/internlm/mineru.jpg" target="_blank">WeChat</a>
78
+ </p>
79
+
80
+ </div>
81
+
82
+ # Changelog
83
+ - 2024/10/31 0.9.0 released. This is a major new version with extensive code refactoring, addressing numerous issues, improving performance, reducing hardware requirements, and enhancing usability:
84
+ - Refactored the sorting module code to use [layoutreader](https://github.com/ppaanngggg/layoutreader) for reading order sorting, ensuring high accuracy in various layouts.
85
+ - Refactored the paragraph concatenation module to achieve good results in cross-column, cross-page, cross-figure, and cross-table scenarios.
86
+ - 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.
87
+ - 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.
88
+ - Added multi-language support for OCR, supporting detection and recognition of 84 languages.For the list of supported languages, see [OCR Language Support List](https://paddlepaddle.github.io/PaddleOCR/latest/en/ppocr/blog/multi_languages.html#5-support-languages-and-abbreviations).
89
+ - 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.
90
+ - Optimized configuration file feature switches, adding an independent formula detection switch to significantly improve speed and parsing results when formula detection is not needed.
91
+ - Integrated [PDF-Extract-Kit 1.0](https://github.com/opendatalab/PDF-Extract-Kit):
92
+ - Added the self-developed `doclayout_yolo` 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 `layoutlmv3` via the configuration file.
93
+ - Upgraded formula parsing to `unimernet 0.2.1`, improving formula parsing accuracy while significantly reducing memory usage.
94
+ - Due to the repository change for `PDF-Extract-Kit 1.0`, you need to re-download the model. Please refer to [How to Download Models](docs/how_to_download_models_en.md) for detailed steps.
95
+ - 2024/09/27 Version 0.8.1 released, Fixed some bugs, and providing a [localized deployment version](projects/web_demo/README.md) of the [online demo](https://opendatalab.com/OpenSourceTools/Extractor/PDF/) and the [front-end interface](projects/web/README.md).
96
+ - 2024/09/09: Version 0.8.0 released, supporting fast deployment with Dockerfile, and launching demos on Huggingface and Modelscope.
97
+ - 2024/08/30: Version 0.7.1 released, add paddle tablemaster table recognition option
98
+ - 2024/08/09: Version 0.7.0b1 released, simplified installation process, added table recognition functionality
99
+ - 2024/08/01: Version 0.6.2b1 released, optimized dependency conflict issues and installation documentation
100
+ - 2024/07/05: Initial open-source release
101
+
102
+ <!-- TABLE OF CONTENT -->
103
+
104
+ <details open="open">
105
+ <summary><h2 style="display: inline-block">Table of Contents</h2></summary>
106
+ <ol>
107
+ <li>
108
+ <a href="#mineru">MinerU</a>
109
+ <ul>
110
+ <li><a href="#project-introduction">Project Introduction</a></li>
111
+ <li><a href="#key-features">Key Features</a></li>
112
+ <li><a href="#quick-start">Quick Start</a>
113
+ <ul>
114
+ <li><a href="#online-demo">Online Demo</a></li>
115
+ <li><a href="#quick-cpu-demo">Quick CPU Demo</a></li>
116
+ <li><a href="#using-gpu">Using GPU</a></li>
117
+ </ul>
118
+ </li>
119
+ <li><a href="#usage">Usage</a>
120
+ <ul>
121
+ <li><a href="#command-line">Command Line</a></li>
122
+ <li><a href="#api">API</a></li>
123
+ <li><a href="#deploy-derived-projects">Deploy Derived Projects</a></li>
124
+ <li><a href="#development-guide">Development Guide</a></li>
125
+ </ul>
126
+ </li>
127
+ </ul>
128
+ </li>
129
+ <li><a href="#todo">TODO</a></li>
130
+ <li><a href="#known-issues">Known Issues</a></li>
131
+ <li><a href="#faq">FAQ</a></li>
132
+ <li><a href="#all-thanks-to-our-contributors">All Thanks To Our Contributors</a></li>
133
+ <li><a href="#license-information">License Information</a></li>
134
+ <li><a href="#acknowledgments">Acknowledgments</a></li>
135
+ <li><a href="#citation">Citation</a></li>
136
+ <li><a href="#star-history">Star History</a></li>
137
+ <li><a href="#magic-doc">Magic-doc</a></li>
138
+ <li><a href="#magic-html">Magic-html</a></li>
139
+ <li><a href="#links">Links</a></li>
140
+ </ol>
141
+ </details>
142
+
143
+ # MinerU
144
+
145
+ ## Project Introduction
146
+
147
+ MinerU is a tool that converts PDFs into machine-readable formats (e.g., markdown, JSON), allowing for easy extraction into any format.
148
+ 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.
149
+ 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**.
150
+
151
+ https://github.com/user-attachments/assets/4bea02c9-6d54-4cd6-97ed-dff14340982c
152
+
153
+ ## Key Features
154
+
155
+ - Remove headers, footers, footnotes, page numbers, etc., to ensure semantic coherence.
156
+ - Output text in human-readable order, suitable for single-column, multi-column, and complex layouts.
157
+ - Preserve the structure of the original document, including headings, paragraphs, lists, etc.
158
+ - Extract images, image descriptions, tables, table titles, and footnotes.
159
+ - Automatically recognize and convert formulas in the document to LaTeX format.
160
+ - Automatically recognize and convert tables in the document to LaTeX or HTML format.
161
+ - Automatically detect scanned PDFs and garbled PDFs and enable OCR functionality.
162
+ - OCR supports detection and recognition of 84 languages.
163
+ - Supports multiple output formats, such as multimodal and NLP Markdown, JSON sorted by reading order, and rich intermediate formats.
164
+ - Supports various visualization results, including layout visualization and span visualization, for efficient confirmation of output quality.
165
+ - Supports both CPU and GPU environments.
166
+ - Compatible with Windows, Linux, and Mac platforms.
167
+
168
+ ## Quick Start
169
+
170
+ If you encounter any installation issues, please first consult the <a href="#faq">FAQ</a>. </br>
171
+ If the parsing results are not as expected, refer to the <a href="#known-issues">Known Issues</a>. </br>
172
+ There are three different ways to experience MinerU:
173
+
174
+ - [Online Demo (No Installation Required)](#online-demo)
175
+ - [Quick CPU Demo (Windows, Linux, Mac)](#quick-cpu-demo)
176
+ - [Linux/Windows + CUDA](#Using-GPU)
177
+
178
+ **⚠️ Pre-installation Notice—Hardware and Software Environment Support**
179
+
180
+ 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.
181
+
182
+ By focusing resources on the mainline environment, our team can more efficiently resolve potential bugs and develop new features.
183
+
184
+ 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.
185
+
186
+ <table>
187
+ <tr>
188
+ <td colspan="3" rowspan="2">Operating System</td>
189
+ </tr>
190
+ <tr>
191
+ <td>Ubuntu 22.04 LTS</td>
192
+ <td>Windows 10 / 11</td>
193
+ <td>macOS 11+</td>
194
+ </tr>
195
+ <tr>
196
+ <td colspan="3">CPU</td>
197
+ <td>x86_64(unsupported ARM Linux)</td>
198
+ <td>x86_64(unsupported ARM Windows)</td>
199
+ <td>x86_64 / arm64</td>
200
+ </tr>
201
+ <tr>
202
+ <td colspan="3">Memory</td>
203
+ <td colspan="3">16GB or more, recommended 32GB+</td>
204
+ </tr>
205
+ <tr>
206
+ <td colspan="3">Python Version</td>
207
+ <td colspan="3">3.10(Please make sure to create a Python 3.10 virtual environment using conda)</td>
208
+ </tr>
209
+ <tr>
210
+ <td colspan="3">Nvidia Driver Version</td>
211
+ <td>latest (Proprietary Driver)</td>
212
+ <td>latest</td>
213
+ <td>None</td>
214
+ </tr>
215
+ <tr>
216
+ <td colspan="3">CUDA Environment</td>
217
+ <td>Automatic installation [12.1 (pytorch) + 11.8 (paddle)]</td>
218
+ <td>11.8 (manual installation) + cuDNN v8.7.0 (manual installation)</td>
219
+ <td>None</td>
220
+ </tr>
221
+ <tr>
222
+ <td rowspan="2">GPU Hardware Support List</td>
223
+ <td colspan="2">Minimum Requirement 8G+ VRAM</td>
224
+ <td colspan="2">3060ti/3070/4060<br>
225
+ 8G VRAM enables layout, formula recognition acceleration and OCR acceleration</td>
226
+ <td rowspan="2">None</td>
227
+ </tr>
228
+ <tr>
229
+ <td colspan="2">Recommended Configuration 10G+ VRAM</td>
230
+ <td colspan="2">3080/3080ti/3090/3090ti/4070/4070ti/4070tisuper/4080/4090<br>
231
+ 10G VRAM or more can enable layout, formula recognition, OCR acceleration and table recognition acceleration simultaneously
232
+ </td>
233
+ </tr>
234
+ </table>
235
+
236
+ ### Online Demo
237
+
238
+ Stable Version (Stable version verified by QA):
239
+ [![OpenDataLab](https://img.shields.io/badge/Demo_on_OpenDataLab-blue?logo=data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzAiIGhlaWdodD0iMzAiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgZmlsbD0ibm9uZSI+CiA8ZGVmcz4KICA8bGluZWFyR3JhZGllbnQgeTI9IjAuNTMzNjciIHgyPSIxLj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MDQgMCAxIDEgLTQuODA3LDBsMCwtNC4yNzhsLTIuODEyLDBsMCw0LjY4NmE1LjIxNSw1LjIxNSAwIDAgMCAxMC40MywwbDAsLTQuNjg2bDAsMi41NjdsLTIuODEsMGwtMC4wMDEsMHoiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZmlsbC1ydWxlPSJldmVub2RkIi8+CiAgPHBhdGggaWQ9InN2Z183IiBmaWxsPSIjZmZmIiBkPSJtMjIuODk4LDEzLjc3MWwxLjE0LDBsMCwxLjE0MWwtMS4xNCwwbDAsLTEuMTRsMCwtMC4wMDF6bS0yLjgxMiwtMC42OTJsMS44MzQsMGwwLDEuODMzbC0xLjgzNCwwbDAsLTEuODMybDAsLTAuMDAxem0xLjgzNCwtMC45NzlsMC45NzgsMGwwLDAuOTc5bC0wLjk3OCwwbDAsLTAuOTc5em0xLjU0OCwtMS42MjlsMC42MTEsMGwwLDAuNjExbC0wLjYxLDBsMCwtMC42MWwtMC4wMDEsLTAuMDAxeiIvPgogPC9nPgo8L3N2Zz4=&labelColor=white)](https://opendatalab.com/OpenSourceTools/Extractor/PDF)
240
+
241
+ Test Version (Synced with dev branch updates, testing new features):
242
+ [![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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JS+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)
243
+ [![ModelScope](https://img.shields.io/badge/Demo_on_ModelScope-purple?logo=data:image/svg+xml;base64,PHN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IxIiBmaWxsPSIjNjI0YWZmIiBkPSJtMTUwLjQ0LDQybDAsMjIuMTlsMjUuNjQ5OTksMGwwLDI1LjY1bDIyLjE5LDBsMCwtNDcuODRsLTQ3Ljg0LDB6Ii8+CiAgPHBhdGggaWQ9InN2Z18yMiIgZmlsbD0iIzM2Y2ZkMSIgZD0ibTczLjQ5LDg5Ljg0bDI1LjY1LDBsMCwyNS42NDk5OWwtMjUuNjUsMGwwLC0yNS42NDk5OXoiLz4KICA8cGF0aCBpZD0ic3ZnXzIzIiBmaWxsPSIjNjI0YWZmIiBkPSJtNDcuODQsNjQuMTlsMjUuNjUsMGwwLC0yMi4xOWwtNDcuODQsMGwwLDQ3Ljg0bDIyLjE5LDBsMCwtMjUuNjV6Ii8+CiAgPHBhdGggaWQ9InN2Z18yNCIgZmlsbD0iIzYyNGFmZiIgZD0ibTQ3Ljg0LDExNS40OWwtMjIuMTksMGwwLDQ3Ljg0bDQ3Ljg0LDBsMCwtMjIuMTlsLTI1LjY1LDBsMCwtMjUuNjV6Ii8+CiA8L2c+Cjwvc3ZnPg==&labelColor=white)](https://www.modelscope.cn/studios/OpenDataLab/MinerU)
244
+
245
+ ### Quick CPU Demo
246
+
247
+ #### 1. Install magic-pdf
248
+
249
+ ```bash
250
+ conda create -n MinerU python=3.10
251
+ conda activate MinerU
252
+ pip install -U magic-pdf[full] --extra-index-url https://wheels.myhloli.com
253
+ ```
254
+
255
+ #### 2. Download model weight files
256
+
257
+ Refer to [How to Download Model Files](docs/how_to_download_models_en.md) for detailed instructions.
258
+
259
+ #### 3. Modify the Configuration File for Additional Configuration
260
+
261
+ After completing the [2. Download model weight files](#2-download-model-weight-files) step, the script will automatically generate a `magic-pdf.json` file in the user directory and configure the default model path.
262
+ You can find the `magic-pdf.json` file in your 【user directory】.
263
+
264
+ > The user directory for Windows is "C:\\Users\\username", for Linux it is "/home/username", and for macOS it is "/Users/username".
265
+
266
+ You can modify certain configurations in this file to enable or disable features, such as table recognition:
267
+
268
+
269
+ > If the following items are not present in the JSON, please manually add the required items and remove the comment content (standard JSON does not support comments).
270
+
271
+ ```json
272
+ {
273
+ // other config
274
+ "layout-config": {
275
+ "model": "layoutlmv3" // Please change to "doclayout_yolo" when using doclayout_yolo.
276
+ },
277
+ "formula-config": {
278
+ "mfd_model": "yolo_v8_mfd",
279
+ "mfr_model": "unimernet_small",
280
+ "enable": true // The formula recognition feature is enabled by default. If you need to disable it, please change the value here to "false".
281
+ },
282
+ "table-config": {
283
+ "model": "tablemaster", // When using structEqTable, please change to "struct_eqtable".
284
+ "enable": false, // The table recognition feature is disabled by default. If you need to enable it, please change the value here to "true".
285
+ "max_time": 400
286
+ }
287
+ }
288
+ ```
289
+
290
+ ### Using GPU
291
+
292
+ If your device supports CUDA and meets the GPU requirements of the mainline environment, you can use GPU acceleration. Please select the appropriate guide based on your system:
293
+
294
+ - [Ubuntu 22.04 LTS + GPU](docs/README_Ubuntu_CUDA_Acceleration_en_US.md)
295
+ - [Windows 10/11 + GPU](docs/README_Windows_CUDA_Acceleration_en_US.md)
296
+ - Quick Deployment with Docker
297
+ > Docker requires a GPU with at least 16GB of VRAM, and all acceleration features are enabled by default.
298
+ >
299
+ > Before running this Docker, you can use the following command to check if your device supports CUDA acceleration on Docker.
300
+ >
301
+ > ```bash
302
+ > docker run --rm --gpus=all nvidia/cuda:12.1.0-base-ubuntu22.04 nvidia-smi
303
+ > ```
304
+ ```bash
305
+ wget https://github.com/opendatalab/MinerU/raw/master/Dockerfile
306
+ docker build -t mineru:latest .
307
+ docker run --rm -it --gpus=all mineru:latest /bin/bash
308
+ magic-pdf --help
309
+ ```
310
+
311
+ ## Usage
312
+
313
+ ### Command Line
314
+
315
+ ```bash
316
+ magic-pdf --help
317
+ Usage: magic-pdf [OPTIONS]
318
+
319
+ Options:
320
+ -v, --version display the version and exit
321
+ -p, --path PATH local pdf filepath or directory [required]
322
+ -o, --output-dir PATH output local directory [required]
323
+ -m, --method [ocr|txt|auto] the method for parsing pdf. ocr: using ocr
324
+ technique to extract information from pdf. txt:
325
+ suitable for the text-based pdf only and
326
+ outperform ocr. auto: automatically choose the
327
+ best method for parsing pdf from ocr and txt.
328
+ without method specified, auto will be used by
329
+ default.
330
+ -l, --lang TEXT Input the languages in the pdf (if known) to
331
+ improve OCR accuracy. Optional. You should
332
+ input "Abbreviation" with language form url: ht
333
+ tps://paddlepaddle.github.io/PaddleOCR/latest/en
334
+ /ppocr/blog/multi_languages.html#5-support-languages-
335
+ and-abbreviations
336
+ -d, --debug BOOLEAN Enables detailed debugging information during
337
+ the execution of the CLI commands.
338
+ -s, --start INTEGER The starting page for PDF parsing, beginning
339
+ from 0.
340
+ -e, --end INTEGER The ending page for PDF parsing, beginning from
341
+ 0.
342
+ --help Show this message and exit.
343
+
344
+
345
+ ## show version
346
+ magic-pdf -v
347
+
348
+ ## command line example
349
+ magic-pdf -p {some_pdf} -o {some_output_dir} -m auto
350
+ ```
351
+
352
+ `{some_pdf}` can be a single PDF file or a directory containing multiple PDFs.
353
+ The results will be saved in the `{some_output_dir}` directory. The output file list is as follows:
354
+
355
+ ```text
356
+ ├── some_pdf.md # markdown file
357
+ ├── images # directory for storing images
358
+ ├── some_pdf_layout.pdf # layout diagram (Include layout reading order)
359
+ ├── some_pdf_middle.json # MinerU intermediate processing result
360
+ ├── some_pdf_model.json # model inference result
361
+ ├── some_pdf_origin.pdf # original PDF file
362
+ ├── some_pdf_spans.pdf # smallest granularity bbox position information diagram
363
+ └── some_pdf_content_list.json # Rich text JSON arranged in reading order
364
+ ```
365
+
366
+ For more information about the output files, please refer to the [Output File Description](docs/output_file_en_us.md).
367
+
368
+ ### API
369
+
370
+ Processing files from local disk
371
+
372
+ ```python
373
+ image_writer = DiskReaderWriter(local_image_dir)
374
+ image_dir = str(os.path.basename(local_image_dir))
375
+ jso_useful_key = {"_pdf_type": "", "model_list": []}
376
+ pipe = UNIPipe(pdf_bytes, jso_useful_key, image_writer)
377
+ pipe.pipe_classify()
378
+ pipe.pipe_analyze()
379
+ pipe.pipe_parse()
380
+ md_content = pipe.pipe_mk_markdown(image_dir, drop_mode="none")
381
+ ```
382
+
383
+ Processing files from object storage
384
+
385
+ ```python
386
+ s3pdf_cli = S3ReaderWriter(pdf_ak, pdf_sk, pdf_endpoint)
387
+ image_dir = "s3://img_bucket/"
388
+ s3image_cli = S3ReaderWriter(img_ak, img_sk, img_endpoint, parent_path=image_dir)
389
+ pdf_bytes = s3pdf_cli.read(s3_pdf_path, mode=s3pdf_cli.MODE_BIN)
390
+ jso_useful_key = {"_pdf_type": "", "model_list": []}
391
+ pipe = UNIPipe(pdf_bytes, jso_useful_key, s3image_cli)
392
+ pipe.pipe_classify()
393
+ pipe.pipe_analyze()
394
+ pipe.pipe_parse()
395
+ md_content = pipe.pipe_mk_markdown(image_dir, drop_mode="none")
396
+ ```
397
+
398
+ For detailed implementation, refer to:
399
+
400
+ - [demo.py Simplest Processing Method](demo/demo.py)
401
+ - [magic_pdf_parse_main.py More Detailed Processing Workflow](demo/magic_pdf_parse_main.py)
402
+
403
+ ### Deploy Derived Projects
404
+
405
+ Derived projects include secondary development projects based on MinerU by project developers and community developers,
406
+ such as application interfaces based on Gradio, RAG based on llama, web demos similar to the official website, lightweight multi-GPU load balancing client/server ends, etc.
407
+ These projects may offer more features and a better user experience.
408
+ For specific deployment methods, please refer to the [Derived Project README](projects/README.md)
409
+
410
+
411
+ ### Development Guide
412
+
413
+ TODO
414
+
415
+ # TODO
416
+
417
+ - 🗹 Reading order based on the model
418
+ - 🗹 Recognition of `index` and `list` in the main text
419
+ - 🗹 Table recognition
420
+ - ☐ Code block recognition in the main text
421
+ - ☐ [Chemical formula recognition](docs/chemical_knowledge_introduction/introduction.pdf)
422
+ - ☐ Geometric shape recognition
423
+
424
+ # Known Issues
425
+
426
+ - 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.
427
+ - Vertical text is not supported.
428
+ - Tables of contents and lists are recognized through rules, and some uncommon list formats may not be recognized.
429
+ - Only one level of headings is supported; hierarchical headings are not currently supported.
430
+ - Code blocks are not yet supported in the layout model.
431
+ - Comic books, art albums, primary school textbooks, and exercises cannot be parsed well.
432
+ - Table recognition may result in row/column recognition errors in complex tables.
433
+ - 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).
434
+ - Some formulas may not render correctly in Markdown.
435
+
436
+ # FAQ
437
+
438
+ [FAQ in Chinese](docs/FAQ_zh_cn.md)
439
+
440
+ [FAQ in English](docs/FAQ_en_us.md)
441
+
442
+ # All Thanks To Our Contributors
443
+
444
+ <a href="https://github.com/opendatalab/MinerU/graphs/contributors">
445
+ <img src="https://contrib.rocks/image?repo=opendatalab/MinerU" />
446
+ </a>
447
+
448
+ # License Information
449
+
450
+ [LICENSE.md](LICENSE.md)
451
+
452
+ This project currently uses PyMuPDF to achieve advanced functionality. However, since it adheres to the AGPL license, it may impose restrictions on certain usage scenarios. In future iterations, we plan to explore and replace it with a more permissive PDF processing library to enhance user-friendliness and flexibility.
453
+
454
+ # Acknowledgments
455
+
456
+ - [PDF-Extract-Kit](https://github.com/opendatalab/PDF-Extract-Kit)
457
+ - [StructEqTable](https://github.com/UniModal4Reasoning/StructEqTable-Deploy)
458
+ - [PaddleOCR](https://github.com/PaddlePaddle/PaddleOCR)
459
+ - [PyMuPDF](https://github.com/pymupdf/PyMuPDF)
460
+ - [layoutreader](https://github.com/ppaanngggg/layoutreader)
461
+ - [fast-langdetect](https://github.com/LlmKira/fast-langdetect)
462
+ - [pdfminer.six](https://github.com/pdfminer/pdfminer.six)
463
+
464
+ # Citation
465
+
466
+ ```bibtex
467
+ @misc{wang2024mineruopensourcesolutionprecise,
468
+ title={MinerU: An Open-Source Solution for Precise Document Content Extraction},
469
+ 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},
470
+ year={2024},
471
+ eprint={2409.18839},
472
+ archivePrefix={arXiv},
473
+ primaryClass={cs.CV},
474
+ url={https://arxiv.org/abs/2409.18839},
475
+ }
476
+
477
+ @article{he2024opendatalab,
478
+ title={Opendatalab: Empowering general artificial intelligence with open datasets},
479
+ author={He, Conghui and Li, Wei and Jin, Zhenjiang and Xu, Chao and Wang, Bin and Lin, Dahua},
480
+ journal={arXiv preprint arXiv:2407.13773},
481
+ year={2024}
482
+ }
483
+ ```
484
+
485
+ # Star History
486
+
487
+ <a>
488
+ <picture>
489
+ <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=opendatalab/MinerU&type=Date&theme=dark" />
490
+ <source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/svg?repos=opendatalab/MinerU&type=Date" />
491
+ <img alt="Star History Chart" src="https://api.star-history.com/svg?repos=opendatalab/MinerU&type=Date" />
492
+ </picture>
493
+ </a>
494
+
495
+ # Magic-doc
496
+
497
+ [Magic-Doc](https://github.com/InternLM/magic-doc) Fast speed ppt/pptx/doc/docx/pdf extraction tool
498
+
499
+ # Magic-html
500
+
501
+ [Magic-HTML](https://github.com/opendatalab/magic-html) Mixed web page extraction tool
502
+
503
+ # Links
504
+
505
+ - [LabelU (A Lightweight Multi-modal Data Annotation Tool)](https://github.com/opendatalab/labelU)
506
+ - [LabelLLM (An Open-source LLM Dialogue Annotation Platform)](https://github.com/opendatalab/LabelLLM)
507
+ - [PDF-Extract-Kit (A Comprehensive Toolkit for High-Quality PDF Content Extraction)](https://github.com/opendatalab/PDF-Extract-Kit)