README.md 1.46 KB
Newer Older
zhougaofeng's avatar
zhougaofeng committed
1
2
# magic_pdf

zhougaofeng's avatar
zhougaofeng committed
3
4
## 安装

zhougaofeng's avatar
zhougaofeng committed
5
### 以下演示在223节点安装pdf解析模块(可以直接使用镜像:1177ea7959ce)
zhougaofeng's avatar
zhougaofeng committed
6

zhougaofeng's avatar
zhougaofeng committed
7
### 1、安装需要的依赖库
zhougaofeng's avatar
zhougaofeng committed
8
下载官方的项目:
zhougaofeng's avatar
zhougaofeng committed
9
` git clone https://github.com/opendatalab/MinerU.git`
zhougaofeng's avatar
zhougaofeng committed
10
11
12
13
#### 将本项目的magic_pdf替换git clone 官方的magic_pdf
#### pip uninstall magic-pdf
#### pip install -e .

zhougaofeng's avatar
zhougaofeng committed
14
15
### 2、安装需要的模型
`git clone https://www.modelscope.cn/opendatalab/PDF-Extract-Kit.git`
zhougaofeng's avatar
zhougaofeng committed
16
17
18
19
20
21
#### 修改magic-pdf.template.json
cd MinerU
<div align=center>
    <img src="doc/image (9).png"/>
</div>
需要注意,"models-dir":"/home/practice/model/PDF-Extract-Kit/models" 路径指向PDF-Extract-Kit/models
zhougaofeng's avatar
zhougaofeng committed
22

zhougaofeng's avatar
zhougaofeng committed
23
24
25
26
27
将magic-pdf.template.json 拷贝到/root目录下并改名为magic-pdf.json
<div align=center>
    <img src="doc/image (10).png"/>
</div>
### 4、启动qwen-ocr模块:
zhougaofeng's avatar
zhougaofeng committed
28
`python magic_pdf/dict2md/ocr_server.py`
zhougaofeng's avatar
zhougaofeng committed
29
默认使用6020端口,0号DCU卡 ,可以通过--dcu_id 指定卡,--server_port指定端口号
zhougaofeng's avatar
zhougaofeng committed
30

zhougaofeng's avatar
zhougaofeng committed
31
32
33
34
35
36
qwen-ocr模块启动成功:
<div align=center>
    <img src="doc/image (5).png"/>
</div>

### 5、启动pdf-server解析服务:
zhougaofeng's avatar
zhougaofeng committed
37
`python magic_pdf/tools/pdf_server.py`
zhougaofeng's avatar
zhougaofeng committed
38
39
40
41
42
43
44
<div align=center>
    <img src="doc/image (6).png"/>
</div>
启动成功:
<div align=center>
    <img src="doc/image (7).png"/>
</div>
zhougaofeng's avatar
zhougaofeng committed
45

zhougaofeng's avatar
zhougaofeng committed
46
### 6、解析pdf
zhougaofeng's avatar
zhougaofeng committed
47
`python magic_pdf/parse/common_parse.py -p [文件/目录 路径] -o [输出地址]`
zhougaofeng's avatar
zhougaofeng committed
48
49
50
51
<div align=center>
    <img src="doc/image (8).png"/>
</div>
-p指定pdf路径,-o指定输出路径