Commit a38c2a88 authored by liukaiwen's avatar liukaiwen

Merge branch 'master' of github.com:papayalove/Magic-PDF

parents b18496b0 c7067c85
...@@ -177,6 +177,8 @@ https://github.com/user-attachments/assets/4bea02c9-6d54-4cd6-97ed-dff14340982c ...@@ -177,6 +177,8 @@ https://github.com/user-attachments/assets/4bea02c9-6d54-4cd6-97ed-dff14340982c
#### 1. 安装magic-pdf #### 1. 安装magic-pdf
```bash ```bash
conda create -n MinerU python=3.10
conda activate MinerU
pip install magic-pdf[full]==0.6.2b1 detectron2 --extra-index-url https://wheels.myhloli.com -i https://pypi.tuna.tsinghua.edu.cn/simple pip install magic-pdf[full]==0.6.2b1 detectron2 --extra-index-url https://wheels.myhloli.com -i https://pypi.tuna.tsinghua.edu.cn/simple
``` ```
#### 2. 下载模型权重文件 #### 2. 下载模型权重文件
...@@ -330,16 +332,15 @@ TODO ...@@ -330,16 +332,15 @@ TODO
[LICENSE.md](LICENSE.md) [LICENSE.md](LICENSE.md)
The project currently leverages PyMuPDF to deliver advanced functionalities; however, its adherence to the AGPL license may impose limitations on certain use cases. In upcoming iterations, we intend to explore and transition to a more permissively licensed PDF processing library to enhance user-friendliness and flexibility. 本项目目前采用PyMuPDF以实现高级功能,但因其遵循AGPL协议,可能对某些使用场景构成限制。未来版本迭代中,我们计划探索并替换为许可条款更为宽松的PDF处理库,以提升用户友好度及灵活性。
# Acknowledgments # Acknowledgments
- [PDF-Extract-Kit](https://github.com/opendatalab/PDF-Extract-Kit)
- [StructEqTable](https://github.com/UniModal4Reasoning/StructEqTable-Deploy) - [StructEqTable](https://github.com/UniModal4Reasoning/StructEqTable-Deploy)
- [PaddleOCR](https://github.com/PaddlePaddle/PaddleOCR) - [PaddleOCR](https://github.com/PaddlePaddle/PaddleOCR)
- [PyMuPDF](https://github.com/pymupdf/PyMuPDF) - [PyMuPDF](https://github.com/pymupdf/PyMuPDF)
- [fast-langdetect](https://github.com/LlmKira/fast-langdetect) - [fast-langdetect](https://github.com/LlmKira/fast-langdetect)
- [pdfminer.six](https://github.com/pdfminer/pdfminer.six) - [pdfminer.six](https://github.com/pdfminer/pdfminer.six)
- [StructEqTable](https://github.com/UniModal4Reasoning/StructEqTable-Deploy)
# Citation # Citation
......
# 常见问题解答 # 常见问题解答
### 1.离线部署首次运行,报错urllib.error.URLError: <urlopen error [Errno 101] Network is unreachable> ### 1.离线部署首次运行,报错urllib.error.URLError: <urlopen error [Errno 101] Network is unreachable>
首次运行需要在线下载一个小的语言检测模型,如果是离线部署需要手动下载该模型并放到指定目录。 Fixed in 0.6.2b1
参考:https://github.com/opendatalab/MinerU/issues/121
### 2.在较新版本的mac上使用命令安装pip install magic-pdf[full-cpu] zsh: no matches found: magic-pdf[full-cpu] ### 2.在较新版本的mac上使用命令安装pip install magic-pdf[full-cpu] zsh: no matches found: magic-pdf[full-cpu]
...@@ -16,34 +17,17 @@ pip install magic-pdf[full-cpu] ...@@ -16,34 +17,17 @@ pip install magic-pdf[full-cpu]
### 3.在intel cpu 的mac上 安装最新版的完整功能包 magic-pdf[full-cpu] (0.6.x) 不成功 ### 3.在intel cpu 的mac上 安装最新版的完整功能包 magic-pdf[full-cpu] (0.6.x) 不成功
完整功能包依赖的公式解析库unimernet限制了pytorch的最低版本为2.3.0,而pytorch官方没有为intel cpu的macOS 提供2.3.0版本的预编译包,所以会产生依赖不兼容的问题。 Fixed in 0.6.2b1
可以先尝试安装unimernet的老版本之后再尝试安装完整功能包的其他依赖。(为避免依赖冲突,请激活一个全新的虚拟环境)
```bash
pip install magic-pdf
pip install unimernet==0.1.0
pip install matplotlib ultralytics paddleocr==2.7.3 paddlepaddle
pip install detectron2 --extra-index-url https://myhloli.github.io/wheels/
```
### 4.在部分较新的M芯片macOS设备上,MPS加速开启失败 ### 4.在部分较新的M芯片macOS设备上,MPS加速开启失败
卸载torch和torchvision,重新安装nightly构建版torch和torchvision Not support over 0.7.x
```bash
pip uninstall torch torchvision
pip install --pre torch torchvision --index-url https://download.pytorch.org/whl/nightly/cpu
```
参考: https://github.com/opendatalab/PDF-Extract-Kit/issues/23
### 5.使用过程中遇到paddle相关的报错FatalError: Illegal instruction is detected by the operating system. ### 5.使用过程中遇到paddle相关的报错FatalError: Illegal instruction is detected by the operating system.
paddlepaddle 2.6.1与部分linux系统环境存在兼容性问题。 Fixed in 0.6.2b1
可尝试~~降级到2.5.2~~升级到3.0.0b1使用,
```bash
pip install paddlepaddle==3.0.0b1
```
~~或卸载paddlepaddle,重新安装paddlepaddle-gpu~~
参考:https://github.com/opendatalab/MinerU/issues/224
### 6.使用过程中遇到_pickle.UnpicklingError: invalid load key, 'v'.错误 ### 6.使用过程中遇到_pickle.UnpicklingError: invalid load key, 'v'.错误
......
# Ubuntu 22.04 LTS
### 1. Check if NVIDIA Drivers Are Installed
```sh
nvidia-smi
```
If you see information similar to the following, it means that the NVIDIA drivers are already installed, and you can skip Step 2.
```plaintext
+---------------------------------------------------------------------------------------+
| NVIDIA-SMI 537.34 Driver Version: 537.34 CUDA Version: 12.2 |
|-----------------------------------------+----------------------+----------------------+
| GPU Name TCC/WDDM | Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap | Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|=========================================+======================+======================|
| 0 NVIDIA GeForce RTX 3060 Ti WDDM | 00000000:01:00.0 On | N/A |
| 0% 51C P8 12W / 200W | 1489MiB / 8192MiB | 5% Default |
| | | N/A |
+-----------------------------------------+----------------------+----------------------+
```
### 2. Install the Driver
If no driver is installed, use the following command:
```sh
sudo apt-get update
sudo apt-get install nvidia-driver-545
```
Install the proprietary driver and restart your computer after installation.
```sh
reboot
```
### 3. Install Anaconda
If Anaconda is already installed, skip this step.
```sh
wget https://repo.anaconda.com/archive/Anaconda3-2024.06-1-Linux-x86_64.sh
bash Anaconda3-2024.06-1-Linux-x86_64.sh
```
In the final step, enter `yes`, close the terminal, and reopen it.
### 4. Create an Environment Using Conda
Specify Python version 3.10.
```sh
conda create -n MinerU python=3.10
conda activate MinerU
```
### 5. Install Applications
```sh
pip install magic-pdf[full]==0.6.2b1 detectron2 --extra-index-url https://wheels.myhloli.com
```
❗ After installation, make sure to check the version of `magic-pdf` using the following command:
```sh
magic-pdf --version
```
If the version number is less than 0.6.2, please report the issue.
### 6. Download Models
Refer to detailed instructions on [how to download model files](how_to_download_models_en.md).
After downloading, move the `models` directory to an SSD with more space.
❗ After downloading the models, ensure they are complete:
- Check that the file sizes match the description on the website.
- If possible, verify the integrity using SHA256.
### 7. Configuration Before First Run
Obtain the configuration template file `magic-pdf.template.json` from the root directory of the repository.
❗ Execute the following command to copy the configuration file to your home directory, otherwise the program will not run:
```sh
wget https://github.com/opendatalab/MinerU/raw/master/magic-pdf.template.json
cp magic-pdf.template.json ~/magic-pdf.json
```
Find the `magic-pdf.json` file in your home directory and configure `"models-dir"` to be the directory where the model weights from Step 6 were downloaded.
❗ Correctly specify the absolute path of the directory containing the model weights; otherwise, the program will fail due to missing model files.
```json
{
"models-dir": "/tmp/models"
}
```
### 8. First Run
Download a sample file from the repository and test it.
```sh
wget https://github.com/opendatalab/MinerU/raw/master/demo/small_ocr.pdf
magic-pdf pdf-command --pdf small_ocr.pdf
```
### 9. Test CUDA Acceleration
If your graphics card has at least 8GB of VRAM, follow these steps to test CUDA acceleration:
1. Modify the value of `"device-mode"` in the `magic-pdf.json` configuration file located in your home directory.
```json
{
"device-mode": "cuda"
}
```
2. Test CUDA acceleration with the following command:
```sh
magic-pdf pdf-command --pdf small_ocr.pdf
```
### 10. Enable CUDA Acceleration for OCR
❗ The following operations require a graphics card with at least 16GB of VRAM; otherwise, the program may crash or experience reduced performance.
1. Download `paddlepaddle-gpu`. Installation will automatically enable OCR acceleration.
```sh
python -m pip install paddlepaddle-gpu==3.0.0b1 -i https://www.paddlepaddle.org.cn/packages/stable/cu118/
```
2. Test OCR acceleration with the following command:
```sh
magic-pdf pdf-command --pdf small_ocr.pdf
```
# Ubuntu 22.04 LTS # Ubuntu 22.04 LTS
## 1. 更新apt ## 1. 检测是否已安装nvidia驱动
```bash
sudo apt-get update
```
## 2. 检测是否已安装nvidia驱动
```bash ```bash
nvidia-smi nvidia-smi
``` ```
如果看到类似如下的信息,说明已经安装了nvidia驱动,可以跳过步骤3 如果看到类似如下的信息,说明已经安装了nvidia驱动,可以跳过步骤2
``` ```
+---------------------------------------------------------------------------------------+ +---------------------------------------------------------------------------------------+
| NVIDIA-SMI 537.34 Driver Version: 537.34 CUDA Version: 12.2 | | NVIDIA-SMI 537.34 Driver Version: 537.34 CUDA Version: 12.2 |
...@@ -22,29 +18,30 @@ nvidia-smi ...@@ -22,29 +18,30 @@ nvidia-smi
| | | N/A | | | | N/A |
+-----------------------------------------+----------------------+----------------------+ +-----------------------------------------+----------------------+----------------------+
``` ```
## 3. 安装驱动 ## 2. 安装驱动
如没有驱动,则通过如下命令 如没有驱动,则通过如下命令
```bash ```bash
sudo apt-get update
sudo apt-get install nvidia-driver-545 sudo apt-get install nvidia-driver-545
``` ```
安装专有驱动,安装完成后,重启电脑 安装专有驱动,安装完成后,重启电脑
```bash ```bash
reboot reboot
``` ```
## 4. 安装anacoda ## 3. 安装anacoda
如果已安装conda,可以跳过本步骤 如果已安装conda,可以跳过本步骤
```bash ```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,关闭终端重新打开
## 5. 使用conda 创建环境 ## 4. 使用conda 创建环境
需指定python版本为3.10 需指定python版本为3.10
```bash ```bash
conda create -n MinerU python=3.10 conda create -n MinerU python=3.10
conda activate MinerU conda activate MinerU
``` ```
## 6. 安装应用 ## 5. 安装应用
```bash ```bash
pip install magic-pdf[full]==0.6.2b1 detectron2 --extra-index-url https://wheels.myhloli.com -i https://pypi.tuna.tsinghua.edu.cn/simple pip install magic-pdf[full]==0.6.2b1 detectron2 --extra-index-url https://wheels.myhloli.com -i https://pypi.tuna.tsinghua.edu.cn/simple
``` ```
...@@ -55,24 +52,24 @@ pip install magic-pdf[full]==0.6.2b1 detectron2 --extra-index-url https://wheels ...@@ -55,24 +52,24 @@ pip install magic-pdf[full]==0.6.2b1 detectron2 --extra-index-url https://wheels
>``` >```
> 如果版本号小于0.6.2,请到issue中向我们反馈 > 如果版本号小于0.6.2,请到issue中向我们反馈
## 7. 下载模型 ## 6. 下载模型
详细参考 [如何下载模型文件](how_to_download_models_zh_cn.md) 详细参考 [如何下载模型文件](how_to_download_models_zh_cn.md)
下载后请将models目录移动到空间较大的ssd磁盘目录 下载后请将models目录移动到空间较大的ssd磁盘目录
> ❗️模型下载后请务必检查模型文件是否下载完整 > ❗️模型下载后请务必检查模型文件是否下载完整
> >
> 请检查目录下的模型文件大小与网页上描述是否一致,如果可以的话,最好通过sha256校验模型是否下载完整 > 请检查目录下的模型文件大小与网页上描述是否一致,如果可以的话,最好通过sha256校验模型是否下载完整
> >
## 8. 第一次运行前的配置 ## 7. 第一次运行前的配置
在仓库根目录可以获得 [magic-pdf.template.json](../magic-pdf.template.json) 配置模版文件 在仓库根目录可以获得 [magic-pdf.template.json](../magic-pdf.template.json) 配置模版文件
> ❗️务必执行以下命令将配置文件拷贝到【用户目录】下,否则程序将无法运行 > ❗️务必执行以下命令将配置文件拷贝到【用户目录】下,否则程序将无法运行
> >
> linux用户目录为 "/home/用户名" > linux用户目录为 "/home/用户名"
```bash ```bash
wget https://github.com/opendatalab/MinerU/raw/master/magic-pdf.template.json wget https://gitee.com/myhloli/MinerU/raw/master/magic-pdf.template.json
cp magic-pdf.template.json ~/magic-pdf.json cp magic-pdf.template.json ~/magic-pdf.json
``` ```
在用户目录中找到magic-pdf.json文件并配置"models-dir"为[7. 下载模型](#7-下载模型)中下载的模型权重文件所在目录 在用户目录中找到magic-pdf.json文件并配置"models-dir"为[6. 下载模型](#6-下载模型)中下载的模型权重文件所在目录
> ❗️务必正确配置模型权重文件所在目录的【绝对路径】,否则会因为找不到模型文件而导致程序无法运行 > ❗️务必正确配置模型权重文件所在目录的【绝对路径】,否则会因为找不到模型文件而导致程序无法运行
> >
```json ```json
...@@ -81,13 +78,13 @@ cp magic-pdf.template.json ~/magic-pdf.json ...@@ -81,13 +78,13 @@ cp magic-pdf.template.json ~/magic-pdf.json
} }
``` ```
## 9. 第一次运行 ## 8. 第一次运行
从仓库中下载样本文件,并测试 从仓库中下载样本文件,并测试
```bash ```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 pdf-command --pdf small_ocr.pdf magic-pdf pdf-command --pdf small_ocr.pdf
``` ```
## 10. 测试CUDA加速 ## 9. 测试CUDA加速
如果您的显卡显存大于等于8G,可以进行以下流程,测试CUDA解析加速效果 如果您的显卡显存大于等于8G,可以进行以下流程,测试CUDA解析加速效果
**1.修改【用户目录】中配置文件magic-pdf.json中"device-mode"的值** **1.修改【用户目录】中配置文件magic-pdf.json中"device-mode"的值**
...@@ -101,7 +98,7 @@ magic-pdf pdf-command --pdf small_ocr.pdf ...@@ -101,7 +98,7 @@ magic-pdf pdf-command --pdf small_ocr.pdf
magic-pdf pdf-command --pdf small_ocr.pdf magic-pdf pdf-command --pdf small_ocr.pdf
``` ```
## 11. 为ocr开启cuda加速 ## 10. 为ocr开启cuda加速
> ❗️以下操作需显卡显存大于等于16G才可进行,否则会因为显存不足导致程序崩溃或运行速度下降 > ❗️以下操作需显卡显存大于等于16G才可进行,否则会因为显存不足导致程序崩溃或运行速度下降
**1.下载paddlepaddle-gpu, 安装完成后会自动开启ocr加速** **1.下载paddlepaddle-gpu, 安装完成后会自动开启ocr加速**
......
# Windows 10/11
### 1. Install CUDA and cuDNN
Required versions: CUDA 11.8 + cuDNN 8.7.0
- CUDA 11.8: https://developer.nvidia.com/cuda-11-8-0-download-archive
- cuDNN v8.7.0 (November 28th, 2022), for CUDA 11.x: https://developer.nvidia.com/rdp/cudnn-archive
### 2. Install Anaconda
If Anaconda is already installed, you can skip this step.
Download link: https://repo.anaconda.com/archive/Anaconda3-2024.06-1-Windows-x86_64.exe
### 3. Create an Environment Using Conda
Python version must be 3.10.
```
conda create -n MinerU python=3.10
conda activate MinerU
```
### 4. Install Applications
```
pip install magic-pdf[full]==0.6.2b1 detectron2 --extra-index-url https://wheels.myhloli.com
```
>❗️After installation, verify the version of `magic-pdf`:
> ```bash
> magic-pdf --version
> ```
> If the version number is less than 0.6.2, please report it in the issues section.
### 5. Download Models
Refer to detailed instructions on [how to download model files](how_to_download_models_en.md).
After downloading, move the `models` directory to an SSD with more space.
>❗ After downloading the models, ensure they are complete:
>- Check that the file sizes match the description on the website.
>- If possible, verify the integrity using SHA256.
### 6. Configuration Before the First Run
Obtain the configuration template file `magic-pdf.template.json` from the repository root directory.
>❗️Execute the following command to copy the configuration file to your user directory, or the program will not run.
>
> In Windows, user directory is "C:\Users\username"
```powershell
(New-Object System.Net.WebClient).DownloadFile('https://github.com/opendatalab/MinerU/raw/master/magic-pdf.template.json', 'magic-pdf.template.json')
cp magic-pdf.template.json ~/magic-pdf.json
```
Find the `magic-pdf.json` file in your user directory and configure `"models-dir"` to point to the directory where the model weights from step 5 were downloaded.
> ❗️Ensure the absolute path of the model weights directory is correctly configured, or the program will fail to run due to not finding the model files.
>
> In Windows, this path should include the drive letter and replace all `"\"` to `"/"`.
>
> Example: If the models are placed in the root directory of drive D, the value for `model-dir` should be `"D:/models"`.
```json
{
"models-dir": "/tmp/models"
}
```
### 7. First Run
Download a sample file from the repository and test it.
```powershell
(New-Object System.Net.WebClient).DownloadFile('https://github.com/opendatalab/MinerU/raw/master/demo/small_ocr.pdf', 'small_ocr.pdf')
magic-pdf pdf-command --pdf small_ocr.pdf
```
### 8. Test CUDA Acceleration
If your graphics card has at least 8GB of VRAM, follow these steps to test CUDA-accelerated parsing performance.
1. **Overwrite the installation of torch and torchvision** supporting CUDA.
```
pip install --force-reinstall torch==2.3.1 torchvision==0.18.1 --index-url https://download.pytorch.org/whl/cu118
```
>❗️Ensure the following versions are specified in the command:
>```
> torch==2.3.1 torchvision==0.18.1
>```
>These are the highest versions we support. Installing higher versions without specifying them will cause the program to fail.
2. **Modify the value of `"device-mode"`** in the `magic-pdf.json` configuration file located in your user directory.
```json
{
"device-mode": "cuda"
}
```
3. **Run the following command to test CUDA acceleration**:
```
magic-pdf pdf-command --pdf small_ocr.pdf
```
### 9. Enable CUDA Acceleration for OCR
>❗️This operation requires at least 16GB of VRAM on your graphics card, otherwise it will cause the program to crash or slow down.
1. **Download paddlepaddle-gpu**, which will automatically enable OCR acceleration upon installation.
```
pip install paddlepaddle-gpu==2.6.1
```
2. **Run the following command to test OCR acceleration**:
```
magic-pdf pdf-command --pdf small_ocr.pdf
```
\ No newline at end of file
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
如果已安装conda,可以跳过本步骤 如果已安装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
...@@ -42,14 +42,14 @@ pip install magic-pdf[full]==0.6.2b1 detectron2 --extra-index-url https://wheels ...@@ -42,14 +42,14 @@ pip install magic-pdf[full]==0.6.2b1 detectron2 --extra-index-url https://wheels
> >
> windows用户目录为 "C:\Users\用户名" > windows用户目录为 "C:\Users\用户名"
```powershell ```powershell
(New-Object System.Net.WebClient).DownloadFile('https://github.com/opendatalab/MinerU/raw/master/magic-pdf.template.json', 'magic-pdf.template.json') (New-Object System.Net.WebClient).DownloadFile('https://gitee.com/myhloli/MinerU/raw/master/magic-pdf.template.json', 'magic-pdf.template.json')
cp magic-pdf.template.json ~/magic-pdf.json cp magic-pdf.template.json ~/magic-pdf.json
``` ```
在用户目录中找到magic-pdf.json文件并配置"models-dir"为[5. 下载模型](#5-下载模型)中下载的模型权重文件所在目录 在用户目录中找到magic-pdf.json文件并配置"models-dir"为[5. 下载模型](#5-下载模型)中下载的模型权重文件所在目录
> ❗️务必正确配置模型权重文件所在目录的【绝对路径】,否则会因为找不到模型文件而导致程序无法运行 > ❗️务必正确配置模型权重文件所在目录的【绝对路径】,否则会因为找不到模型文件而导致程序无法运行
> >
> windows系统中此路径应包含盘符,且需把路径中所有的"\"替换为"/",否则会因为转义原因导致json文件语法错误。 > windows系统中此路径应包含盘符,且需把路径中所有的`"\"`替换为`"/"`,否则会因为转义原因导致json文件语法错误。
> >
> 例如:模型放在D盘根目录的models目录,则model-dir的值应为"D:/models" > 例如:模型放在D盘根目录的models目录,则model-dir的值应为"D:/models"
```json ```json
...@@ -61,7 +61,7 @@ cp magic-pdf.template.json ~/magic-pdf.json ...@@ -61,7 +61,7 @@ cp magic-pdf.template.json ~/magic-pdf.json
## 7. 第一次运行 ## 7. 第一次运行
从仓库中下载样本文件,并测试 从仓库中下载样本文件,并测试
```powershell ```powershell
(New-Object System.Net.WebClient).DownloadFile('https://github.com/opendatalab/MinerU/raw/master/demo/small_ocr.pdf', 'small_ocr.pdf') (New-Object System.Net.WebClient).DownloadFile('https://gitee.com/myhloli/MinerU/raw/master/demo/small_ocr.pdf', 'small_ocr.pdf')
magic-pdf pdf-command --pdf small_ocr.pdf magic-pdf pdf-command --pdf small_ocr.pdf
``` ```
......
### Install Git LFS ### 1. Install Git LFS
Before you begin, make sure Git Large File Storage (Git LFS) is installed on your system. Install it using the following command: Before you begin, make sure Git Large File Storage (Git LFS) is installed on your system. Install it using the following command:
```bash ```bash
git lfs install git lfs install
``` ```
### Download the Model from Hugging Face ### 2. Download the Model from Hugging Face
To download the `PDF-Extract-Kit` model from Hugging Face, use the following command: To download the `PDF-Extract-Kit` model from Hugging Face, use the following command:
```bash ```bash
...@@ -14,35 +14,13 @@ git lfs clone https://huggingface.co/wanderkid/PDF-Extract-Kit ...@@ -14,35 +14,13 @@ git lfs clone https://huggingface.co/wanderkid/PDF-Extract-Kit
Ensure that Git LFS is enabled during the clone to properly download all large files. Ensure that Git LFS is enabled during the clone to properly download all large files.
### 3. Additional steps
#### 1. Check whether the model directory is downloaded completely.
### Download the Model from ModelScope The structure of the model folder is as follows, including configuration files and weight files of different components:
#### SDK Download
```bash
# First, install the ModelScope library using pip:
pip install modelscope
```
```python
# Use the following Python code to download the model using the ModelScope SDK:
from modelscope import snapshot_download
model_dir = snapshot_download('wanderkid/PDF-Extract-Kit')
```
#### Git Download
Alternatively, you can use Git to clone the model repository from ModelScope:
```bash
git lfs clone https://www.modelscope.cn/wanderkid/PDF-Extract-Kit.git
``` ```
../
Put [model files]() here:
```
./
├── Layout ├── Layout
│ ├── config.json │ ├── config.json
│ └── model_final.pth │ └── model_final.pth
...@@ -56,5 +34,22 @@ Put [model files]() here: ...@@ -56,5 +34,22 @@ Put [model files]() here:
│ ├── README.md │ ├── README.md
│ ├── tokenizer_config.json │ ├── tokenizer_config.json
│ └── tokenizer.json │ └── tokenizer.json
│── TabRec
│ └─StructEqTable
│ ├── config.json
│ ├── generation_config.json
│ ├── model.safetensors
│ ├── preprocessor_config.json
│ ├── special_tokens_map.json
│ ├── spiece.model
│ ├── tokenizer.json
│ └── tokenizer_config.json
└── README.md └── README.md
``` ```
#### 2. Check whether the model file is fully downloaded.
Please check whether the size of the model file in the directory is consistent with the description on the web page. If possible, it is best to check whether the model is downloaded completely through sha256.
#### 3. Move the model to the solid-state drive
Move the 'models' directory to a directory with large disk space, preferably on a solid-state drive (SSD). In addition, modify the model directory in `~/magic-pdf.json` to point to the final model storage location, otherwise the model cannot be loaded.
\ No newline at end of file
...@@ -42,6 +42,7 @@ pip install modelscope ...@@ -42,6 +42,7 @@ pip install modelscope
# 使用modelscope sdk下载模型 # 使用modelscope sdk下载模型
from modelscope import snapshot_download from modelscope import snapshot_download
model_dir = snapshot_download('wanderkid/PDF-Extract-Kit') model_dir = snapshot_download('wanderkid/PDF-Extract-Kit')
print(f"模型文件下载路径为:{model_dir}")
``` ```
## 额外步骤 ## 额外步骤
......
__version__ = "0.6.2b1" __version__ = "0.7.0a1"
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