Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
wangsen
MinerU
Commits
c7a5f3a0
Commit
c7a5f3a0
authored
Jun 13, 2025
by
myhloli
Browse files
feat: update README_zh-CN with installation instructions and usage examples for MinerU
parent
087a4e00
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
119 additions
and
99 deletions
+119
-99
README_zh-CN.md
README_zh-CN.md
+119
-99
No files found.
README_zh-CN.md
View file @
c7a5f3a0
...
...
@@ -50,7 +50,6 @@
-
2025/06/13 2.0.0发布
-
MinerU 2.0 是经过完全重构的全新版本,主要包含以下重大改进:
-
**全新架构**
:MinerU 2.0 完全重构了代码架构,采用了更现代化的设计,大幅提升了易用性、可维护性和可扩展性。
-
使用pyproject.toml作为项目配置文件,支持更灵活的依赖管理和版本控制。
-
完全移除pymupdf库依赖,在开源协议友好之路上迈出了重要一步。
-
支持开箱即用,无需额外配置(json文件),将绝大部分参数开放到命令行和API参数中,用户可通过命令行或API直接配置所需功能。
-
支持模型的自动下载和更新,用户无需手动干预,模型管理更简单。
...
...
@@ -462,172 +461,193 @@ https://github.com/user-attachments/assets/4bea02c9-6d54-4cd6-97ed-dff14340982c
</tr>
</table>
##
#
在线体验
## 在线体验
[

](https://mineru.net/OpenSourceTools/Extractor?source=github)
[

](https://www.modelscope.cn/studios/OpenDataLab/MinerU)
[

](https://huggingface.co/spaces/opendatalab/MinerU)
##
#
本地部署
## 本地部署
MinerU
#### 1.安装MinerU
### 1. 安装 MinerU
#### 1.1 使用 pip 或 uv 安装
使用pip或uv安装
```
bash
pip
install
--upgrade
pip
pip
install
uv
uv pip
install
"mineru[core]>=2.0.0"
```
您也可以通过源码安装
#### 1.2 源码安装
```
bash
git clone https://github.com/opendatalab/MinerU.git
cd
MinerU
uv pip
install
-e
.[core]
```
如果您需要使用sglang加速vlm模型推理,请直接安装MinerU的完整版本
#### 1.3 安装完整版(支持 sglang 加速)
如需使用
**sglang 加速 VLM 模型推理**
,请安装完整版本:
```
bash
uv pip
install
"mineru[all]>=2.0.0"
```
或
或从源码安装:
```
bash
uv pip
install
-e
.[all]
```
#### 2.使用 MinerU
---
### 2. 使用 MinerU
####
## 命令行
####
2.1 命令行使用方式
最简单的命令行方式使用MinerU
```
commandline
##### 基础用法
最简单的命令行调用方式如下:
```
bash
mineru
-p
<input_path>
-o
<output_path>
```
其中
`<input_path>`
为本地PDF文件或目录,
`<output_path>`
为输出目录。
-
`<input_path>`
:本地 PDF 文件或目录(支持 pdf/png/jpg/jpeg)
-
`<output_path>`
:输出目录
##### 查看帮助信息
如果您需要获得更多命令行参数信息,可以使用以下命令
```
commandline
获取所有可用参数说明:
```
bash
mineru
--help
```
```
commandline
##### 参数详解
```
text
Usage: mineru [OPTIONS]
Options:
-v, --version display the version and exit
-p, --path PATH local filepath or directory. support pdf,
png, jpg, jpeg files [required]
-o, --output PATH output local directory [required]
-m, --method [auto|txt|ocr] the method for parsing pdf: auto:
Automatically determine the method based on
the file type. txt: Use text extraction
method. ocr: Use OCR method for image-based
PDFs. Without method specified, 'auto' will
be used by default. Adapted only for the
case where the backend is set to "pipeline".
-v, --version 显示版本并退出
-p, --path PATH 输入文件路径或目录(必填)
-o, --output PATH 输出目录(必填)
-m, --method [auto|txt|ocr] 解析方法:auto(默认)、txt、ocr(仅用于 pipeline 后端)
-b, --backend [pipeline|vlm-transformers|vlm-sglang-engine|vlm-sglang-client]
the backend for parsing pdf: pipeline: More
general. vlm-transformers: More general.
vlm-sglang-engine: Faster(engine). vlm-
sglang-client: Faster(client). without
method specified, pipeline will be used by
default.
-l, --lang [ch|ch_server|ch_lite|en|korean|japan|chinese_cht|ta|te|ka]
Input the languages in the pdf (if known) to
improve OCR accuracy. Optional. Without
languages specified, 'ch' will be used by
default. Adapted only for the case where the
backend is set to "pipeline".
-u, --url TEXT When the backend is `sglang-client`, you
need to specify the server_url, for
example:`http://127.0.0.1:30000`
-s, --start INTEGER The starting page for PDF parsing, beginning
from 0.
-e, --end INTEGER The ending page for PDF parsing, beginning
from 0.
-f, --formula BOOLEAN Enable formula parsing. Default is True.
Adapted only for the case where the backend
is set to "pipeline".
-t, --table BOOLEAN Enable table parsing. Default is True.
Adapted only for the case where the backend
is set to "pipeline".
-d, --device TEXT Device mode for model inference, e.g.,
"cpu", "cuda", "cuda:0", "npu", "npu:0",
"mps". Adapted only for the case where the
backend is set to "pipeline".
--vram INTEGER Upper limit of GPU memory occupied by a
single process. Adapted only for the case
where the backend is set to "pipeline".
解析后端(默认为 pipeline)
-l, --lang [ch|ch_server|... ] 指定文档语言(可提升 OCR 准确率,仅用于 pipeline 后端)
-u, --url TEXT 当使用 sglang-client 时,需指定服务地址
-s, --start INTEGER 开始解析的页码(从 0 开始)
-e, --end INTEGER 结束解析的页码(从 0 开始)
-f, --formula BOOLEAN 是否启用公式解析(默认开启,仅 pipeline 后端)
-t, --table BOOLEAN 是否启用表格解析(默认开启,仅 pipeline 后端)
-d, --device TEXT 推理设备(如 cpu/cuda/cuda:0/npu/mps,仅 pipeline 后端)
--vram INTEGER 单进程最大 GPU 显存占用(仅 pipeline 后端)
--source [huggingface|modelscope|local]
The source of the model repository. Default
is 'huggingface'.
--help Show this message and exit.
模型来源,默认 huggingface
--help 显示帮助信息
```
MinerU现已使用自动模型下载功能,默认为运行时在第一次加载时下载当前所需要的模型文件,默认使用
`huggingface`
作为模型源,如您的网络无法访问
`huggingface`
,您可以通过以下方式切换为
`modelscope`
源
```
commandline
---
#### 2.2 模型源配置
MinerU 默认在首次运行时自动从 HuggingFace 下载所需模型。若无法访问 HuggingFace,可通过以下方式切换模型源:
##### 切换至 ModelScope 源
```
bash
mineru
-p
<input_path>
-o
<output_path>
--source
modelscope
```
或使用环境变量
或设置环境变量:
```
bash
export
MINERU_MODEL_SOURCE
=
modelscope
mineru
-p
<input_path>
-o
<output_path>
```
如果您需要使用本地模型文件,请先通过命令将模型下载到本地
```
commandline
$ mineru-models-download --help
Usage: mineru-models-download [OPTIONS]
Download MinerU model files.
Supports downloading pipeline or VLM models from ModelScope or HuggingFace.
Options:
-s, --source [huggingface|modelscope]
The source of the model repository.
-m, --model_type [pipeline|vlm|all]
The type of the model to download.
--help Show this message and exit.
##### 使用本地模型
###### 1. 下载模型到本地
```
bash
mineru-models-download
--help
```
或通过交互式命令行下载模型文件
```
commandline
或使用交互式命令行工具选择模型下载:
```
bash
mineru-models-download
```
模型下载完成后,会自动将本地模型路径配置在用户目录的
`mineru.json`
中
您可以在下次执行MinerU时,直接使用本地模型文件进行解析
```
commandline
下载完成后,模型路径会在当前终端窗口输出,并自动写入用户目录下的
`mineru.json`
。
###### 2. 使用本地模型进行解析
```
bash
mineru
-p
<input_path>
-o
<output_path>
--source
local
```
或使用环境变量
或通过环境变量启用:
```
bash
export
MINERU_MODEL_SOURCE
=
local
mineru
-p
<input_path>
-o
<output_path>
```
###### 使用sglang加速的vlm模型推理
MinerU支持使用sglang加速VLM模型推理,您可以通过以下方式启用sglang加速
```
commandline
---
#### 2.3 使用 sglang 加速 VLM 模型推理
##### 启动 sglang-engine 模式
```
bash
mineru
-p
<input_path>
-o
<output_path>
-b
vlm-sglang-engine
```
同时您也可以使用sglang原生的sever/client模式进行推理
```
commandline
##### 启动 sglang-server/client 模式
1.
启动 Server:
```
bash
mineru-sglang-server
--port
30000
```
在一个终端中启动sglang server后,您可以在另一个终端中使用sglang-client进行推理
```
commandline
2.
在另一个终端中使用 Client 调用:
```
bash
mineru
-p
<input_path>
-o
<output_path>
-b
vlm-sglang-client
-u
http://127.0.0.1:30000
```
> [!TIP]
> 更多有关输出文件的信息,请参考[输出文件说明](docs/output_file_zh_cn.md)
> 💡 更多关于输出文件的信息,请参考 [输出文件说明](docs/output_file_zh_cn.md)
---
### 3. API 调用方式
您也可以通过 Python 代码调用 MinerU,示例代码请参考:
👉
[
Python 调用示例
](
demo/demo.py
)
---
### 4. 部署衍生项目
社区开发者基于 MinerU 进行了多种二次开发,包括:
##### API
-
基于 Gradio 的图形界面
-
基于 FastAPI 的 Web API
-
多卡负载均衡的客户端/服务端架构等
[
通过Python代码调用MinerU
](
demo/demo.py
)
这些项目通常提供更好的用户体验和更多功能。
##### 部署衍生项目
详细部署方式请参阅:
👉
[
衍生项目说明
](
projects/README_zh-CN.md
)
衍生项目包含项目开发者和社群开发者们基于MinerU的二次开发项目,
例如基于Gradio的应用界面、基于Fastapi的webapi、轻量级的多卡负载均衡c/s端等,
这些项目可能会提供更多的功能和更好的用户体验。
具体部署方式请参考
[
衍生项目readme
](
projects/README_zh-CN.md
)
---
# TODO
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment