DataWhale共学-向量数据库task04-MinerU部署与文本嵌入实战

58 阅读1分钟

MinerU部署教程

github地址:github.com/opendatalab…

MinerU/
├── demo/                # 用于运行转换演示的脚本
├── docker/              # 用于容器化的 Dockerfile 配置文件
├── docs/                # 存储各类说明文档
├── projects/            # 存放由 MinerU 衍生或相关的项目
│   ├── gradio_app/        # MinerU Gradio 界面的源代码
│   ├── multi_gpu/         # 为 MinerU 提供多 GPU 支持的解决方案
│   ├── web_api/           # 提供本地 Web API 接口的服务端代码
conda create -n mineru 'python=3.12' -y
conda activate mineru
pip install -U "magic-pdf[full]" -i https://mirrors.aliyun.com/pypi/simple 
#-i 是指定国内的加速源,可选清华源或阿里云源,此处用阿里云源示例

image.png

下载模型文件

官方地址:github.com/opendatalab…

方法一:从Hugging Face下载模型(国际用户推荐)

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

方法二:从ModelScope下载模型(国内用户推荐)

pip install modelscope 
curl -o download_models.py https://gcore.jsdelivr.net/gh/opendatalab/MinerU@master/scripts/download_models.py
python download_models.py

image.png

使用pip或uv安装MinerU
pip install --upgrade pip -i https://mirrors.aliyun.com/pypi/simple
pip install uv -i https://mirrors.aliyun.com/pypi/simple
uv pip install -U "mineru[core]" -i https://mirrors.aliyun.com/pypi/simple 

image.png

2.  GPU加速配置

conda activate mineru
cd ./.conda/envs/mineru

image.png

使用 MinerU

mineru -p cv.pdf -o ./output

image.png

image.png

单文件测试

cd demo
magic-pdf -p cv.pdf -o ./output2

image.png