安装MinerU
MinerU为开源的将pdf
、word
等文档转为markdown
文件的工具
文档
安装
下载:
git clone https://github.com/opendatalab/MinerU.git
创建Conda环境
conda create -n MinerU 'python=3.12' -y
启动conda环境
conda activate MinerU
只安装pdf转markdown
pip install -U "magic-pdf[full]" -i https://mirrors.aliyun.com/pypi/simple
完整安装
pip install "mineru[all]>=2.0.0" -i https://mirrors.aliyun.com/pypi/simple
下载模型权重文件
linux下
pip install huggingface_hub
wget https://gcore.jsdelivr.net/gh/opendatalab/MinerU@master/scripts/download_models_hf.py -O download_models_hf.py
python download_models_hf.py
方式一:
pip install huggingface_hub
curl -o download_models_hf.py https://gcore.jsdelivr.net/gh/opendatalab/MinerU@master/scripts/download_models_hf.py
python download_models_hf.py
方式二:
pip install modelscope
curl -o download_models.py https://gcore.jsdelivr.net/gh/opendatalab/MinerU@master/scripts/download_models.py
python download_models.py
下载完成后,系统会自动在用户目录下生成magic-pdf.json配置文件
🪟 Windows:C:\Users\用户名
🐧 Linux:/home/用户名
🍎 macOS:/Users/用户名
新版本这种方法弃用了,已经无法下载到这个py文件了,直接运行就可以自动下载模型
使用 CUDA 加速
修改【用户目录】中配置文件 magic-pdf.json 中”device-mode”的值
{
"device-mode":"cuda"
}
覆盖安装支持cuda的torch和torchvision
CUDA11.8
pip install --force-reinstall torch==2.3.1 torchvision==0.18.1 --index-url https://download.pytorch.org/whl/cu118
CUDA12.4
pip install --force-reinstall torch==2.6.0 torchvision==0.21.1 "numpy<2.0.0" --index-url https://download.pytorch.org/whl/cu124
CUDA12.6
pip install --force-reinstall torch==2.6.0 torchvision==0.21.0 torchaudio==2.6.0 --index-url https://download.pytorch.org/whl/cu126
如果使用CUDA12.8
建议使用torch 2.7.0
开启OCR加速
pip install paddlepaddle-gpu==2.6.1
测试
如果只安装了magic-pdf
则使用以下指令
magic-pdf -p small_ocr.pdf -o ./output
完全安装
mineru -p small_ocr.pdf -o ./output
gradio_app: 基于 Gradio 的 Web 应用
pip install gradio gradio-pdf
安装easy dataset
将md文件转为json格式的数据集
文档
客户端安装
github下载:https://github.com/ConardLi/easy-dataset/releases
网盘下载:https://pan.quark.cn/s/ef8d0ef3785a
NPM 启动
下载:
git clone https://github.com/ConardLi/easy-dataset.git
cd easy-dataset
安装依赖:
npm install
编译
npm run build
启动服务器
npm run start
docker启动
下载:
git clone https://github.com/ConardLi/easy-dataset.git
cd easy-dataset
构建 Docker 镜像:
docker build -t easy-dataset .
运行容器:
docker run -d -p 1717:1717 -v {YOUR_LOCAL_DB_PATH}:/app/local-db --name easy-dataset easy-dataset
npm install时报错
删除 node_modules
目录和 package-lock.json
这是关闭赞助提示的,可以不用关闭
npm config set fund false --location=global
跳过本次安装的审计
npm install --no-audit
全局关闭审计(不推荐生产环境)
npm set audit false
重新安装
npm install