README_zh-CN.md 4.09 KB
Newer Older
赵小蒙's avatar
赵小蒙 committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<div id="top"></div>
<div align="center">

[![stars](https://img.shields.io/github/stars/magicpdf/Magic-PDF.svg)](https://github.com/magicpdf/Magic-PDF)
[![forks](https://img.shields.io/github/forks/magicpdf/Magic-PDF.svg)](https://github.com/magicpdf/Magic-PDF)
[![license](https://img.shields.io/github/license/magicpdf/Magic-PDF.svg)](https://github.com/magicpdf/Magic-PDF/tree/main/LICENSE)
[![issue resolution](https://img.shields.io/github/issues-closed-raw/magicpdf/Magic-PDF)](https://github.com/magicpdf/Magic-PDF/issues)
[![open issues](https://img.shields.io/github/issues-raw/magicpdf/Magic-PDF)](https://github.com/magicpdf/Magic-PDF/issues)

[English](README.md) | [简体中文](README_zh-CN.md)

</div>

<div align="center">

</div>

赵小蒙's avatar
赵小蒙 committed
18
19
# MinerU 

myhloli's avatar
myhloli committed
20
21
## 简介

赵小蒙's avatar
赵小蒙 committed
22
23
24
25
26
MinerU 是一款一站式开源数据提取工具,主要包含以下功能:

- PDF文档提取  (Magic-PDF)
- 网页与电子书提取  (Magic-Doc)

赵小蒙's avatar
赵小蒙 committed
27
28
# Magic-PDF

赵小蒙's avatar
赵小蒙 committed
29
## 简介
赵小蒙's avatar
赵小蒙 committed
30
31
32
33
34
35
36
37

Magic-PDF 是一款将 PDF 转化为 markdown 格式的工具。支持转换本地文档或者位于支持S3协议对象存储上的文件。

主要功能包含

- 支持多种前端模型输入
- 删除页眉、页脚、脚注、页码等元素
- 符合人类阅读顺序的排版格式
赵小蒙's avatar
赵小蒙 committed
38
- 保留原文档的结构和格式,包括标题、段落、列表等
赵小蒙's avatar
赵小蒙 committed
39
40
41
42
43
44
- 提取图像和表格并在markdown中展示
- 将公式转换成latex
- 乱码PDF自动识别并转换
- 支持cpu和gpu环境
- 支持windows/linux/mac平台

myhloli's avatar
myhloli committed
45
46
47
48

https://github.com/magicpdf/Magic-PDF/assets/11393164/618937cb-dc6a-4646-b433-e3131a5f4070


赵小蒙's avatar
update:  
赵小蒙 committed
49

赵小蒙's avatar
赵小蒙 committed
50
51
52
53
## 项目全景

![项目全景图](docs/images/project_panorama_zh_cn.png)

赵小蒙's avatar
赵小蒙 committed
54
55
## 流程图

56
57
58
59
60
![流程图](docs/images/flowchart_zh_cn.png)

### 子模块仓库

- [pdf-extract-kit](https://github.com/wangbinDL/pdf-extract-kit)
myhloli's avatar
myhloli committed
61
  领先的文档分析模型
赵小蒙's avatar
赵小蒙 committed
62
- [Miner-PDF-Benchmark](https://github.com/opendatalab/Miner-PDF-Benchmark) 
myhloli's avatar
myhloli committed
63
  端到端的PDF文档理解评估套件,专为大规模模型数据场景而设计
64

赵小蒙's avatar
赵小蒙 committed
65

赵小蒙's avatar
赵小蒙 committed
66
## 上手指南
赵小蒙's avatar
赵小蒙 committed
67

赵小蒙's avatar
赵小蒙 committed
68
### 配置要求
赵小蒙's avatar
赵小蒙 committed
69
70
71

python 3.9+

赵小蒙's avatar
赵小蒙 committed
72
### 使用说明
赵小蒙's avatar
赵小蒙 committed
73

赵小蒙's avatar
赵小蒙 committed
74
#### 1. 安装Magic-PDF
赵小蒙's avatar
赵小蒙 committed
75
```bash
赵小蒙's avatar
赵小蒙 committed
76
pip install magic-pdf
赵小蒙's avatar
赵小蒙 committed
77
78
```

赵小蒙's avatar
赵小蒙 committed
79
#### 2. 通过命令行使用
赵小蒙's avatar
赵小蒙 committed
80

赵小蒙's avatar
赵小蒙 committed
81
82
83
84
85
86
###### 直接使用
```bash
cp magic-pdf.template.json to ~/magic-pdf.json
magic-pdf pdf-command --pdf "pdf_path" --model "model_json_path"
```
###### 更多用法
赵小蒙's avatar
赵小蒙 committed
87
88
89
90
```bash
magic-pdf --help
```

赵小蒙's avatar
赵小蒙 committed
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#### 3. 通过接口调用

###### 本地使用
```python
image_writer = DiskReaderWriter(local_image_dir)
image_dir = str(os.path.basename(local_image_dir))
jso_useful_key = {"_pdf_type": "", "model_list": model_json}
pipe = UNIPipe(pdf_bytes, jso_useful_key, image_writer)
pipe.pipe_classify()
pipe.pipe_parse()
md_content = pipe.pipe_mk_markdown(image_dir, drop_mode="none")
```

###### 在对象存储上使用
```python
s3pdf_cli = S3ReaderWriter(pdf_ak, pdf_sk, pdf_endpoint)
image_dir = "s3://img_bucket/"
s3image_cli = S3ReaderWriter(img_ak, img_sk, img_endpoint, parent_path=image_dir)
pdf_bytes = s3pdf_cli.read(s3_pdf_path, mode=s3pdf_cli.MODE_BIN)
jso_useful_key = {"_pdf_type": "", "model_list": model_json}
pipe = UNIPipe(pdf_bytes, jso_useful_key, s3image_cli)
pipe.pipe_classify()
pipe.pipe_parse()
md_content = pipe.pipe_mk_markdown(image_dir, drop_mode="none")
```

117
详细实现可参考 [demo.py](demo/demo.py)
赵小蒙's avatar
赵小蒙 committed
118

myhloli's avatar
myhloli committed
119
120
121
122
123
124
125
126
127

## 版权说明

[LICENSE.md](LICENSE.md)

## 鸣谢
- [PaddleOCR](https://github.com/PaddlePaddle/PaddleOCR)
- [PyMuPDF](https://github.com/pymupdf/PyMuPDF)

赵小蒙's avatar
赵小蒙 committed
128
129
# Magic-Doc

myhloli's avatar
myhloli committed
130
131
## 简介

赵小蒙's avatar
赵小蒙 committed
132
133
134
135
136
137
138
139
140
141
142
143
144
Magic-Doc 是一款支持将网页或多格式电子书转换为 markdown 格式的工具。

主要功能包含
 
- Web网页提取
  - 跨模态精准解析图文、表格、公式信息

- 电子书文献提取
  - 支持 epub,mobi等多格式文献,文本图片全适配

- 语言类型鉴定
  - 支持176种语言的准确识别

myhloli's avatar
myhloli committed
145
146
147
148
149
150
https://github.com/opendatalab/MinerU/assets/11393164/a5a650e9-f4c0-463e-acc3-960967f1a1ca



https://github.com/opendatalab/MinerU/assets/11393164/0f4a6fe9-6cca-4113-9fdc-a537749d764d

赵小蒙's avatar
赵小蒙 committed
151
152


myhloli's avatar
myhloli committed
153
https://github.com/opendatalab/MinerU/assets/11393164/20438a02-ce6c-4af8-9dde-d722a4e825b2
赵小蒙's avatar
赵小蒙 committed
154
155


myhloli's avatar
myhloli committed
156

myhloli's avatar
myhloli committed
157
## 项目仓库
myhloli's avatar
myhloli committed
158

myhloli's avatar
myhloli committed
159
160
- [Magic-Doc](https://github.com/magicpdf/Magic-Doc)
  优秀的网页与电子书提取工具
赵小蒙's avatar
赵小蒙 committed
161