Unverified Commit 23d83968 authored by Xiaomeng Zhao's avatar Xiaomeng Zhao Committed by GitHub
Browse files

Merge pull request #966 from opendatalab/dev

Dev to 0.9.3
parents 9581fcda d44a868a
...@@ -2,11 +2,9 @@ ...@@ -2,11 +2,9 @@
============ ============
1.在较新版本的mac上使用命令安装pip install magic-pdf[full] zsh: no matches found: magic-pdf[full] 1.在较新版本的mac上使用命令安装pip install magic-pdf[full] zsh: no matches found: magic-pdf[full]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
在 macOS 上,默认的 shell 从 Bash 切换到了 Z shell,而 Z shell 在 macOS 上,默认的 shell 从 Bash 切换到了 Z shell,而 Z shell 对于某些类型的字符串匹配有特殊的处理逻辑,这可能导致no matches found错误。 可以通过在命令行禁用globbing特性,再尝试运行安装命令
对于某些类型的字符串匹配有特殊的处理逻辑,这可能导致no matches
found错误。 可以通过在命令行禁用globbing特性,再尝试运行安装命令
.. code:: bash .. code:: bash
...@@ -14,13 +12,12 @@ found错误。 可以通过在命令行禁用globbing特性,再尝试运行安 ...@@ -14,13 +12,12 @@ found错误。 可以通过在命令行禁用globbing特性,再尝试运行安
pip install magic-pdf[full] pip install magic-pdf[full]
2.使用过程中遇到_pickle.UnpicklingError: invalid load key, ‘v’.错误 2.使用过程中遇到_pickle.UnpicklingError: invalid load key, ‘v’.错误
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
可能是由于模型文件未下载完整导致,可尝试重新下载模型文件后再试 可能是由于模型文件未下载完整导致,可尝试重新下载模型文件后再试。参考:https://github.com/opendatalab/MinerU/issues/143
参考:https://github.com/opendatalab/MinerU/issues/143
3.模型文件应该下载到哪里/models-dir的配置应该怎么填 3.模型文件应该下载到哪里/models-dir的配置应该怎么填
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
模型文件的路径输入是在”magic-pdf.json”中通过 模型文件的路径输入是在”magic-pdf.json”中通过
...@@ -30,13 +27,11 @@ found错误。 可以通过在命令行禁用globbing特性,再尝试运行安 ...@@ -30,13 +27,11 @@ found错误。 可以通过在命令行禁用globbing特性,再尝试运行安
"models-dir": "/tmp/models" "models-dir": "/tmp/models"
} }
进行配置的。 进行配置的。这个路径是绝对路径而不是相对路径,绝对路径的获取可在models目录中通过命令 “pwd” 获取。
这个路径是绝对路径而不是相对路径,绝对路径的获取可在models目录中通过命令
“pwd” 获取。
参考:https://github.com/opendatalab/MinerU/issues/155#issuecomment-2230216874 参考:https://github.com/opendatalab/MinerU/issues/155#issuecomment-2230216874
4.在WSL2的Ubuntu22.04中遇到报错\ ``ImportError: libGL.so.1: cannot open shared object file: No such file or directory`` 4.在WSL2的Ubuntu22.04中遇到报错\ ``ImportError: libGL.so.1: cannot open shared object file: No such file or directory``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
WSL2的Ubuntu22.04中缺少\ ``libgl``\ 库,可通过以下命令安装\ ``libgl``\ 库解决: WSL2的Ubuntu22.04中缺少\ ``libgl``\ 库,可通过以下命令安装\ ``libgl``\ 库解决:
...@@ -47,7 +42,7 @@ WSL2的Ubuntu22.04中缺少\ ``libgl``\ 库,可通过以下命令安装\ ``lib ...@@ -47,7 +42,7 @@ WSL2的Ubuntu22.04中缺少\ ``libgl``\ 库,可通过以下命令安装\ ``lib
参考:https://github.com/opendatalab/MinerU/issues/388 参考:https://github.com/opendatalab/MinerU/issues/388
5.遇到报错 ``ModuleNotFoundError : Nomodulenamed 'fairscale'`` 5.遇到报错 ``ModuleNotFoundError : Nomodulenamed 'fairscale'``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
需要卸载该模块并重新安装 需要卸载该模块并重新安装
...@@ -59,7 +54,7 @@ WSL2的Ubuntu22.04中缺少\ ``libgl``\ 库,可通过以下命令安装\ ``lib ...@@ -59,7 +54,7 @@ WSL2的Ubuntu22.04中缺少\ ``libgl``\ 库,可通过以下命令安装\ ``lib
参考:https://github.com/opendatalab/MinerU/issues/411 参考:https://github.com/opendatalab/MinerU/issues/411
6.在部分较新的设备如H100上,使用CUDA加速OCR时解析出的文字乱码。 6.在部分较新的设备如H100上,使用CUDA加速OCR时解析出的文字乱码。
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cuda11对新显卡的兼容性不好,需要升级paddle使用的cuda版本 cuda11对新显卡的兼容性不好,需要升级paddle使用的cuda版本
...@@ -70,9 +65,8 @@ cuda11对新显卡的兼容性不好,需要升级paddle使用的cuda版本 ...@@ -70,9 +65,8 @@ cuda11对新显卡的兼容性不好,需要升级paddle使用的cuda版本
参考:https://github.com/opendatalab/MinerU/issues/558 参考:https://github.com/opendatalab/MinerU/issues/558
7.在部分Linux服务器上,程序一运行就报错 ``非法指令 (核心已转储)`` 或 ``Illegal instruction (core dumped)`` 7.在部分Linux服务器上,程序一运行就报错 ``非法指令 (核心已转储)`` 或 ``Illegal instruction (core dumped)``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
可能是因为服务器CPU不支持AVX/AVX2指令集,或cpu本身支持但被运维禁用了,可以尝试联系运维解除限制或更换服务器。 可能是因为服务器CPU不支持AVX/AVX2指令集,或cpu本身支持但被运维禁用了,可以尝试联系运维解除限制或更换服务器。
参考:https://github.com/opendatalab/MinerU/issues/591 , 参考:https://github.com/opendatalab/MinerU/issues/591 ,https://github.com/opendatalab/MinerU/issues/736
https://github.com/opendatalab/MinerU/issues/736
...@@ -73,6 +73,8 @@ S3DataReader 基于 MultiBucketS3DataReader 构建,但仅支持单个桶。S3D ...@@ -73,6 +73,8 @@ S3DataReader 基于 MultiBucketS3DataReader 构建,但仅支持单个桶。S3D
--------- ---------
.. code:: python .. code:: python
from magic_pdf.data.data_reader_writer import *
# 文件相关的 # 文件相关的
file_based_reader1 = FileBasedDataReader('') file_based_reader1 = FileBasedDataReader('')
...@@ -126,6 +128,8 @@ S3DataReader 基于 MultiBucketS3DataReader 构建,但仅支持单个桶。S3D ...@@ -126,6 +128,8 @@ S3DataReader 基于 MultiBucketS3DataReader 构建,但仅支持单个桶。S3D
---------- ----------
.. code:: python .. code:: python
from magic_pdf.data.data_reader_writer import *
# 文件相关的 # 文件相关的
file_based_writer1 = FileBasedDataWriter('') file_based_writer1 = FileBasedDataWriter('')
......
...@@ -15,6 +15,8 @@ read_jsonl ...@@ -15,6 +15,8 @@ read_jsonl
.. code:: python .. code:: python
from magic_pdf.data.io.read_api import *
# 从本地机器读取 JSONL # 从本地机器读取 JSONL
datasets = read_jsonl("tt.jsonl", None) datasets = read_jsonl("tt.jsonl", None)
...@@ -28,6 +30,8 @@ read_local_pdfs ...@@ -28,6 +30,8 @@ read_local_pdfs
.. code:: python .. code:: python
from magic_pdf.data.io.read_api import *
# 读取 PDF 路径 # 读取 PDF 路径
datasets = read_local_pdfs("tt.pdf") datasets = read_local_pdfs("tt.pdf")
...@@ -41,6 +45,8 @@ read_local_images ...@@ -41,6 +45,8 @@ read_local_images
.. code:: python .. code:: python
from magic_pdf.data.io.read_api import *
# 从图像路径读取 # 从图像路径读取
datasets = read_local_images("tt.png") datasets = read_local_images("tt.png")
......
...@@ -5,39 +5,44 @@ ...@@ -5,39 +5,44 @@
- :ref:`ubuntu_22_04_lts_section` - :ref:`ubuntu_22_04_lts_section`
- :ref:`windows_10_or_11_section` - :ref:`windows_10_or_11_section`
- 使用 Docker 快速部署
.. admonition:: Important .. admonition:: Important
:class: warning :class: tip
使用 Docker 快速部署 > Docker 需要至少 16GB 显存的 GPU,并且所有加速功能默认启用。 Docker 需要至少 16GB 显存的 GPU,并且所有加速功能默认启用。
在运行此 Docker 容器之前,您可以使用以下命令检查您的设备是否支持 Docker 上的 CUDA 加速。
在运行此 Docker 容器之前,您可以使用以下命令检查您的设备是否支持 Docker 上的 CUDA 加速。
.. code-block:: sh .. code-block:: sh
bash docker run --rm --gpus=all nvidia/cuda:12.1.0-base-ubuntu22.04 nvidia-smi docker run --rm --gpus=all nvidia/cuda:12.1.0-base-ubuntu22.04 nvidia-smi
.. code:: sh .. code:: sh
wget https://github.com/opendatalab/MinerU/raw/master/Dockerfile wget https://github.com/opendatalab/MinerU/raw/master/Dockerfile
docker build -t mineru:latest . docker build -t mineru:latest .
docker run --rm -it --gpus=all mineru:latest /bin/bash docker run --rm -it --gpus=all mineru:latest /bin/bash
magic-pdf --help magic-pdf --help
.. _ubuntu_22_04_lts_section: .. _ubuntu_22_04_lts_section:
Ubuntu 22.04 LT Ubuntu 22.04 LTS
---------------- ----------------
1. 检测是否已安装 nvidia 驱动
---------------------------
1.检查 NVIDIA 驱动程序是否已安装 .. code:: bash
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. code:: sh
nvidia-smi nvidia-smi
如果看到类似下的信息,则表示 NVIDIA 驱动程序已安装,可以跳过第 2 步。 如果看到类似下的信息,说明已经安装了 nvidia 驱动,可以跳过步骤2
注意:“CUDA 版本”应 >= 12.1,如果显示的版本号小于 12.1,请升级驱动程序。 .. admonition:: Important
:class: tip
``CUDA Version`` 显示的版本号应 >=12.1,如显示的版本号小于12.1,请升级驱动
.. code:: text .. code:: text
...@@ -53,190 +58,211 @@ Ubuntu 22.04 LT ...@@ -53,190 +58,211 @@ Ubuntu 22.04 LT
| | | N/A | | | | N/A |
+-----------------------------------------+----------------------+----------------------+ +-----------------------------------------+----------------------+----------------------+
2. 安装驱动
-----------
2. 安装驱动程序 如没有驱动,则通过如下命令
~~~~~~~~~~~~~~~~~~~~~
如果没有安装驱动程序,请使用以下命令:
.. code:: sh .. code:: bash
sudo apt-get update sudo apt-get update
sudo apt-get install nvidia-driver-545 sudo apt-get install nvidia-driver-545
安装专有驱动程序并在安装后重启计算机。 安装专有驱动,安装完成后,重启电脑
.. code:: sh .. code:: bash
reboot reboot
3. 安装 Anaconda 3. 安装 anacoda
~~~~~~~~~~~~~~~~~~ --------------
如果已安装了 Anaconda,跳过步骤 如果已安装 conda,可以跳过步骤
.. code:: sh .. code:: bash
wget https://repo.anaconda.com/archive/Anaconda3-2024.06-1-Linux-x86_64.sh wget -U NoSuchBrowser/1.0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/Anaconda3-2024.06-1-Linux-x86_64.sh
bash Anaconda3-2024.06-1-Linux-x86_64.sh bash Anaconda3-2024.06-1-Linux-x86_64.sh
最后一步输入 ``yes``,关闭终端重新打开 最后一步输入yes,关闭终端重新打开
4. 使用 Conda 创建环境 4. 使用 conda 创建环境
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ---------------------
指定 Python 版本为 3.10 指定 python 版本为3.10
.. code:: sh .. code:: bash
conda create -n MinerU python=3.10 conda create -n MinerU python=3.10
conda activate MinerU conda activate MinerU
5. 安装应用程序 5. 安装应用
~~~~~~~~~~~~~~~~~~~~~~~ -----------
.. code:: sh .. code:: bash
pip install -U magic-pdf[full] --extra-index-url https://wheels.myhloli.com pip install -U magic-pdf[full] --extra-index-url https://wheels.myhloli.com -i https://mirrors.aliyun.com/pypi/simple
❗ 安装完成后,请确保使用以下命令检查 ``magic-pdf`` 的版本: .. admonition:: Important
:class: tip
.. code:: sh 下载完成后,务必通过以下命令确认magic-pdf的版本是否正确
magic-pdf --version .. code:: bash
如果版本号小于 0.7.0,请报告问题。 magic-pdf --version
如果版本号小于0.7.0,请到issue中向我们反馈
6. 下载模型 6. 下载模型
~~~~~~~~~~~~~~~~~~ -----------
参考详细说明 :doc:`下载模型权重文件 <download_model_weight_files>` 详细参考 :doc:`download_model_weight_files`
7. 了解配置文件的位置 7. 了解配置文件存放的位置
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -------------------------
完成 `6. 下载模型 <#6-download-models>`__ 步骤后,脚本自动用户目录中生成一个 ``magic-pdf.json`` 文件并配置默认模型路径。您可在用户目录中找到 ``magic-pdf.json`` 文件。 完成\ `6.下载模型 <#6-下载模型>`__\ 步骤后,脚本自动生成用户目录下的magic-pdf.json文件,并自动配置默认模型路径。您可在用户目录】下找到magic-pdf.json文件。
Linux 用户目录是 “/home/用户名”。 .. admonition:: Tip
:class: tip
8. 首次运行 linux用户目录为 “/home/用户名”
~~~~~~~~~~~~
从仓库下载示例文件并测试它。 8. 第一次运行
-------------
.. code:: sh 从仓库中下载样本文件,并测试
.. code:: bash
wget https://github.com/opendatalab/MinerU/raw/master/demo/small_ocr.pdf wget https://gitee.com/myhloli/MinerU/raw/master/demo/small_ocr.pdf
magic-pdf -p small_ocr.pdf -o ./output magic-pdf -p small_ocr.pdf -o ./output
9. 测试 CUDA 加速 9. 测试CUDA加速
~~~~~~~~~~~~~~~~~~~~~~~~~ ---------------
如果您的显卡至少有 **8GB** 显存,请按照以下步骤测试 CUDA 加速: 如果您的显卡显存大于等于 **8GB**
,可以进行以下流程,测试CUDA解析加速效果
1. 修改位于用户目录中的 ``magic-pdf.json`` 配置文件中的 ``"device-mode"`` 值。 **1.修改用户目录】中配置文件 magic-pdf.json 中”device-mode”的值**
.. code:: json .. code:: json
{
"device-mode":"cuda"
}
**2.运行以下命令测试 cuda 加速效果**
.. code:: bash
magic-pdf -p small_ocr.pdf -o ./output
.. admonition:: Tip
:class: tip
{ CUDA 加速是否生效可以根据 log 中输出的各个阶段 cost 耗时来简单判断,通常情况下, ``layout detection cost`` 和 ``mfr time`` 应提速10倍以上。
"device-mode": "cuda"
}
2. 使用以下命令测试 CUDA 加速: 10. 为 ocr 开启 cuda 加速
---------------------
.. code:: sh **1.下载paddlepaddle-gpu, 安装完成后会自动开启ocr加速**
magic-pdf -p small_ocr.pdf -o ./output .. code:: bash
10. 启用 OCR 的 CUDA 加速 python -m pip install paddlepaddle-gpu==3.0.0b1 -i https://www.paddlepaddle.org.cn/packages/stable/cu118/
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1. 下载 ``paddlepaddle-gpu``。安装将自动启用 OCR 加速。 **2.运行以下命令测试ocr加速效果**
.. code:: sh .. code:: bash
python -m pip install paddlepaddle-gpu==3.0.0b1 -i https://www.paddlepaddle.org.cn/packages/stable/cu118/ magic-pdf -p small_ocr.pdf -o ./output
2. 使用以下命令测试 OCR 加速: .. admonition:: Tip
:class: tip
.. code:: sh CUDA 加速是否生效可以根据 log 中输出的各个阶段 cost 耗时来简单判断,通常情况下, ``ocr cost`` 应提速10倍以上。
magic-pdf -p small_ocr.pdf -o ./output
.. _windows_10_or_11_section: .. _windows_10_or_11_section:
Windows 10/11 Windows 10/11
-------------- --------------
1. 安装 CUDA 和 cuDNN 1. 安装 cuda 和 cuDNN
~~~~~~~~~~~~~~~~~~~~~~~~~ ------------------
需版本CUDA 11.8 + cuDNN 8.7.0 要安装的版本 CUDA 11.8 + cuDNN 8.7.0
- CUDA 11.8: https://developer.nvidia.com/cuda-11-8-0-download-archive - CUDA 11.8 https://developer.nvidia.com/cuda-11-8-0-download-archive
- cuDNN v8.7.0(2022年11月28日发布),适用于 CUDA 11.x: - cuDNN v8.7.0 (November 28th, 2022), for CUDA 11.x https://developer.nvidia.com/rdp/cudnn-archive
https://developer.nvidia.com/rdp/cudnn-archive
2. 安装 Anaconda 2. 安装 anaconda
~~~~~~~~~~~~~~~~~~ ---------------
如果已安装了 Anaconda,可以跳过步骤 如果已安装 conda,可以跳过步骤
下载链接:https://repo.anaconda.com/archive/Anaconda3-2024.06-1-Windows-x86_64.exe 下载链接:https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/Anaconda3-2024.06-1-Windows-x86_64.exe
3. 使用 Conda 创建环境 3. 使用 conda 创建环境
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ---------------------
Python 版本必须是 3.10 需指定python版本3.10
:: .. code:: bash
conda create -n MinerU python=3.10 conda create -n MinerU python=3.10
conda activate MinerU conda activate MinerU
4. 安装应用程序 4. 安装应用
~~~~~~~~~~~~~~~~~~~~~~~ -----------
.. code:: bash .. code:: bash
pip install -U magic-pdf[full] --extra-index-url https://wheels.myhloli.com pip install -U magic-pdf[full] --extra-index-url https://wheels.myhloli.com -i https://mirrors.aliyun.com/pypi/simple
.. admonition:: Important
:class: tip
❗️安装完成后,请验证 ``magic-pdf`` 的版本: 下载完成后,务必通过以下命令确认magic-pdf的版本是否正确
.. code:: bash .. code:: bash
magic-pdf --version magic-pdf --version
如果版本号小于 0.7.0,请在问题部分报告。 如果版本号小于0.7.0,请到issue中向我们反馈
5. 下载模型 5. 下载模型
~~~~~~~~~~~~~~~~~~ -----------
详细参考 :doc:`download_model_weight_files`
参考详细说明 :doc:`下载模型权重文件 <download_model_weight_files>` 6. 了解配置文件存放的位置
-------------------------
6. 了解配置文件的位置 完成\ `5.下载模型 <#5-下载模型>`__\ 步骤后,脚本会自动生成用户目录下的magic-pdf.json文件,并自动配置默认模型路径。您可在【用户目录】下找到 magic-pdf.json 文件。
~~~~~~~~~~~~~~~~~~~~
完成 `5. 下载模型 <#5-download-models>__` 步骤后,脚本将自动在用户目录中生成一个 magic-pdf.json 文件并配置默认模型路径。您可以在【用户目录】中找到 magic-pdf.json 文件。 .. admonition:: Tip
:class: tip
Windows 用户目录 “C:/Users/用户名” windows 用户目录 “C:/Users/用户名”
7. 次运行 7. 第一次运行
~~~~~~~~~~ -------------
从仓库下载示例文件并测试它。 从仓库下载样本文件并测试
.. code:: powershell .. code:: powershell
wget https://github.com/opendatalab/MinerU/raw/master/demo/small_ocr.pdf -O small_ocr.pdf wget https://github.com/opendatalab/MinerU/raw/master/demo/small_ocr.pdf -O small_ocr.pdf
magic-pdf -p small_ocr.pdf -o ./output magic-pdf -p small_ocr.pdf -o ./output
8. 测试CUDA加速 8. 测试 CUDA 加速
~~~~~~~~~~~~~~~~ ---------------
如果您的显卡显存大于等于 **8GB** 如果您的显卡显存大于等于 **8GB**,可以进行以下流程,测试 CUDA 解析加速效果
,可以进行以下流程,测试CUDA解析加速效果
**1.覆盖安装支持cuda的torch和torchvision** **1.覆盖安装支持cuda的torch和torchvision**
...@@ -244,15 +270,16 @@ Windows 用户目录是 “C:/Users/用户名”。 ...@@ -244,15 +270,16 @@ Windows 用户目录是 “C:/Users/用户名”。
pip install --force-reinstall torch==2.3.1 torchvision==0.18.1 --index-url https://download.pytorch.org/whl/cu118 pip install --force-reinstall torch==2.3.1 torchvision==0.18.1 --index-url https://download.pytorch.org/whl/cu118
.. .. admonition:: Important
:class: tip
❗️务必在命令中指定以下版本 务必在命令中指定以下版本
.. code:: bash .. code:: bash
torch==2.3.1 torchvision==0.18.1 torch==2.3.1 torchvision==0.18.1
这是我们支持的最高版本,如果不指定版本会自动安装更高版本导致程序无法运行 这是我们支持的最高版本,如果不指定版本会自动安装更高版本导致程序无法运行
**2.修改【用户目录】中配置文件magic-pdf.json中”device-mode”的值** **2.修改【用户目录】中配置文件magic-pdf.json中”device-mode”的值**
...@@ -268,13 +295,13 @@ Windows 用户目录是 “C:/Users/用户名”。 ...@@ -268,13 +295,13 @@ Windows 用户目录是 “C:/Users/用户名”。
magic-pdf -p small_ocr.pdf -o ./output magic-pdf -p small_ocr.pdf -o ./output
.. .. admonition:: Tip
:class: tip
提示:CUDA加速是否生效可以根据log中输出的各个阶段的耗时来简单判断,通常情况下,\ ``layout detection time`` CUDA 加速是否生效可以根据 log 中输出的各个阶段的耗时来简单判断,通常情况下, ``layout detection time`` 和 ``mfr time`` 应提速10倍以上。
和 ``mfr time`` 应提速10倍以上。
9. 为ocr开启cuda加速 9. 为 ocr 开启 cuda 加速
~~~~~~~~~~~~~~~~~~~~~~~ --------------------
**1.下载paddlepaddle-gpu, 安装完成后会自动开启ocr加速** **1.下载paddlepaddle-gpu, 安装完成后会自动开启ocr加速**
...@@ -288,6 +315,7 @@ Windows 用户目录是 “C:/Users/用户名”。 ...@@ -288,6 +315,7 @@ Windows 用户目录是 “C:/Users/用户名”。
magic-pdf -p small_ocr.pdf -o ./output magic-pdf -p small_ocr.pdf -o ./output
.. .. admonition:: Tip
:class: tip
提示:CUDA加速是否生效可以根据log中输出的各个阶段cost耗时来简单判断,通常情况下,\ ``ocr time``\ 应提速10倍以上。 CUDA 加速是否生效可以根据 log 中输出的各个阶段 cost 耗时来简单判断,通常情况下, ``ocr time`` 应提速10倍以上。
下载模型权重文件 下载模型权重文件
=============== ==================
模型下载分为初始下载和更新到模型目录。请参考相应的文档以获取如何操作的指示。 模型下载分为初始下载和更新到模型目录。请参考相应的文档以获取如何操作的指示。
初始下载模型文件 首次下载模型文件
-------------- -----------------
从 Hugging Face 下载模型
模型文件可以从 Hugging Face 或 Model Scope下载,由于网络原因,国内用户访问HF可能会失败,请使用 ModelScope。
使用 Python 脚本从 Hugging Face 下载模型文件
方法一:从 Hugging Face 下载模型
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
使用python脚本 从Hugging Face下载模型文件
.. code:: bash .. code:: bash
pip install huggingface_hub pip install huggingface_hub
wget https://github.com/opendatalab/MinerU/raw/master/scripts/download_models_hf.py -O download_models_hf.py wget https://gitee.com/myhloli/MinerU/raw/master/scripts/download_models_hf.py -O download_models_hf.py
python download_models_hf.py python download_models_hf.py
该 Python 脚本将自动下载模型文件,并在配置文件中配置模型目录。 python脚本会自动下载模型文件并配置好配置文件中的模型目录
方法二:从 ModelScope 下载模型
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
使用python脚本从 ModelScope 下载模型文件
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. code:: bash
pip install modelscope
wget https://gitee.com/myhloli/MinerU/raw/master/scripts/download_models.py -O download_models.py
python download_models.py
python脚本会自动下载模型文件并配置好配置文件中的模型目录
配置文件可以在用户目录中找到,文件名为\ ``magic-pdf.json``
.. admonition:: Tip
:class: tip
windows的用户目录为 “C:\Users\用户名”, linux用户目录为 “/home/用户名”, macOS用户目录为 “/Users/用户名”
此前下载过模型,如何更新
--------------------
配置文件可以在用户目录中找到,文件名为 ``magic-pdf.json``。 1. 通过 git lfs 下载过模型
^^^^^^^^^^^^^^^^^^^^^^^
如何更新先前下载的模型 .. admonition:: Important
----------------------------------------- :class: tip
1. 通过 Git LFS 下载的模型 由于部分用户反馈通过git lfs下载模型文件遇到下载不全和模型文件损坏情况,现已不推荐使用该方式下载。
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
由于一些用户的反馈指出使用 git lfs 下载模型文件会出现不完整或导致模型文件损坏的情况,因此不再推荐使用这种方法 0.9.x及以后版本由于PDF-Extract-Kit 1.0更换仓库和新增layout排序模型,不能通过 ``git pull``\命令更新,需要使用python脚本一键更新
如果您之前通过 git lfs 下载模型文件,可以导航到之前的下载目录并使用 ``git pull`` 命令更新模型。 当magic-pdf <= 0.8.1时,如此前通过 git lfs 下载模型文件,可以进入到之前的下载目录中,通过 ``git pull`` 命令更新模型。
2. 通过 Hugging Face 或 ModelScope 下载模型 2. 通过 Hugging Face 或 Model Scope 下载模型
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
如果您之前通过 Hugging Face 或 ModelScope 下载了模型,您可以重新运行用于初始下载的 Python 脚本。这将自动将模型目录更新到最新版本。 如此前通过 HuggingFace 或 Model Scope 下载过模型,可以重复执行此前的模型下载 python 脚本,将会自动将模型目录更新到最新版本。
\ No newline at end of file \ No newline at end of file
...@@ -4,15 +4,16 @@ ...@@ -4,15 +4,16 @@
如果您遇到任何安装问题,请首先查阅 :doc:`../../additional_notes/faq`。如果解析结果不如预期,可参考 :doc:`../../additional_notes/known_issues`。 如果您遇到任何安装问题,请首先查阅 :doc:`../../additional_notes/faq`。如果解析结果不如预期,可参考 :doc:`../../additional_notes/known_issues`。
预安装须知—硬件和软件环境支持 .. admonition:: Warning
----------------------------- :class: tip
为了确保项目的稳定性和可靠性,在开发过程中我们仅对特定的硬件和软件环境进行了优化和测试。这确保了在推荐系统配置上部署和运行项目的用户能够获得最佳性能,并且兼容性问题最少。 **安装前必看——软硬件环境支持说明**
通过将资源集中在主线环境中,我们的团队可以更高效地解决潜在的错误并开发新功能 为了确保项目的稳定性和可靠性,我们在开发过程中仅对特定的软硬件环境进行优化和测试。这样当用户在推荐的系统配置上部署和运行项目时,能够获得最佳的性能表现和最少的兼容性问题
在非主线环境中,由于硬件和软件配置的多样性以及第三方依赖项的兼容性问题,我们无法保证100%的项目可用性。因此,对于希望在非推荐环境中使用该项目的用户,我们建议首先仔细阅读文档和常见问题解答。大多数问题在常见问题解答中已经有相应的解决方案。我们也鼓励社区反馈,以帮助我们逐步扩大支持 通过集中资源和精力于主线环境,我们团队能够更高效地解决潜在的BUG,及时开发新功能
在非主线环境中,由于硬件、软件配置的多样性,以及第三方依赖项的兼容性问题,我们无法100%保证项目的完全可用性。因此,对于希望在非推荐环境中使用本项目的用户,我们建议先仔细阅读文档以及 :doc:`../../additional_notes/faq` ,大多数问题已经在 :doc:`../../additional_notes/faq` 中有对应的解决方案,除此之外我们鼓励社区反馈问题,以便我们能够逐步扩大支持范围。
.. raw:: html .. raw:: html
...@@ -80,7 +81,7 @@ ...@@ -80,7 +81,7 @@
conda create -n MinerU python=3.10 conda create -n MinerU python=3.10
conda activate MinerU conda activate MinerU
pip install -U magic-pdf[full] --extra-index-url https://wheels.myhloli.com pip install -U magic-pdf[full] --extra-index-url https://wheels.myhloli.com -i https://mirrors.aliyun.com/pypi/simple
下载模型权重文件 下载模型权重文件
...@@ -89,8 +90,9 @@ ...@@ -89,8 +90,9 @@
.. code-block:: shell .. code-block:: shell
pip install huggingface_hub pip install huggingface_hub
wget https://github.com/opendatalab/MinerU/raw/master/scripts/download_models_hf.py -O download_models_hf.py wget https://gitee.com/myhloli/MinerU/raw/master/scripts/download_models_hf.py -O download_models_hf.py
python download_models_hf.py python download_models_hf.py
MinerU 已安装,查看 :doc:`../quick_start` 或阅读 :doc:`boost_with_cuda` 以加速推理。 MinerU 已安装,查看 :doc:`../quick_start` 或阅读 :doc:`boost_with_cuda` 以加速推理。
...@@ -49,5 +49,5 @@ ...@@ -49,5 +49,5 @@
md_writer.write_string(f"{pdf_file_name}.md", md_content) md_writer.write_string(f"{pdf_file_name}.md", md_content)
前去 :doc:`../data/data_reader_writer` 获取更多有关**读写**示例 前去 :doc:`../data/data_reader_writer` 获取更多有关 **读写** 示例
...@@ -191,7 +191,7 @@ if __name__ == "__main__": ...@@ -191,7 +191,7 @@ if __name__ == "__main__":
gr.HTML(header) gr.HTML(header)
with gr.Row(): with gr.Row():
with gr.Column(variant='panel', scale=5): with gr.Column(variant='panel', scale=5):
file = gr.File(label="Please upload a PDF or image", file_types=[".pdf", ".png", ".jpeg", "jpg"]) file = gr.File(label="Please upload a PDF or image", file_types=[".pdf", ".png", ".jpeg", ".jpg"])
max_pages = gr.Slider(1, 10, 5, step=1, label="Max convert pages") max_pages = gr.Slider(1, 10, 5, step=1, label="Max convert pages")
with gr.Row(): with gr.Row():
layout_mode = gr.Dropdown(["layoutlmv3", "doclayout_yolo"], label="Layout model", value="layoutlmv3") layout_mode = gr.Dropdown(["layoutlmv3", "doclayout_yolo"], label="Layout model", value="layoutlmv3")
......
...@@ -12,7 +12,11 @@ matplotlib ...@@ -12,7 +12,11 @@ matplotlib
ultralytics ultralytics
paddleocr==2.7.3 paddleocr==2.7.3
paddlepaddle==3.0.0b1 paddlepaddle==3.0.0b1
pypandoc struct-eqtable==0.3.2
struct-eqtable==0.1.0 einops
accelerate
doclayout_yolo==0.0.2
rapidocr-paddle
rapid_table
doclayout-yolo==0.0.2 doclayout-yolo==0.0.2
detectron2 detectron2
...@@ -45,7 +45,7 @@ if __name__ == '__main__': ...@@ -45,7 +45,7 @@ if __name__ == '__main__':
print(f'model_dir is: {model_dir}') print(f'model_dir is: {model_dir}')
print(f'layoutreader_model_dir is: {layoutreader_model_dir}') print(f'layoutreader_model_dir is: {layoutreader_model_dir}')
json_url = 'https://gitee.com/myhloli/MinerU/raw/dev/magic-pdf.template.json' json_url = 'https://gitee.com/myhloli/MinerU/raw/master/magic-pdf.template.json'
config_file_name = 'magic-pdf.json' config_file_name = 'magic-pdf.json'
home_dir = os.path.expanduser('~') home_dir = os.path.expanduser('~')
config_file = os.path.join(home_dir, config_file_name) config_file = os.path.join(home_dir, config_file_name)
......
...@@ -52,7 +52,7 @@ if __name__ == '__main__': ...@@ -52,7 +52,7 @@ if __name__ == '__main__':
print(f'model_dir is: {model_dir}') print(f'model_dir is: {model_dir}')
print(f'layoutreader_model_dir is: {layoutreader_model_dir}') print(f'layoutreader_model_dir is: {layoutreader_model_dir}')
json_url = 'https://github.com/opendatalab/MinerU/raw/dev/magic-pdf.template.json' json_url = 'https://github.com/opendatalab/MinerU/raw/master/magic-pdf.template.json'
config_file_name = 'magic-pdf.json' config_file_name = 'magic-pdf.json'
home_dir = os.path.expanduser('~') home_dir = os.path.expanduser('~')
config_file = os.path.join(home_dir, config_file_name) config_file = os.path.join(home_dir, config_file_name)
......
...@@ -47,6 +47,9 @@ if __name__ == '__main__': ...@@ -47,6 +47,9 @@ if __name__ == '__main__':
"einops", # struct-eqtable依赖 "einops", # struct-eqtable依赖
"accelerate", # struct-eqtable依赖 "accelerate", # struct-eqtable依赖
"doclayout_yolo==0.0.2", # doclayout_yolo "doclayout_yolo==0.0.2", # doclayout_yolo
"rapidocr-paddle", # rapidocr-paddle
"rapid_table", # rapid_table
"PyYAML", # yaml
"detectron2" "detectron2"
], ],
}, },
......
scihub/scihub_00500000/libgen.scimag00527000-00527999.zip_10.1002/app.25178
scihub/scihub_07400000/libgen.scimag07481000-07481999.zip_10.1007/s003960050343
scihub/scihub_11400000/libgen.scimag11451000-11451999.zip_10.1017/s0009838811000231
scihub/scihub_24400000/libgen.scimag24401000-24401999.zip_10.1016/j.toxicon.2014.02.018
scihub/scihub_27400000/libgen.scimag27441000-27441999.zip_10.2307/30122482
scihub/scihub_28400000/libgen.scimag28413000-28413999.zip_10.2307/1316224
scihub/scihub_31200000/libgen.scimag31207000-31207999.zip_10.1080/03639040600920622
scihub/scihub_31800000/libgen.scimag31824000-31824999.zip_10.1109/med.2012.6265668
scihub/scihub_32500000/libgen.scimag32539000-32539999.zip_10.1080/09540121003721000
scihub/scihub_42500000/libgen.scimag42522000-42522999.zip_10.1016/S1365-6937(15)30162-3
scihub/scihub_45900000/libgen.scimag45914000-45914999.zip_10.1055/s-0030-1256333
scihub/scihub_50900000/libgen.scimag50902000-50902999.zip_10.1007/s12274-016-1035-8
scihub/scihub_63900000/libgen.scimag63921000-63921999.zip_10.1063/1.4938050
scihub/scihub_65800000/libgen.scimag65832000-65832999.zip_10.1016/s0166-4115(08)62165-2
scihub/scihub_67300000/libgen.scimag67369000-67369999.zip_10.1096/fj.201700997R
scihub/scihub_67900000/libgen.scimag67967000-67967999.zip_10.1038/s41598-018-21867-z
scihub/scihub_77400000/libgen.scimag77447000-77447999.zip_10.1016/j.jid.2019.06.094
{
"pageID_imageBboxs": [
[
[
37.5,
651.3200073242188,
557.5,
790.8300170898438
]
],
[
[
69,
771,
119,
789
]
],
[],
[
[
152.16000366210938,
188.3996124267578,
458.8800048828125,
330.4796142578125
],
[
200.57258064516128,
499.0322580645161,
339.67863247863244,
627.5418803418803
]
],
[
[
88.29032258064515,
246.63709677419354,
288.822792022792,
608.8307692307692
]
],
[
[
168.42338709677418,
118.04032258064515,
439.9509971509971,
246.60284900284898
],
[
155.94758064516128,
341.1653225806451,
452.4250712250712,
434.67350427350425
]
],
[],
[]
],
"pageID_tableBboxs": [
[],
[],
[],
[],
[],
[
[
71.9758064516129,
534.0604838709677,
520.5527065527065,
717.7390313390313
]
],
[
[
71.01612903225806,
296.5403225806451,
525.3504273504273,
392.45356125356125
],
[
79.17338709677419,
503.8306451612903,
517.674074074074,
736.4501424501424
]
],
[]
],
"pageID_equationBboxs": [
[],
[],
[
[
247.59677419354836,
511.9879032258064,
524.8706552706552,
525.8301994301994
],
[
222.16532258064515,
588.7620967741935,
524.3908831908832,
608.8307692307692
]
],
[],
[],
[],
[],
[]
]
}
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
{
"page_0":{
"para_blocks": [
{
"block_id": 0,
"bbox": [39.0, 34.719993591308594, 347.1359558105469, 51.2079963684082],
"text": "IOP Conference Series: Earth and Environmental Science",
"dir": [1.0, 0.0],
"X0": 39.0,
"X1": 347.1359558105469,
"avg_char_width": 6.4194990793863935,
"avg_char_height": 16.48800277709961,
"block_font_type": "Helvetica",
"block_font_size": 12.0,
"is_segmented": 1,
"paras": [
{
"para_id": 0,
"bbox": [39.0, 34.719993591308594, 347.1359558105469, 51.2079963684082],
"text": "IOP Conference Series: Earth and Environmental Science",
"is_matched": 1,
"is_title": 0,
"font_type": "Helvetica",
"font_size": 12.0,
"font_color": 0,
"neighbor_paras": [null, null]
}
],
"bboxes_para": [[39.0, 34.719993591308594, 347.1359558105469, 51.2079963684082]]
},
{
"block_id": 1,
"bbox": [39.0, 111.38001251220703, 143.67001342773438, 123.77301025390625],
"text": "PAPER • OPEN ACCESS",
"dir": [1.0, 0.0],
"X0": 39.0,
"X1": 143.67001342773438,
"avg_char_width": 6.541875839233398,
"avg_char_height": 12.392997741699219,
"block_font_type": "Helvetica-Bold",
"block_font_size": 9.0,
"is_segmented": 1,
"paras": [
{
"para_id": 0,
"bbox": [39.0, 111.38001251220703, 143.67001342773438, 123.77301025390625],
"text": "PAPER • OPEN ACCESS",
"is_matched": 1,
"is_title": 0,
"font_type": "Helvetica-Bold",
"font_size": 9.0,
"font_color": 0,
"neighbor_paras": [null, null]
},
{
"para_id": 1,
"bbox": [39.0, 111.38001251220703, 143.67001342773438, 123.77301025390625],
"text": "PAPER • OPEN ACCESS",
"is_matched": 1,
"is_title": 0,
"font_type": "Helvetica-Bold",
"font_size": 9.0,
"font_color": 0,
"neighbor_paras": [null, null]
}
],
"bboxes_para": [[39.0, 111.38001251220703, 143.67001342773438, 123.77301025390625]]
}
],
"line_blocks":[
{
"number": 0,
"type": 0,
"bbox": [
428.93170166015625,
744.921142578125,
541.5675048828125,
757.8131713867188
],
"lines": [
{
"spans": [
{
"size": 11.0,
"flags": 20,
"font": "UniversNextPro-BoldCond",
"color": 0,
"ascender": 0.9490000009536743,
"descender": -0.22300000488758087,
"text": "3",
"origin": [
536.37548828125,
755.3601684570312
],
"bbox": [
536.37548828125,
744.921142578125,
541.5675048828125,
757.8131713867188
]
}
],
"wmode": 0,
"dir": [
1.0,
0.0
],
"bbox": [
536.37548828125,
744.921142578125,
541.5675048828125,
757.8131713867188
]
},
{
"spans": [
{
"size": 8.0,
"flags": 20,
"font": "UniversNextPro-BoldCond",
"color": 0,
"ascender": 0.9490000009536743,
"descender": -0.22300000488758087,
"text": "Spektrum ",
"origin": [
428.93170166015625,
755.3601684570312
],
"bbox": [
428.93170166015625,
747.7681884765625,
458.7516174316406,
757.1441650390625
]
},
{
"size": 8.0,
"flags": 4,
"font": "UniversNextPro-Cond",
"color": 0,
"ascender": 0.9359999895095825,
"descender": -0.21400000154972076,
"text": "der Wissenschaft ",
"origin": [
458.431884765625,
755.3601684570312
],
"bbox": [
458.431884765625,
747.8721923828125,
508.0399169921875,
757.0721435546875
]
},
{
"size": 8.0,
"flags": 4,
"font": "UniversNextPro-Regular",
"color": 0,
"ascender": 0.9290000200271606,
"descender": -0.22200000286102295,
"text": "7.21",
"origin": [
510.2349853515625,
755.3601684570312
],
"bbox": [
510.2349853515625,
747.9281616210938,
524.5621948242188,
757.1361694335938
]
}
],
"wmode": 0,
"dir": [
1.0,
0.0
],
"bbox": [
428.93170166015625,
747.7681884765625,
524.5621948242188,
757.1441650390625
]
}
]
}
],
"images":[
{
"image_bbox":[0,0,1,1],
"image_path":"path/to/image.jpg"
},
{
"image_bbox":[1,2,3,4],
"image_path":"path/to/image.jpg"
}
],
"tables":[
{
"table_bbox":[0,0,1,1],
"image_path":"path/to/image.jpg"
},
{
"table_bbox":[1,2,3,4],
"image_path":"path/to/image.jpg"
}
],
"interline_equations":[
{
"equation_bbox":[0,0,1,1],
"image_path":"path/to/equation.jpg"
},
{
"equation_bbox":[1,2,3,4],
"image_path":"path/to/equation.jpg"
}
],
"inline_equations":[
{
"equation_bbox":[0,0,1,1],
"image_path":"path/to/equation.jpg"
},
{
"equation_bbox":[1,2,3,4],
"image_path":"path/to/equation.jpg"
}
],
"layout_bboxes":[
{
"layout_bbox": [0,0, 1,1],
"layout_label":"V|H|B"
},
{
"layout_bbox": [1,2,3,4],
"layout_label":"V|H|B"
}
],
"pymu_raw_blocks":[],
"global_statistic":{
},
"droped_text_block":[
],
"droped_image_block":[
],
"droped_table_block":[
],
"image_backup":[
],
"table_backup":[
]
},
"page_1":{
}
}
\ No newline at end of file
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment