how_to_download_models_zh_cn.md 2.89 KB
Newer Older
1
2
# 如何下载模型文件

3
模型文件可以从 Hugging Face 或 Model Scope 下载,由于网络原因,国内用户访问HF可能会失败,请使用 ModelScope。
4

5
6
7
8
9
10
11
12
<details>
  <summary>方法一:从 Hugging Face 下载模型</summary>
  <p>使用python脚本 从Hugging Face下载模型文件</p>
  <pre><code>pip install huggingface_hub
wget https://gitee.com/myhloli/MinerU/raw/master/docs/download_models_hf.py
python download_models_hf.py</code></pre>
  <p>python脚本执行完毕后,会输出模型下载目录</p>
</details>
13

14
## 方法二:从 ModelScope 下载模型
15

16
### 使用python脚本 从ModelScope下载模型文件
17
18
19

```bash
pip install modelscope
20
21
wget https://gitee.com/myhloli/MinerU/raw/master/docs/download_models.py
python download_models.py
22
```
23
python脚本执行完毕后,会输出模型下载目录
24
## 【❗️必须要做❗️】的额外步骤(模型下载完成后请务必完成以下操作)
25

26
### 1.检查模型目录是否下载完整
27
模型文件夹的结构如下,包含了不同组件的配置文件和权重文件:
28
29
```
./
30
├── Layout  # 布局检测模型
31
32
│   ├── config.json
│   └── model_final.pth
33
├── MFD  # 公式检测
34
│   └── weights.pt
35
├── MFR  # 公式识别模型
36
37
38
39
40
41
42
│   └── UniMERNet
│       ├── config.json
│       ├── preprocessor_config.json
│       ├── pytorch_model.bin
│       ├── README.md
│       ├── tokenizer_config.json
│       └── tokenizer.json
43
│── TabRec # 表格识别模型
44
45
46
47
48
49
50
51
52
│   └─StructEqTable
│       ├── config.json
│       ├── generation_config.json
│       ├── model.safetensors
│       ├── preprocessor_config.json
│       ├── special_tokens_map.json
│       ├── spiece.model
│       ├── tokenizer.json
│       └── tokenizer_config.json 
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
│   └─ TableMaster 
│       └─ ch_PP-OCRv3_det_infer
│           ├── inference.pdiparams
│           ├── inference.pdiparams.info
│           └── inference.pdmodel
│       └─ ch_PP-OCRv3_rec_infer
│           ├── inference.pdiparams
│           ├── inference.pdiparams.info
│           └── inference.pdmodel
│       └─ table_structure_tablemaster_infer
│           ├── inference.pdiparams
│           ├── inference.pdiparams.info
│           └── inference.pdmodel
│       ├── ppocr_keys_v1.txt
│       └── table_master_structure_dict.txt
68
└── README.md
69
```
70
71
72
73

### 2.检查模型文件是否下载完整
请检查目录下的模型文件大小与网页上描述是否一致,如果可以的话,最好通过sha256校验模型是否下载完整

74
75
### 3.修改magic-pdf.json中的模型路径
此外在 `~/magic-pdf.json`里修改模型的目录指向之前python脚本输出的models目录的绝对路径,否则会报模型无法加载的错误。