MinerU 筆記

MinerU 用于處理pdf 屬于是工作流 最后解析成markdown+json

__version__ = "2.1.10"

##構(gòu)建虛擬環(huán)境,執(zhí)行環(huán)境路徑(空間較大),避免依賴(lài)過(guò)大
conda create -p /root/autodl-tmp/data/mineru python=3.10
conda activate /root/autodl-tmp/data/mineru

## 用git下載代碼
git clone https://github.com/opendatalab/MinerU.git
cd MinerU
## 項(xiàng)目用uv工具管理,先下個(gè)uv
pip install uv
#阿里云的源好像還沒(méi)有,換清華的
pip install uv -i https://pypi.tuna.tsinghua.edu.cn/simple
## 安裝依賴(lài)
uv pip install -e .[core] -i https://mirrors.aliyun.com/pypi/simple
#阿里云的源好像403,換清華的
uv pip install -e .[core] --index-url https://pypi.tuna.tsinghua.edu.cn/simple

#依賴(lài)超級(jí)多,貌似147個(gè)(2.1.10)   150個(gè)(3.0版本),耐心等待。



## 下載模型(也可以不執(zhí)行,執(zhí)行了會(huì)下載較多的模型,占用空間)
mineru-models-download

## 執(zhí)行命令
mineru -p /root/autodl-tmp/data/mineru/input/劉邦的簡(jiǎn)歷.pdf -o /root/autodl-tmp/data/mineru/output -d  cuda 


mineru -p /root/autodl-tmp/input/DeepSeek專(zhuān)題之企業(yè)級(jí)智能客服.pdf -o /root/autodl-tmp/output 
![image.png](https://upload-images.jianshu.io/upload_images/5047437-9d9a5a66db6c54a6.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
報(bào)錯(cuò)的話

conda install -c nvidia nccl
檢查并修復(fù) PyTorch 環(huán)境

確保 PyTorch 版本與 CUDA 匹配

pip uninstall torch torchvision torchaudio
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118 # 替換為您的 CUDA 版本

![image.png](https://upload-images.jianshu.io/upload_images/5047437-49ba264f8a43cc4d.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)


pip install pymupdf




#新版-d移除了  會(huì)自動(dòng)檢測(cè)設(shè)備  --source 也移除了   使用環(huán)境變量來(lái)設(shè)置
export MINERU_MODEL_SOURCE=modelscope

image.png

設(shè)置模型下載位置

# 創(chuàng)建模型目錄
mkdir -p /root/autodl-tmp/data/mineru/models

# 寫(xiě)入環(huán)境變量
echo 'export MODELSCOPE_CACHE=/root/autodl-tmp/data/mineru/models' >> ~/.bashrc
echo 'export MINERU_MODEL_SOURCE=modelscope' >> ~/.bashrc
source ~/.bashrc

2.1.10版本的

cd /root/autodl-tmp/MinerU/projects/multi_gpu_v2


image.png

#完成以上自定義配置后,回到服務(wù)器終端,依次執(zhí)行如下三條命令安裝LitServe服務(wù)運(yùn)行所需要的依賴(lài)環(huán)境:
pip install -U litserve python-multipart filetype
pip install paddlepaddle-gpu==3.0.0b1 -i https://www.paddlepaddle.org.cn/packages/stable/cu118

# 啟動(dòng)腳本
python server.py


3.0版本移除了litserver 內(nèi)置了自己的多gpu方案


# 單卡直接用
mineru-api --host 0.0.0.0 --port 8000

# 多卡
mineru-router --host 0.0.0.0 --port 8002 --local-gpus auto

image.png

3.0的同步方法

/file_parse

~~

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容