当前位置: 首页 > news >正文

将文档转为数据集

安装MinerU

MinerU为开源的将pdfword等文档转为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

相关文章:

  • FPGA内部资源介绍
  • tf serving和torch serve哪个耗时更低
  • 数据结构与算法总概
  • 鸿蒙 Grid 与 GridItem 深度解析:二维网格布局解决方案
  • 操作系统的概述之二
  • 探索钉钉生态中的宜搭:创建与分享应用的新视界
  • SpringMVC系列(六)(Restful架构风格(中))
  • 每日算法刷题Day40 6.27:leetcode前缀和3道题,用时1h20min
  • 鸿蒙5:布局组件
  • Linux环境安装Redis的多种方式分析
  • [Java 基础]LinkedList
  • 矩阵的条件数(Condition Number of a Matrix)
  • FPGA产品
  • 基于Pandas和FineBI的昆明职位数据分析与可视化实现(二)- 职位数据清洗与预处理
  • 鸿蒙5:ArkTS基本介绍
  • Qt:QCustomPlot库简介
  • 短波电台和超短波电台的区别
  • 使用Calibre对GDS进行数据遍历
  • Qt 收藏夹书签管理
  • 【区块链】区块链交易(Transaction)之nonce