Spaces:
Build error
Build error
Upload 396 files
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- .gitattributes +23 -0
- PDF-Extract-Kit/.gitignore +22 -0
- PDF-Extract-Kit/.readthedocs.yaml +16 -0
- PDF-Extract-Kit/.vscode/launch.json +92 -0
- PDF-Extract-Kit/LICENSE.md +661 -0
- PDF-Extract-Kit/README.md +221 -0
- PDF-Extract-Kit/README_zh-CN.md +239 -0
- PDF-Extract-Kit/assets/demo/PDFs/DDPM.pdf +3 -0
- PDF-Extract-Kit/assets/demo/PDFs/UniMERNet.pdf +3 -0
- PDF-Extract-Kit/assets/demo/formula_detection/textbook.png +3 -0
- PDF-Extract-Kit/assets/demo/formula_detection/wikipedia_sce.png +3 -0
- PDF-Extract-Kit/assets/demo/formula_recognition/cpe.png +0 -0
- PDF-Extract-Kit/assets/demo/formula_recognition/hwe.png +0 -0
- PDF-Extract-Kit/assets/demo/formula_recognition/sce.png +0 -0
- PDF-Extract-Kit/assets/demo/formula_recognition/spe.png +0 -0
- PDF-Extract-Kit/assets/demo/layout_detection/exam_paper.png +3 -0
- PDF-Extract-Kit/assets/demo/layout_detection/financial_report.png +3 -0
- PDF-Extract-Kit/assets/demo/layout_detection/fuzzy_scan.png +3 -0
- PDF-Extract-Kit/assets/demo/layout_detection/paper.png +3 -0
- PDF-Extract-Kit/assets/demo/layout_detection/slides.png +3 -0
- PDF-Extract-Kit/assets/demo/layout_detection/watermark.png +3 -0
- PDF-Extract-Kit/assets/demo/ocr/ocr_001.png +3 -0
- PDF-Extract-Kit/assets/demo/ocr/ocr_002.png +3 -0
- PDF-Extract-Kit/assets/demo/table_parsing/table_001.png +3 -0
- PDF-Extract-Kit/assets/readme/datalab_logo.png +0 -0
- PDF-Extract-Kit/assets/readme/layout_example.png +3 -0
- PDF-Extract-Kit/assets/readme/mfd_example.png +3 -0
- PDF-Extract-Kit/assets/readme/modelscope_logo.png +0 -0
- PDF-Extract-Kit/assets/readme/pdf-extract-kit_logo.png +0 -0
- PDF-Extract-Kit/assets/readme/pipeline.png +3 -0
- PDF-Extract-Kit/assets/readme/table_expamle.png +3 -0
- PDF-Extract-Kit/assets/readme/unimernet_result.jpg +3 -0
- PDF-Extract-Kit/configs/config.yaml +17 -0
- PDF-Extract-Kit/configs/formula_detection.yaml +12 -0
- PDF-Extract-Kit/configs/formula_recognition.yaml +9 -0
- PDF-Extract-Kit/configs/layout_detection.yaml +11 -0
- PDF-Extract-Kit/configs/layout_detection_layoutlmv3.yaml +7 -0
- PDF-Extract-Kit/configs/layout_detection_yolo.yaml +12 -0
- PDF-Extract-Kit/configs/ocr.yaml +12 -0
- PDF-Extract-Kit/configs/table_parsing.yaml +12 -0
- PDF-Extract-Kit/docs/en/.readthedocs.yaml +16 -0
- PDF-Extract-Kit/docs/en/Makefile +20 -0
- PDF-Extract-Kit/docs/en/_static/image/logo.png +0 -0
- PDF-Extract-Kit/docs/en/algorithm/formula_detection.rst +91 -0
- PDF-Extract-Kit/docs/en/algorithm/formula_recognition.rst +52 -0
- PDF-Extract-Kit/docs/en/algorithm/layout_detection.rst +190 -0
- PDF-Extract-Kit/docs/en/algorithm/ocr.rst +65 -0
- PDF-Extract-Kit/docs/en/algorithm/reading_order.rst +6 -0
- PDF-Extract-Kit/docs/en/algorithm/table_recognition.rst +66 -0
- PDF-Extract-Kit/docs/en/conf copy.py +121 -0
.gitattributes
CHANGED
@@ -33,3 +33,26 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
36 |
+
PDF-Extract-Kit/assets/demo/formula_detection/textbook.png filter=lfs diff=lfs merge=lfs -text
|
37 |
+
PDF-Extract-Kit/assets/demo/formula_detection/wikipedia_sce.png filter=lfs diff=lfs merge=lfs -text
|
38 |
+
PDF-Extract-Kit/assets/demo/layout_detection/exam_paper.png filter=lfs diff=lfs merge=lfs -text
|
39 |
+
PDF-Extract-Kit/assets/demo/layout_detection/financial_report.png filter=lfs diff=lfs merge=lfs -text
|
40 |
+
PDF-Extract-Kit/assets/demo/layout_detection/fuzzy_scan.png filter=lfs diff=lfs merge=lfs -text
|
41 |
+
PDF-Extract-Kit/assets/demo/layout_detection/paper.png filter=lfs diff=lfs merge=lfs -text
|
42 |
+
PDF-Extract-Kit/assets/demo/layout_detection/slides.png filter=lfs diff=lfs merge=lfs -text
|
43 |
+
PDF-Extract-Kit/assets/demo/layout_detection/watermark.png filter=lfs diff=lfs merge=lfs -text
|
44 |
+
PDF-Extract-Kit/assets/demo/ocr/ocr_001.png filter=lfs diff=lfs merge=lfs -text
|
45 |
+
PDF-Extract-Kit/assets/demo/ocr/ocr_002.png filter=lfs diff=lfs merge=lfs -text
|
46 |
+
PDF-Extract-Kit/assets/demo/PDFs/DDPM.pdf filter=lfs diff=lfs merge=lfs -text
|
47 |
+
PDF-Extract-Kit/assets/demo/PDFs/UniMERNet.pdf filter=lfs diff=lfs merge=lfs -text
|
48 |
+
PDF-Extract-Kit/assets/demo/table_parsing/table_001.png filter=lfs diff=lfs merge=lfs -text
|
49 |
+
PDF-Extract-Kit/assets/readme/layout_example.png filter=lfs diff=lfs merge=lfs -text
|
50 |
+
PDF-Extract-Kit/assets/readme/mfd_example.png filter=lfs diff=lfs merge=lfs -text
|
51 |
+
PDF-Extract-Kit/assets/readme/pipeline.png filter=lfs diff=lfs merge=lfs -text
|
52 |
+
PDF-Extract-Kit/assets/readme/table_expamle.png filter=lfs diff=lfs merge=lfs -text
|
53 |
+
PDF-Extract-Kit/assets/readme/unimernet_result.jpg filter=lfs diff=lfs merge=lfs -text
|
54 |
+
PDF-Extract-Kit/docs/zh_cn/_build/html/_static/vendor/fontawesome/6.5.2/webfonts/fa-brands-400.ttf filter=lfs diff=lfs merge=lfs -text
|
55 |
+
PDF-Extract-Kit/docs/zh_cn/_build/html/_static/vendor/fontawesome/6.5.2/webfonts/fa-brands-400.woff2 filter=lfs diff=lfs merge=lfs -text
|
56 |
+
PDF-Extract-Kit/docs/zh_cn/_build/html/_static/vendor/fontawesome/6.5.2/webfonts/fa-solid-900.ttf filter=lfs diff=lfs merge=lfs -text
|
57 |
+
PDF-Extract-Kit/docs/zh_cn/_build/html/_static/vendor/fontawesome/6.5.2/webfonts/fa-solid-900.woff2 filter=lfs diff=lfs merge=lfs -text
|
58 |
+
PDF-Extract-Kit/project/pdf2markdown/demo.png filter=lfs diff=lfs merge=lfs -text
|
PDF-Extract-Kit/.gitignore
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
*.ipynb*
|
2 |
+
*.ipynb
|
3 |
+
|
4 |
+
# local data
|
5 |
+
outputs/*
|
6 |
+
data/*
|
7 |
+
temp*
|
8 |
+
test*
|
9 |
+
|
10 |
+
# python
|
11 |
+
.ipynb_checkpoints
|
12 |
+
*.ipynb
|
13 |
+
**/__pycache__/
|
14 |
+
|
15 |
+
# logs
|
16 |
+
*.log
|
17 |
+
*.out
|
18 |
+
|
19 |
+
models/*
|
20 |
+
|
21 |
+
# Sphinx documentation
|
22 |
+
docs/*/_build/
|
PDF-Extract-Kit/.readthedocs.yaml
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
version: 2
|
2 |
+
|
3 |
+
build:
|
4 |
+
os: ubuntu-22.04
|
5 |
+
tools:
|
6 |
+
python: "3.10"
|
7 |
+
|
8 |
+
formats:
|
9 |
+
- epub
|
10 |
+
|
11 |
+
python:
|
12 |
+
install:
|
13 |
+
- requirements: requirements/docs.txt
|
14 |
+
|
15 |
+
sphinx:
|
16 |
+
configuration: docs/zh_cn/conf.py
|
PDF-Extract-Kit/.vscode/launch.json
ADDED
@@ -0,0 +1,92 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
// 使用 IntelliSense 了解相关属性。
|
3 |
+
// 悬停以查看现有属性的描述。
|
4 |
+
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
|
5 |
+
"version": "0.2.0",
|
6 |
+
"configurations": [
|
7 |
+
{
|
8 |
+
"name": "run_mfd",
|
9 |
+
"type": "debugpy",
|
10 |
+
"request": "launch",
|
11 |
+
"program": "${workspaceFolder}/scripts/run_mfd.py",
|
12 |
+
"console": "integratedTerminal",
|
13 |
+
"args": [
|
14 |
+
"--config",
|
15 |
+
"configs/config_mfd.yaml"
|
16 |
+
],
|
17 |
+
"env": {
|
18 |
+
"PYTHONPATH": "/Users/bin/anaconda3/envs/mfd_test"
|
19 |
+
}
|
20 |
+
},
|
21 |
+
{
|
22 |
+
"name": "run_formula_recognition",
|
23 |
+
"type": "debugpy",
|
24 |
+
"request": "launch",
|
25 |
+
"program": "${workspaceFolder}/scripts/formula_recognition.py",
|
26 |
+
"console": "integratedTerminal",
|
27 |
+
"args": [
|
28 |
+
"--config",
|
29 |
+
"configs/formula_recognition.yaml"
|
30 |
+
],
|
31 |
+
"env": {
|
32 |
+
"PYTHONPATH": "/Users/bin/anaconda3/envs/mfd_test"
|
33 |
+
}
|
34 |
+
},
|
35 |
+
{
|
36 |
+
"name": "run_ocr",
|
37 |
+
"type": "debugpy",
|
38 |
+
"request": "launch",
|
39 |
+
"program": "${workspaceFolder}/scripts/ocr.py",
|
40 |
+
"console": "integratedTerminal",
|
41 |
+
"args": [
|
42 |
+
"--config",
|
43 |
+
"configs/ocr.yaml"
|
44 |
+
],
|
45 |
+
"env": {
|
46 |
+
"PYTHONPATH": "/Users/bin/anaconda3/envs/mfd_test"
|
47 |
+
}
|
48 |
+
},
|
49 |
+
{
|
50 |
+
"name": "run_formula_detection",
|
51 |
+
"type": "debugpy",
|
52 |
+
"request": "launch",
|
53 |
+
"program": "${workspaceFolder}/scripts/formula_detection.py",
|
54 |
+
"console": "integratedTerminal",
|
55 |
+
"args": [
|
56 |
+
"--config",
|
57 |
+
"configs/formula_detection.yaml"
|
58 |
+
],
|
59 |
+
"env": {
|
60 |
+
"PYTHONPATH": "/Users/bin/anaconda3/envs/mfd_test"
|
61 |
+
}
|
62 |
+
},
|
63 |
+
{
|
64 |
+
"name": "run_layout_detection",
|
65 |
+
"type": "debugpy",
|
66 |
+
"request": "launch",
|
67 |
+
"program": "${workspaceFolder}/scripts/layout_detection.py",
|
68 |
+
"console": "integratedTerminal",
|
69 |
+
"args": [
|
70 |
+
"--config",
|
71 |
+
"configs/layout_detection.yaml"
|
72 |
+
],
|
73 |
+
"env": {
|
74 |
+
"PYTHONPATH": "/Users/bin/anaconda3/envs/mfd_test"
|
75 |
+
}
|
76 |
+
},
|
77 |
+
{
|
78 |
+
"name": "run_layout_detection_layoutlmv3",
|
79 |
+
"type": "debugpy",
|
80 |
+
"request": "launch",
|
81 |
+
"program": "${workspaceFolder}/scripts/layout_detection.py",
|
82 |
+
"console": "integratedTerminal",
|
83 |
+
"args": [
|
84 |
+
"--config",
|
85 |
+
"configs/layout_detection_layoutlmv3.yaml"
|
86 |
+
],
|
87 |
+
"env": {
|
88 |
+
"PYTHONPATH": "/Users/bin/anaconda3/envs/mfd_test"
|
89 |
+
}
|
90 |
+
}
|
91 |
+
]
|
92 |
+
}
|
PDF-Extract-Kit/LICENSE.md
ADDED
@@ -0,0 +1,661 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
GNU AFFERO GENERAL PUBLIC LICENSE
|
2 |
+
Version 3, 19 November 2007
|
3 |
+
|
4 |
+
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
5 |
+
Everyone is permitted to copy and distribute verbatim copies
|
6 |
+
of this license document, but changing it is not allowed.
|
7 |
+
|
8 |
+
Preamble
|
9 |
+
|
10 |
+
The GNU Affero General Public License is a free, copyleft license for
|
11 |
+
software and other kinds of works, specifically designed to ensure
|
12 |
+
cooperation with the community in the case of network server software.
|
13 |
+
|
14 |
+
The licenses for most software and other practical works are designed
|
15 |
+
to take away your freedom to share and change the works. By contrast,
|
16 |
+
our General Public Licenses are intended to guarantee your freedom to
|
17 |
+
share and change all versions of a program--to make sure it remains free
|
18 |
+
software for all its users.
|
19 |
+
|
20 |
+
When we speak of free software, we are referring to freedom, not
|
21 |
+
price. Our General Public Licenses are designed to make sure that you
|
22 |
+
have the freedom to distribute copies of free software (and charge for
|
23 |
+
them if you wish), that you receive source code or can get it if you
|
24 |
+
want it, that you can change the software or use pieces of it in new
|
25 |
+
free programs, and that you know you can do these things.
|
26 |
+
|
27 |
+
Developers that use our General Public Licenses protect your rights
|
28 |
+
with two steps: (1) assert copyright on the software, and (2) offer
|
29 |
+
you this License which gives you legal permission to copy, distribute
|
30 |
+
and/or modify the software.
|
31 |
+
|
32 |
+
A secondary benefit of defending all users' freedom is that
|
33 |
+
improvements made in alternate versions of the program, if they
|
34 |
+
receive widespread use, become available for other developers to
|
35 |
+
incorporate. Many developers of free software are heartened and
|
36 |
+
encouraged by the resulting cooperation. However, in the case of
|
37 |
+
software used on network servers, this result may fail to come about.
|
38 |
+
The GNU General Public License permits making a modified version and
|
39 |
+
letting the public access it on a server without ever releasing its
|
40 |
+
source code to the public.
|
41 |
+
|
42 |
+
The GNU Affero General Public License is designed specifically to
|
43 |
+
ensure that, in such cases, the modified source code becomes available
|
44 |
+
to the community. It requires the operator of a network server to
|
45 |
+
provide the source code of the modified version running there to the
|
46 |
+
users of that server. Therefore, public use of a modified version, on
|
47 |
+
a publicly accessible server, gives the public access to the source
|
48 |
+
code of the modified version.
|
49 |
+
|
50 |
+
An older license, called the Affero General Public License and
|
51 |
+
published by Affero, was designed to accomplish similar goals. This is
|
52 |
+
a different license, not a version of the Affero GPL, but Affero has
|
53 |
+
released a new version of the Affero GPL which permits relicensing under
|
54 |
+
this license.
|
55 |
+
|
56 |
+
The precise terms and conditions for copying, distribution and
|
57 |
+
modification follow.
|
58 |
+
|
59 |
+
TERMS AND CONDITIONS
|
60 |
+
|
61 |
+
0. Definitions.
|
62 |
+
|
63 |
+
"This License" refers to version 3 of the GNU Affero General Public License.
|
64 |
+
|
65 |
+
"Copyright" also means copyright-like laws that apply to other kinds of
|
66 |
+
works, such as semiconductor masks.
|
67 |
+
|
68 |
+
"The Program" refers to any copyrightable work licensed under this
|
69 |
+
License. Each licensee is addressed as "you". "Licensees" and
|
70 |
+
"recipients" may be individuals or organizations.
|
71 |
+
|
72 |
+
To "modify" a work means to copy from or adapt all or part of the work
|
73 |
+
in a fashion requiring copyright permission, other than the making of an
|
74 |
+
exact copy. The resulting work is called a "modified version" of the
|
75 |
+
earlier work or a work "based on" the earlier work.
|
76 |
+
|
77 |
+
A "covered work" means either the unmodified Program or a work based
|
78 |
+
on the Program.
|
79 |
+
|
80 |
+
To "propagate" a work means to do anything with it that, without
|
81 |
+
permission, would make you directly or secondarily liable for
|
82 |
+
infringement under applicable copyright law, except executing it on a
|
83 |
+
computer or modifying a private copy. Propagation includes copying,
|
84 |
+
distribution (with or without modification), making available to the
|
85 |
+
public, and in some countries other activities as well.
|
86 |
+
|
87 |
+
To "convey" a work means any kind of propagation that enables other
|
88 |
+
parties to make or receive copies. Mere interaction with a user through
|
89 |
+
a computer network, with no transfer of a copy, is not conveying.
|
90 |
+
|
91 |
+
An interactive user interface displays "Appropriate Legal Notices"
|
92 |
+
to the extent that it includes a convenient and prominently visible
|
93 |
+
feature that (1) displays an appropriate copyright notice, and (2)
|
94 |
+
tells the user that there is no warranty for the work (except to the
|
95 |
+
extent that warranties are provided), that licensees may convey the
|
96 |
+
work under this License, and how to view a copy of this License. If
|
97 |
+
the interface presents a list of user commands or options, such as a
|
98 |
+
menu, a prominent item in the list meets this criterion.
|
99 |
+
|
100 |
+
1. Source Code.
|
101 |
+
|
102 |
+
The "source code" for a work means the preferred form of the work
|
103 |
+
for making modifications to it. "Object code" means any non-source
|
104 |
+
form of a work.
|
105 |
+
|
106 |
+
A "Standard Interface" means an interface that either is an official
|
107 |
+
standard defined by a recognized standards body, or, in the case of
|
108 |
+
interfaces specified for a particular programming language, one that
|
109 |
+
is widely used among developers working in that language.
|
110 |
+
|
111 |
+
The "System Libraries" of an executable work include anything, other
|
112 |
+
than the work as a whole, that (a) is included in the normal form of
|
113 |
+
packaging a Major Component, but which is not part of that Major
|
114 |
+
Component, and (b) serves only to enable use of the work with that
|
115 |
+
Major Component, or to implement a Standard Interface for which an
|
116 |
+
implementation is available to the public in source code form. A
|
117 |
+
"Major Component", in this context, means a major essential component
|
118 |
+
(kernel, window system, and so on) of the specific operating system
|
119 |
+
(if any) on which the executable work runs, or a compiler used to
|
120 |
+
produce the work, or an object code interpreter used to run it.
|
121 |
+
|
122 |
+
The "Corresponding Source" for a work in object code form means all
|
123 |
+
the source code needed to generate, install, and (for an executable
|
124 |
+
work) run the object code and to modify the work, including scripts to
|
125 |
+
control those activities. However, it does not include the work's
|
126 |
+
System Libraries, or general-purpose tools or generally available free
|
127 |
+
programs which are used unmodified in performing those activities but
|
128 |
+
which are not part of the work. For example, Corresponding Source
|
129 |
+
includes interface definition files associated with source files for
|
130 |
+
the work, and the source code for shared libraries and dynamically
|
131 |
+
linked subprograms that the work is specifically designed to require,
|
132 |
+
such as by intimate data communication or control flow between those
|
133 |
+
subprograms and other parts of the work.
|
134 |
+
|
135 |
+
The Corresponding Source need not include anything that users
|
136 |
+
can regenerate automatically from other parts of the Corresponding
|
137 |
+
Source.
|
138 |
+
|
139 |
+
The Corresponding Source for a work in source code form is that
|
140 |
+
same work.
|
141 |
+
|
142 |
+
2. Basic Permissions.
|
143 |
+
|
144 |
+
All rights granted under this License are granted for the term of
|
145 |
+
copyright on the Program, and are irrevocable provided the stated
|
146 |
+
conditions are met. This License explicitly affirms your unlimited
|
147 |
+
permission to run the unmodified Program. The output from running a
|
148 |
+
covered work is covered by this License only if the output, given its
|
149 |
+
content, constitutes a covered work. This License acknowledges your
|
150 |
+
rights of fair use or other equivalent, as provided by copyright law.
|
151 |
+
|
152 |
+
You may make, run and propagate covered works that you do not
|
153 |
+
convey, without conditions so long as your license otherwise remains
|
154 |
+
in force. You may convey covered works to others for the sole purpose
|
155 |
+
of having them make modifications exclusively for you, or provide you
|
156 |
+
with facilities for running those works, provided that you comply with
|
157 |
+
the terms of this License in conveying all material for which you do
|
158 |
+
not control copyright. Those thus making or running the covered works
|
159 |
+
for you must do so exclusively on your behalf, under your direction
|
160 |
+
and control, on terms that prohibit them from making any copies of
|
161 |
+
your copyrighted material outside their relationship with you.
|
162 |
+
|
163 |
+
Conveying under any other circumstances is permitted solely under
|
164 |
+
the conditions stated below. Sublicensing is not allowed; section 10
|
165 |
+
makes it unnecessary.
|
166 |
+
|
167 |
+
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
168 |
+
|
169 |
+
No covered work shall be deemed part of an effective technological
|
170 |
+
measure under any applicable law fulfilling obligations under article
|
171 |
+
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
172 |
+
similar laws prohibiting or restricting circumvention of such
|
173 |
+
measures.
|
174 |
+
|
175 |
+
When you convey a covered work, you waive any legal power to forbid
|
176 |
+
circumvention of technological measures to the extent such circumvention
|
177 |
+
is effected by exercising rights under this License with respect to
|
178 |
+
the covered work, and you disclaim any intention to limit operation or
|
179 |
+
modification of the work as a means of enforcing, against the work's
|
180 |
+
users, your or third parties' legal rights to forbid circumvention of
|
181 |
+
technological measures.
|
182 |
+
|
183 |
+
4. Conveying Verbatim Copies.
|
184 |
+
|
185 |
+
You may convey verbatim copies of the Program's source code as you
|
186 |
+
receive it, in any medium, provided that you conspicuously and
|
187 |
+
appropriately publish on each copy an appropriate copyright notice;
|
188 |
+
keep intact all notices stating that this License and any
|
189 |
+
non-permissive terms added in accord with section 7 apply to the code;
|
190 |
+
keep intact all notices of the absence of any warranty; and give all
|
191 |
+
recipients a copy of this License along with the Program.
|
192 |
+
|
193 |
+
You may charge any price or no price for each copy that you convey,
|
194 |
+
and you may offer support or warranty protection for a fee.
|
195 |
+
|
196 |
+
5. Conveying Modified Source Versions.
|
197 |
+
|
198 |
+
You may convey a work based on the Program, or the modifications to
|
199 |
+
produce it from the Program, in the form of source code under the
|
200 |
+
terms of section 4, provided that you also meet all of these conditions:
|
201 |
+
|
202 |
+
a) The work must carry prominent notices stating that you modified
|
203 |
+
it, and giving a relevant date.
|
204 |
+
|
205 |
+
b) The work must carry prominent notices stating that it is
|
206 |
+
released under this License and any conditions added under section
|
207 |
+
7. This requirement modifies the requirement in section 4 to
|
208 |
+
"keep intact all notices".
|
209 |
+
|
210 |
+
c) You must license the entire work, as a whole, under this
|
211 |
+
License to anyone who comes into possession of a copy. This
|
212 |
+
License will therefore apply, along with any applicable section 7
|
213 |
+
additional terms, to the whole of the work, and all its parts,
|
214 |
+
regardless of how they are packaged. This License gives no
|
215 |
+
permission to license the work in any other way, but it does not
|
216 |
+
invalidate such permission if you have separately received it.
|
217 |
+
|
218 |
+
d) If the work has interactive user interfaces, each must display
|
219 |
+
Appropriate Legal Notices; however, if the Program has interactive
|
220 |
+
interfaces that do not display Appropriate Legal Notices, your
|
221 |
+
work need not make them do so.
|
222 |
+
|
223 |
+
A compilation of a covered work with other separate and independent
|
224 |
+
works, which are not by their nature extensions of the covered work,
|
225 |
+
and which are not combined with it such as to form a larger program,
|
226 |
+
in or on a volume of a storage or distribution medium, is called an
|
227 |
+
"aggregate" if the compilation and its resulting copyright are not
|
228 |
+
used to limit the access or legal rights of the compilation's users
|
229 |
+
beyond what the individual works permit. Inclusion of a covered work
|
230 |
+
in an aggregate does not cause this License to apply to the other
|
231 |
+
parts of the aggregate.
|
232 |
+
|
233 |
+
6. Conveying Non-Source Forms.
|
234 |
+
|
235 |
+
You may convey a covered work in object code form under the terms
|
236 |
+
of sections 4 and 5, provided that you also convey the
|
237 |
+
machine-readable Corresponding Source under the terms of this License,
|
238 |
+
in one of these ways:
|
239 |
+
|
240 |
+
a) Convey the object code in, or embodied in, a physical product
|
241 |
+
(including a physical distribution medium), accompanied by the
|
242 |
+
Corresponding Source fixed on a durable physical medium
|
243 |
+
customarily used for software interchange.
|
244 |
+
|
245 |
+
b) Convey the object code in, or embodied in, a physical product
|
246 |
+
(including a physical distribution medium), accompanied by a
|
247 |
+
written offer, valid for at least three years and valid for as
|
248 |
+
long as you offer spare parts or customer support for that product
|
249 |
+
model, to give anyone who possesses the object code either (1) a
|
250 |
+
copy of the Corresponding Source for all the software in the
|
251 |
+
product that is covered by this License, on a durable physical
|
252 |
+
medium customarily used for software interchange, for a price no
|
253 |
+
more than your reasonable cost of physically performing this
|
254 |
+
conveying of source, or (2) access to copy the
|
255 |
+
Corresponding Source from a network server at no charge.
|
256 |
+
|
257 |
+
c) Convey individual copies of the object code with a copy of the
|
258 |
+
written offer to provide the Corresponding Source. This
|
259 |
+
alternative is allowed only occasionally and noncommercially, and
|
260 |
+
only if you received the object code with such an offer, in accord
|
261 |
+
with subsection 6b.
|
262 |
+
|
263 |
+
d) Convey the object code by offering access from a designated
|
264 |
+
place (gratis or for a charge), and offer equivalent access to the
|
265 |
+
Corresponding Source in the same way through the same place at no
|
266 |
+
further charge. You need not require recipients to copy the
|
267 |
+
Corresponding Source along with the object code. If the place to
|
268 |
+
copy the object code is a network server, the Corresponding Source
|
269 |
+
may be on a different server (operated by you or a third party)
|
270 |
+
that supports equivalent copying facilities, provided you maintain
|
271 |
+
clear directions next to the object code saying where to find the
|
272 |
+
Corresponding Source. Regardless of what server hosts the
|
273 |
+
Corresponding Source, you remain obligated to ensure that it is
|
274 |
+
available for as long as needed to satisfy these requirements.
|
275 |
+
|
276 |
+
e) Convey the object code using peer-to-peer transmission, provided
|
277 |
+
you inform other peers where the object code and Corresponding
|
278 |
+
Source of the work are being offered to the general public at no
|
279 |
+
charge under subsection 6d.
|
280 |
+
|
281 |
+
A separable portion of the object code, whose source code is excluded
|
282 |
+
from the Corresponding Source as a System Library, need not be
|
283 |
+
included in conveying the object code work.
|
284 |
+
|
285 |
+
A "User Product" is either (1) a "consumer product", which means any
|
286 |
+
tangible personal property which is normally used for personal, family,
|
287 |
+
or household purposes, or (2) anything designed or sold for incorporation
|
288 |
+
into a dwelling. In determining whether a product is a consumer product,
|
289 |
+
doubtful cases shall be resolved in favor of coverage. For a particular
|
290 |
+
product received by a particular user, "normally used" refers to a
|
291 |
+
typical or common use of that class of product, regardless of the status
|
292 |
+
of the particular user or of the way in which the particular user
|
293 |
+
actually uses, or expects or is expected to use, the product. A product
|
294 |
+
is a consumer product regardless of whether the product has substantial
|
295 |
+
commercial, industrial or non-consumer uses, unless such uses represent
|
296 |
+
the only significant mode of use of the product.
|
297 |
+
|
298 |
+
"Installation Information" for a User Product means any methods,
|
299 |
+
procedures, authorization keys, or other information required to install
|
300 |
+
and execute modified versions of a covered work in that User Product from
|
301 |
+
a modified version of its Corresponding Source. The information must
|
302 |
+
suffice to ensure that the continued functioning of the modified object
|
303 |
+
code is in no case prevented or interfered with solely because
|
304 |
+
modification has been made.
|
305 |
+
|
306 |
+
If you convey an object code work under this section in, or with, or
|
307 |
+
specifically for use in, a User Product, and the conveying occurs as
|
308 |
+
part of a transaction in which the right of possession and use of the
|
309 |
+
User Product is transferred to the recipient in perpetuity or for a
|
310 |
+
fixed term (regardless of how the transaction is characterized), the
|
311 |
+
Corresponding Source conveyed under this section must be accompanied
|
312 |
+
by the Installation Information. But this requirement does not apply
|
313 |
+
if neither you nor any third party retains the ability to install
|
314 |
+
modified object code on the User Product (for example, the work has
|
315 |
+
been installed in ROM).
|
316 |
+
|
317 |
+
The requirement to provide Installation Information does not include a
|
318 |
+
requirement to continue to provide support service, warranty, or updates
|
319 |
+
for a work that has been modified or installed by the recipient, or for
|
320 |
+
the User Product in which it has been modified or installed. Access to a
|
321 |
+
network may be denied when the modification itself materially and
|
322 |
+
adversely affects the operation of the network or violates the rules and
|
323 |
+
protocols for communication across the network.
|
324 |
+
|
325 |
+
Corresponding Source conveyed, and Installation Information provided,
|
326 |
+
in accord with this section must be in a format that is publicly
|
327 |
+
documented (and with an implementation available to the public in
|
328 |
+
source code form), and must require no special password or key for
|
329 |
+
unpacking, reading or copying.
|
330 |
+
|
331 |
+
7. Additional Terms.
|
332 |
+
|
333 |
+
"Additional permissions" are terms that supplement the terms of this
|
334 |
+
License by making exceptions from one or more of its conditions.
|
335 |
+
Additional permissions that are applicable to the entire Program shall
|
336 |
+
be treated as though they were included in this License, to the extent
|
337 |
+
that they are valid under applicable law. If additional permissions
|
338 |
+
apply only to part of the Program, that part may be used separately
|
339 |
+
under those permissions, but the entire Program remains governed by
|
340 |
+
this License without regard to the additional permissions.
|
341 |
+
|
342 |
+
When you convey a copy of a covered work, you may at your option
|
343 |
+
remove any additional permissions from that copy, or from any part of
|
344 |
+
it. (Additional permissions may be written to require their own
|
345 |
+
removal in certain cases when you modify the work.) You may place
|
346 |
+
additional permissions on material, added by you to a covered work,
|
347 |
+
for which you have or can give appropriate copyright permission.
|
348 |
+
|
349 |
+
Notwithstanding any other provision of this License, for material you
|
350 |
+
add to a covered work, you may (if authorized by the copyright holders of
|
351 |
+
that material) supplement the terms of this License with terms:
|
352 |
+
|
353 |
+
a) Disclaiming warranty or limiting liability differently from the
|
354 |
+
terms of sections 15 and 16 of this License; or
|
355 |
+
|
356 |
+
b) Requiring preservation of specified reasonable legal notices or
|
357 |
+
author attributions in that material or in the Appropriate Legal
|
358 |
+
Notices displayed by works containing it; or
|
359 |
+
|
360 |
+
c) Prohibiting misrepresentation of the origin of that material, or
|
361 |
+
requiring that modified versions of such material be marked in
|
362 |
+
reasonable ways as different from the original version; or
|
363 |
+
|
364 |
+
d) Limiting the use for publicity purposes of names of licensors or
|
365 |
+
authors of the material; or
|
366 |
+
|
367 |
+
e) Declining to grant rights under trademark law for use of some
|
368 |
+
trade names, trademarks, or service marks; or
|
369 |
+
|
370 |
+
f) Requiring indemnification of licensors and authors of that
|
371 |
+
material by anyone who conveys the material (or modified versions of
|
372 |
+
it) with contractual assumptions of liability to the recipient, for
|
373 |
+
any liability that these contractual assumptions directly impose on
|
374 |
+
those licensors and authors.
|
375 |
+
|
376 |
+
All other non-permissive additional terms are considered "further
|
377 |
+
restrictions" within the meaning of section 10. If the Program as you
|
378 |
+
received it, or any part of it, contains a notice stating that it is
|
379 |
+
governed by this License along with a term that is a further
|
380 |
+
restriction, you may remove that term. If a license document contains
|
381 |
+
a further restriction but permits relicensing or conveying under this
|
382 |
+
License, you may add to a covered work material governed by the terms
|
383 |
+
of that license document, provided that the further restriction does
|
384 |
+
not survive such relicensing or conveying.
|
385 |
+
|
386 |
+
If you add terms to a covered work in accord with this section, you
|
387 |
+
must place, in the relevant source files, a statement of the
|
388 |
+
additional terms that apply to those files, or a notice indicating
|
389 |
+
where to find the applicable terms.
|
390 |
+
|
391 |
+
Additional terms, permissive or non-permissive, may be stated in the
|
392 |
+
form of a separately written license, or stated as exceptions;
|
393 |
+
the above requirements apply either way.
|
394 |
+
|
395 |
+
8. Termination.
|
396 |
+
|
397 |
+
You may not propagate or modify a covered work except as expressly
|
398 |
+
provided under this License. Any attempt otherwise to propagate or
|
399 |
+
modify it is void, and will automatically terminate your rights under
|
400 |
+
this License (including any patent licenses granted under the third
|
401 |
+
paragraph of section 11).
|
402 |
+
|
403 |
+
However, if you cease all violation of this License, then your
|
404 |
+
license from a particular copyright holder is reinstated (a)
|
405 |
+
provisionally, unless and until the copyright holder explicitly and
|
406 |
+
finally terminates your license, and (b) permanently, if the copyright
|
407 |
+
holder fails to notify you of the violation by some reasonable means
|
408 |
+
prior to 60 days after the cessation.
|
409 |
+
|
410 |
+
Moreover, your license from a particular copyright holder is
|
411 |
+
reinstated permanently if the copyright holder notifies you of the
|
412 |
+
violation by some reasonable means, this is the first time you have
|
413 |
+
received notice of violation of this License (for any work) from that
|
414 |
+
copyright holder, and you cure the violation prior to 30 days after
|
415 |
+
your receipt of the notice.
|
416 |
+
|
417 |
+
Termination of your rights under this section does not terminate the
|
418 |
+
licenses of parties who have received copies or rights from you under
|
419 |
+
this License. If your rights have been terminated and not permanently
|
420 |
+
reinstated, you do not qualify to receive new licenses for the same
|
421 |
+
material under section 10.
|
422 |
+
|
423 |
+
9. Acceptance Not Required for Having Copies.
|
424 |
+
|
425 |
+
You are not required to accept this License in order to receive or
|
426 |
+
run a copy of the Program. Ancillary propagation of a covered work
|
427 |
+
occurring solely as a consequence of using peer-to-peer transmission
|
428 |
+
to receive a copy likewise does not require acceptance. However,
|
429 |
+
nothing other than this License grants you permission to propagate or
|
430 |
+
modify any covered work. These actions infringe copyright if you do
|
431 |
+
not accept this License. Therefore, by modifying or propagating a
|
432 |
+
covered work, you indicate your acceptance of this License to do so.
|
433 |
+
|
434 |
+
10. Automatic Licensing of Downstream Recipients.
|
435 |
+
|
436 |
+
Each time you convey a covered work, the recipient automatically
|
437 |
+
receives a license from the original licensors, to run, modify and
|
438 |
+
propagate that work, subject to this License. You are not responsible
|
439 |
+
for enforcing compliance by third parties with this License.
|
440 |
+
|
441 |
+
An "entity transaction" is a transaction transferring control of an
|
442 |
+
organization, or substantially all assets of one, or subdividing an
|
443 |
+
organization, or merging organizations. If propagation of a covered
|
444 |
+
work results from an entity transaction, each party to that
|
445 |
+
transaction who receives a copy of the work also receives whatever
|
446 |
+
licenses to the work the party's predecessor in interest had or could
|
447 |
+
give under the previous paragraph, plus a right to possession of the
|
448 |
+
Corresponding Source of the work from the predecessor in interest, if
|
449 |
+
the predecessor has it or can get it with reasonable efforts.
|
450 |
+
|
451 |
+
You may not impose any further restrictions on the exercise of the
|
452 |
+
rights granted or affirmed under this License. For example, you may
|
453 |
+
not impose a license fee, royalty, or other charge for exercise of
|
454 |
+
rights granted under this License, and you may not initiate litigation
|
455 |
+
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
456 |
+
any patent claim is infringed by making, using, selling, offering for
|
457 |
+
sale, or importing the Program or any portion of it.
|
458 |
+
|
459 |
+
11. Patents.
|
460 |
+
|
461 |
+
A "contributor" is a copyright holder who authorizes use under this
|
462 |
+
License of the Program or a work on which the Program is based. The
|
463 |
+
work thus licensed is called the contributor's "contributor version".
|
464 |
+
|
465 |
+
A contributor's "essential patent claims" are all patent claims
|
466 |
+
owned or controlled by the contributor, whether already acquired or
|
467 |
+
hereafter acquired, that would be infringed by some manner, permitted
|
468 |
+
by this License, of making, using, or selling its contributor version,
|
469 |
+
but do not include claims that would be infringed only as a
|
470 |
+
consequence of further modification of the contributor version. For
|
471 |
+
purposes of this definition, "control" includes the right to grant
|
472 |
+
patent sublicenses in a manner consistent with the requirements of
|
473 |
+
this License.
|
474 |
+
|
475 |
+
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
476 |
+
patent license under the contributor's essential patent claims, to
|
477 |
+
make, use, sell, offer for sale, import and otherwise run, modify and
|
478 |
+
propagate the contents of its contributor version.
|
479 |
+
|
480 |
+
In the following three paragraphs, a "patent license" is any express
|
481 |
+
agreement or commitment, however denominated, not to enforce a patent
|
482 |
+
(such as an express permission to practice a patent or covenant not to
|
483 |
+
sue for patent infringement). To "grant" such a patent license to a
|
484 |
+
party means to make such an agreement or commitment not to enforce a
|
485 |
+
patent against the party.
|
486 |
+
|
487 |
+
If you convey a covered work, knowingly relying on a patent license,
|
488 |
+
and the Corresponding Source of the work is not available for anyone
|
489 |
+
to copy, free of charge and under the terms of this License, through a
|
490 |
+
publicly available network server or other readily accessible means,
|
491 |
+
then you must either (1) cause the Corresponding Source to be so
|
492 |
+
available, or (2) arrange to deprive yourself of the benefit of the
|
493 |
+
patent license for this particular work, or (3) arrange, in a manner
|
494 |
+
consistent with the requirements of this License, to extend the patent
|
495 |
+
license to downstream recipients. "Knowingly relying" means you have
|
496 |
+
actual knowledge that, but for the patent license, your conveying the
|
497 |
+
covered work in a country, or your recipient's use of the covered work
|
498 |
+
in a country, would infringe one or more identifiable patents in that
|
499 |
+
country that you have reason to believe are valid.
|
500 |
+
|
501 |
+
If, pursuant to or in connection with a single transaction or
|
502 |
+
arrangement, you convey, or propagate by procuring conveyance of, a
|
503 |
+
covered work, and grant a patent license to some of the parties
|
504 |
+
receiving the covered work authorizing them to use, propagate, modify
|
505 |
+
or convey a specific copy of the covered work, then the patent license
|
506 |
+
you grant is automatically extended to all recipients of the covered
|
507 |
+
work and works based on it.
|
508 |
+
|
509 |
+
A patent license is "discriminatory" if it does not include within
|
510 |
+
the scope of its coverage, prohibits the exercise of, or is
|
511 |
+
conditioned on the non-exercise of one or more of the rights that are
|
512 |
+
specifically granted under this License. You may not convey a covered
|
513 |
+
work if you are a party to an arrangement with a third party that is
|
514 |
+
in the business of distributing software, under which you make payment
|
515 |
+
to the third party based on the extent of your activity of conveying
|
516 |
+
the work, and under which the third party grants, to any of the
|
517 |
+
parties who would receive the covered work from you, a discriminatory
|
518 |
+
patent license (a) in connection with copies of the covered work
|
519 |
+
conveyed by you (or copies made from those copies), or (b) primarily
|
520 |
+
for and in connection with specific products or compilations that
|
521 |
+
contain the covered work, unless you entered into that arrangement,
|
522 |
+
or that patent license was granted, prior to 28 March 2007.
|
523 |
+
|
524 |
+
Nothing in this License shall be construed as excluding or limiting
|
525 |
+
any implied license or other defenses to infringement that may
|
526 |
+
otherwise be available to you under applicable patent law.
|
527 |
+
|
528 |
+
12. No Surrender of Others' Freedom.
|
529 |
+
|
530 |
+
If conditions are imposed on you (whether by court order, agreement or
|
531 |
+
otherwise) that contradict the conditions of this License, they do not
|
532 |
+
excuse you from the conditions of this License. If you cannot convey a
|
533 |
+
covered work so as to satisfy simultaneously your obligations under this
|
534 |
+
License and any other pertinent obligations, then as a consequence you may
|
535 |
+
not convey it at all. For example, if you agree to terms that obligate you
|
536 |
+
to collect a royalty for further conveying from those to whom you convey
|
537 |
+
the Program, the only way you could satisfy both those terms and this
|
538 |
+
License would be to refrain entirely from conveying the Program.
|
539 |
+
|
540 |
+
13. Remote Network Interaction; Use with the GNU General Public License.
|
541 |
+
|
542 |
+
Notwithstanding any other provision of this License, if you modify the
|
543 |
+
Program, your modified version must prominently offer all users
|
544 |
+
interacting with it remotely through a computer network (if your version
|
545 |
+
supports such interaction) an opportunity to receive the Corresponding
|
546 |
+
Source of your version by providing access to the Corresponding Source
|
547 |
+
from a network server at no charge, through some standard or customary
|
548 |
+
means of facilitating copying of software. This Corresponding Source
|
549 |
+
shall include the Corresponding Source for any work covered by version 3
|
550 |
+
of the GNU General Public License that is incorporated pursuant to the
|
551 |
+
following paragraph.
|
552 |
+
|
553 |
+
Notwithstanding any other provision of this License, you have
|
554 |
+
permission to link or combine any covered work with a work licensed
|
555 |
+
under version 3 of the GNU General Public License into a single
|
556 |
+
combined work, and to convey the resulting work. The terms of this
|
557 |
+
License will continue to apply to the part which is the covered work,
|
558 |
+
but the work with which it is combined will remain governed by version
|
559 |
+
3 of the GNU General Public License.
|
560 |
+
|
561 |
+
14. Revised Versions of this License.
|
562 |
+
|
563 |
+
The Free Software Foundation may publish revised and/or new versions of
|
564 |
+
the GNU Affero General Public License from time to time. Such new versions
|
565 |
+
will be similar in spirit to the present version, but may differ in detail to
|
566 |
+
address new problems or concerns.
|
567 |
+
|
568 |
+
Each version is given a distinguishing version number. If the
|
569 |
+
Program specifies that a certain numbered version of the GNU Affero General
|
570 |
+
Public License "or any later version" applies to it, you have the
|
571 |
+
option of following the terms and conditions either of that numbered
|
572 |
+
version or of any later version published by the Free Software
|
573 |
+
Foundation. If the Program does not specify a version number of the
|
574 |
+
GNU Affero General Public License, you may choose any version ever published
|
575 |
+
by the Free Software Foundation.
|
576 |
+
|
577 |
+
If the Program specifies that a proxy can decide which future
|
578 |
+
versions of the GNU Affero General Public License can be used, that proxy's
|
579 |
+
public statement of acceptance of a version permanently authorizes you
|
580 |
+
to choose that version for the Program.
|
581 |
+
|
582 |
+
Later license versions may give you additional or different
|
583 |
+
permissions. However, no additional obligations are imposed on any
|
584 |
+
author or copyright holder as a result of your choosing to follow a
|
585 |
+
later version.
|
586 |
+
|
587 |
+
15. Disclaimer of Warranty.
|
588 |
+
|
589 |
+
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
590 |
+
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
591 |
+
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
592 |
+
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
593 |
+
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
594 |
+
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
595 |
+
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
596 |
+
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
597 |
+
|
598 |
+
16. Limitation of Liability.
|
599 |
+
|
600 |
+
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
601 |
+
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
602 |
+
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
603 |
+
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
604 |
+
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
605 |
+
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
606 |
+
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
607 |
+
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
608 |
+
SUCH DAMAGES.
|
609 |
+
|
610 |
+
17. Interpretation of Sections 15 and 16.
|
611 |
+
|
612 |
+
If the disclaimer of warranty and limitation of liability provided
|
613 |
+
above cannot be given local legal effect according to their terms,
|
614 |
+
reviewing courts shall apply local law that most closely approximates
|
615 |
+
an absolute waiver of all civil liability in connection with the
|
616 |
+
Program, unless a warranty or assumption of liability accompanies a
|
617 |
+
copy of the Program in return for a fee.
|
618 |
+
|
619 |
+
END OF TERMS AND CONDITIONS
|
620 |
+
|
621 |
+
How to Apply These Terms to Your New Programs
|
622 |
+
|
623 |
+
If you develop a new program, and you want it to be of the greatest
|
624 |
+
possible use to the public, the best way to achieve this is to make it
|
625 |
+
free software which everyone can redistribute and change under these terms.
|
626 |
+
|
627 |
+
To do so, attach the following notices to the program. It is safest
|
628 |
+
to attach them to the start of each source file to most effectively
|
629 |
+
state the exclusion of warranty; and each file should have at least
|
630 |
+
the "copyright" line and a pointer to where the full notice is found.
|
631 |
+
|
632 |
+
<one line to give the program's name and a brief idea of what it does.>
|
633 |
+
Copyright (C) <year> <name of author>
|
634 |
+
|
635 |
+
This program is free software: you can redistribute it and/or modify
|
636 |
+
it under the terms of the GNU Affero General Public License as published
|
637 |
+
by the Free Software Foundation, either version 3 of the License, or
|
638 |
+
(at your option) any later version.
|
639 |
+
|
640 |
+
This program is distributed in the hope that it will be useful,
|
641 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
642 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
643 |
+
GNU Affero General Public License for more details.
|
644 |
+
|
645 |
+
You should have received a copy of the GNU Affero General Public License
|
646 |
+
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
647 |
+
|
648 |
+
Also add information on how to contact you by electronic and paper mail.
|
649 |
+
|
650 |
+
If your software can interact with users remotely through a computer
|
651 |
+
network, you should also make sure that it provides a way for users to
|
652 |
+
get its source. For example, if your program is a web application, its
|
653 |
+
interface could display a "Source" link that leads users to an archive
|
654 |
+
of the code. There are many ways you could offer source, and different
|
655 |
+
solutions will be better for different programs; see section 13 for the
|
656 |
+
specific requirements.
|
657 |
+
|
658 |
+
You should also get your employer (if you work as a programmer) or school,
|
659 |
+
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
660 |
+
For more information on this, and how to apply and follow the GNU AGPL, see
|
661 |
+
<https://www.gnu.org/licenses/>.
|
PDF-Extract-Kit/README.md
ADDED
@@ -0,0 +1,221 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
<p align="center">
|
3 |
+
<img src="assets/readme/pdf-extract-kit_logo.png" width="220px" style="vertical-align:middle;">
|
4 |
+
</p>
|
5 |
+
|
6 |
+
<div align="center">
|
7 |
+
|
8 |
+
English | [简体中文](./README_zh-CN.md)
|
9 |
+
|
10 |
+
[PDF-Extract-Kit-1.0 Tutorial](https://pdf-extract-kit.readthedocs.io/en/latest/get_started/pretrained_model.html)
|
11 |
+
|
12 |
+
[[Models (🤗Hugging Face)]](https://huggingface.co/opendatalab/PDF-Extract-Kit-1.0) | [[Models(<img src="./assets/readme/modelscope_logo.png" width="20px">ModelScope)]](https://www.modelscope.cn/models/OpenDataLab/PDF-Extract-Kit-1.0)
|
13 |
+
|
14 |
+
🔥🔥🔥 [MinerU: Efficient Document Content Extraction Tool Based on PDF-Extract-Kit](https://github.com/opendatalab/MinerU)
|
15 |
+
|
16 |
+
</div>
|
17 |
+
|
18 |
+
<p align="center">
|
19 |
+
👋 join us on <a href="https://discord.gg/Tdedn9GTXq" target="_blank">Discord</a> and <a href="https://r.vansin.top/?r=MinerU" target="_blank">WeChat</a>
|
20 |
+
</p>
|
21 |
+
|
22 |
+
|
23 |
+
## Overview
|
24 |
+
|
25 |
+
`PDF-Extract-Kit` is a powerful open-source toolkit designed to efficiently extract high-quality content from complex and diverse PDF documents. Here are its main features and advantages:
|
26 |
+
|
27 |
+
- **Integration of Leading Document Parsing Models**: Incorporates state-of-the-art models for layout detection, formula detection, formula recognition, OCR, and other core document parsing tasks.
|
28 |
+
- **High-Quality Parsing Across Diverse Documents**: Fine-tuned with diverse document annotation data to deliver high-quality results across various complex document types.
|
29 |
+
- **Modular Design**: The flexible modular design allows users to easily combine and construct various applications by modifying configuration files and minimal code, making application building as straightforward as stacking blocks.
|
30 |
+
- **Comprehensive Evaluation Benchmarks**: Provides diverse and comprehensive PDF evaluation benchmarks, enabling users to choose the most suitable model based on evaluation results.
|
31 |
+
|
32 |
+
**Experience PDF-Extract-Kit now and unlock the limitless potential of PDF documents!**
|
33 |
+
|
34 |
+
> **Note:** PDF-Extract-Kit is designed for high-quality document processing and functions as a model toolbox.
|
35 |
+
> If you are interested in extracting high-quality document content (e.g., converting PDFs to Markdown), please use [MinerU](https://github.com/opendatalab/MinerU), which combines the high-quality predictions from PDF-Extract-Kit with specialized engineering optimizations for more convenient and efficient content extraction.
|
36 |
+
> If you're a developer looking to create engaging applications such as document translation, document Q&A, or document assistants, you'll find it very convenient to build your own projects using PDF-Extract-Kit. In particular, we will periodically update the PDF-Extract-Kit/project directory with interesting applications, so stay tuned!
|
37 |
+
|
38 |
+
**We welcome researchers and engineers from the community to contribute outstanding models and innovative applications by submitting PRs to become contributors to the PDF-Extract-Kit project.**
|
39 |
+
|
40 |
+
## Model Overview
|
41 |
+
|
42 |
+
| **Task Type** | **Description** | **Models** |
|
43 |
+
|-------------------|---------------------------------------------------------------------------------|-------------------------------|
|
44 |
+
| **Layout Detection** | Locate different elements in a document: including images, tables, text, titles, formulas | `DocLayout-YOLO_ft`, `YOLO-v10_ft`, `LayoutLMv3_ft` |
|
45 |
+
| **Formula Detection** | Locate formulas in documents: including inline and block formulas | `YOLOv8_ft` |
|
46 |
+
| **Formula Recognition** | Recognize formula images into LaTeX source code | `UniMERNet` |
|
47 |
+
| **OCR** | Extract text content from images (including location and recognition) | `PaddleOCR` |
|
48 |
+
| **Table Recognition** | Recognize table images into corresponding source code (LaTeX/HTML/Markdown) | `PaddleOCR+TableMaster`, `StructEqTable` |
|
49 |
+
| **Reading Order** | Sort and concatenate discrete text paragraphs | Coming Soon! |
|
50 |
+
|
51 |
+
## News and Updates
|
52 |
+
- `2024.10.22` 🎉🎉🎉 We are excited to announce that table recognition model [StructTable-InternVL2-1B](https://huggingface.co/U4R/StructTable-InternVL2-1B), which supports output LaTeX, HTML and MarkdDown formats has been officially integrated into `PDF-Extract-Kit 1.0`. Please refer to the [table recognition algorithm documentation](https://pdf-extract-kit.readthedocs.io/en/latest/algorithm/table_recognition.html) for usage instructions!
|
53 |
+
- `2024.10.17` 🎉🎉🎉 We are excited to announce that the more accurate and faster layout detection model, [DocLayout-YOLO](https://github.com/opendatalab/DocLayout-YOLO), has been officially integrated into `PDF-Extract-Kit 1.0`. Please refer to the [layout detection algorithm documentation](https://pdf-extract-kit.readthedocs.io/en/latest/algorithm/layout_detection.html) for usage instructions!
|
54 |
+
- `2024.10.10` 🎉🎉🎉 The official release of `PDF-Extract-Kit 1.0`, rebuilt with modularity for more convenient and flexible model usage! Please switch to the [release/0.1.1](https://github.com/opendatalab/PDF-Extract-Kit/tree/release/0.1.1) branch for the old version.
|
55 |
+
- `2024.08.01` 🎉🎉🎉 Added the [StructEqTable](demo/TabRec/StructEqTable/README_TABLE.md) module for table content extraction. Welcome to use it!
|
56 |
+
- `2024.07.01` 🎉🎉🎉 We released `PDF-Extract-Kit`, a comprehensive toolkit for high-quality PDF content extraction, including `Layout Detection`, `Formula Detection`, `Formula Recognition`, and `OCR`.
|
57 |
+
|
58 |
+
## Performance Demonstration
|
59 |
+
|
60 |
+
Many current open-source SOTA models are trained and evaluated on academic datasets, achieving high-quality results only on single document types. To enable models to achieve stable and robust high-quality results on diverse documents, we constructed diverse fine-tuning datasets and fine-tuned some SOTA models to obtain practical parsing models. Below are some visual results of the models.
|
61 |
+
|
62 |
+
### Layout Detection
|
63 |
+
|
64 |
+
We trained robust `Layout Detection` models using diverse PDF document annotations. Our fine-tuned models achieve accurate extraction results on diverse PDF documents such as papers, textbooks, research reports, and financial reports, and demonstrate high robustness to challenges like blurring and watermarks. The visualization example below shows the inference results of the fine-tuned LayoutLMv3 model.
|
65 |
+
|
66 |
+

|
67 |
+
|
68 |
+
### Formula Detection
|
69 |
+
|
70 |
+
Similarly, we collected and annotated documents containing formulas in both English and Chinese, and fine-tuned advanced formula detection models. The visualization result below shows the inference results of the fine-tuned YOLO formula detection model:
|
71 |
+
|
72 |
+

|
73 |
+
|
74 |
+
### Formula Recognition
|
75 |
+
|
76 |
+
[UniMERNet](https://github.com/opendatalab/UniMERNet) is an algorithm designed for diverse formula recognition in real-world scenarios. By constructing large-scale training data and carefully designed results, it achieves excellent recognition performance for complex long formulas, handwritten formulas, and noisy screenshot formulas.
|
77 |
+
|
78 |
+
### Table Recognition
|
79 |
+
|
80 |
+
[StructEqTable](https://github.com/UniModal4Reasoning/StructEqTable-Deploy) is a high efficiency toolkit that can converts table images into LaTeX/HTML/MarkDown. The latest version, powered by the InternVL2-1B foundation model, improves Chinese recognition accuracy and expands multi-format output options.
|
81 |
+
|
82 |
+
#### For more visual and inference results of the models, please refer to the [PDF-Extract-Kit tutorial documentation](xxx).
|
83 |
+
|
84 |
+
## Evaluation Metrics
|
85 |
+
|
86 |
+
Coming Soon!
|
87 |
+
|
88 |
+
## Usage Guide
|
89 |
+
|
90 |
+
### Environment Setup
|
91 |
+
|
92 |
+
```bash
|
93 |
+
conda create -n pdf-extract-kit-1.0 python=3.10
|
94 |
+
conda activate pdf-extract-kit-1.0
|
95 |
+
pip install -r requirements.txt
|
96 |
+
```
|
97 |
+
> **Note:** If your device does not support GPU, please install the CPU version dependencies using `requirements-cpu.txt` instead of `requirements.txt`.
|
98 |
+
|
99 |
+
> **Note:** Current Doclayout-YOLO only supports installation from pypi,if error raises during DocLayout-YOLO installation,please install through `pip3 install doclayout-yolo==0.0.2 --extra-index-url=https://pypi.org/simple` .
|
100 |
+
|
101 |
+
### Model Download
|
102 |
+
|
103 |
+
Please refer to the [Model Weights Download Tutorial](https://pdf-extract-kit.readthedocs.io/en/latest/get_started/pretrained_model.html) to download the required model weights. Note: You can choose to download all the weights or select specific ones. For detailed instructions, please refer to the tutorial.
|
104 |
+
|
105 |
+
### Running Demos
|
106 |
+
|
107 |
+
#### Layout Detection Model
|
108 |
+
|
109 |
+
```bash
|
110 |
+
python scripts/layout_detection.py --config=configs/layout_detection.yaml
|
111 |
+
```
|
112 |
+
Layout detection models support **DocLayout-YOLO** (default model), YOLO-v10, and LayoutLMv3. For YOLO-v10 and LayoutLMv3, please refer to [Layout Detection Algorithm](https://pdf-extract-kit.readthedocs.io/en/latest/algorithm/layout_detection.html). You can view the layout detection results in the `outputs/layout_detection` folder.
|
113 |
+
|
114 |
+
#### Formula Detection Model
|
115 |
+
|
116 |
+
```bash
|
117 |
+
python scripts/formula_detection.py --config=configs/formula_detection.yaml
|
118 |
+
```
|
119 |
+
You can view the formula detection results in the `outputs/formula_detection` folder.
|
120 |
+
|
121 |
+
#### OCR Model
|
122 |
+
|
123 |
+
```bash
|
124 |
+
python scripts/ocr.py --config=configs/ocr.yaml
|
125 |
+
```
|
126 |
+
You can view the OCR results in the `outputs/ocr` folder.
|
127 |
+
|
128 |
+
#### Formula Recognition Model
|
129 |
+
|
130 |
+
```bash
|
131 |
+
python scripts/formula_recognition.py --config=configs/formula_recognition.yaml
|
132 |
+
```
|
133 |
+
You can view the formula recognition results in the `outputs/formula_recognition` folder.
|
134 |
+
|
135 |
+
#### Table Recognition Model
|
136 |
+
|
137 |
+
```bash
|
138 |
+
python scripts/table_parsing.py --config configs/table_parsing.yaml
|
139 |
+
```
|
140 |
+
You can view the table recognition results in the `outputs/table_parsing` folder.
|
141 |
+
|
142 |
+
> **Note:** For more details on using the model, please refer to the[PDF-Extract-Kit-1.0 Tutorial](https://pdf-extract-kit.readthedocs.io/en/latest/get_started/pretrained_model.html).
|
143 |
+
|
144 |
+
> This project focuses on using models for `high-quality` content extraction from `diverse` documents and does not involve reconstructing extracted content into new documents, such as PDF to Markdown. For such needs, please refer to our other GitHub project: [MinerU](https://github.com/opendatalab/MinerU).
|
145 |
+
|
146 |
+
## To-Do List
|
147 |
+
|
148 |
+
- [x] **Table Parsing**: Develop functionality to convert table images into corresponding LaTeX/Markdown format source code.
|
149 |
+
- [ ] **Chemical Equation Detection**: Implement automatic detection of chemical equations.
|
150 |
+
- [ ] **Chemical Equation/Diagram Recognition**: Develop models to recognize and parse chemical equations and diagrams.
|
151 |
+
- [ ] **Reading Order Sorting Model**: Build a model to determine the correct reading order of text in documents.
|
152 |
+
|
153 |
+
**PDF-Extract-Kit** aims to provide high-quality PDF content extraction capabilities. We encourage the community to propose specific and valuable needs and welcome everyone to participate in continuously improving the PDF-Extract-Kit tool to advance research and industry development.
|
154 |
+
|
155 |
+
## License
|
156 |
+
|
157 |
+
This project is open-sourced under the [AGPL-3.0](LICENSE) license.
|
158 |
+
|
159 |
+
Since this project uses YOLO code and PyMuPDF for file processing, these components require compliance with the AGPL-3.0 license. Therefore, to ensure adherence to the licensing requirements of these dependencies, this repository as a whole adopts the AGPL-3.0 license.
|
160 |
+
|
161 |
+
## Acknowledgement
|
162 |
+
|
163 |
+
- [LayoutLMv3](https://github.com/microsoft/unilm/tree/master/layoutlmv3): Layout detection model
|
164 |
+
- [UniMERNet](https://github.com/opendatalab/UniMERNet): Formula recognition model
|
165 |
+
- [StructEqTable](https://github.com/UniModal4Reasoning/StructEqTable-Deploy): Table recognition model
|
166 |
+
- [YOLO](https://github.com/ultralytics/ultralytics): Formula detection model
|
167 |
+
- [PaddleOCR](https://github.com/PaddlePaddle/PaddleOCR): OCR model
|
168 |
+
- [DocLayout-YOLO](https://github.com/opendatalab/DocLayout-YOLO): Layout detection model
|
169 |
+
|
170 |
+
## Citation
|
171 |
+
If you find our models / code / papers useful in your research, please consider giving ⭐ and citations 📝, thx :)
|
172 |
+
```bibtex
|
173 |
+
@article{wang2024mineru,
|
174 |
+
title={MinerU: An Open-Source Solution for Precise Document Content Extraction},
|
175 |
+
author={Wang, Bin and Xu, Chao and Zhao, Xiaomeng and Ouyang, Linke and Wu, Fan and Zhao, Zhiyuan and Xu, Rui and Liu, Kaiwen and Qu, Yuan and Shang, Fukai and others},
|
176 |
+
journal={arXiv preprint arXiv:2409.18839},
|
177 |
+
year={2024}
|
178 |
+
}
|
179 |
+
|
180 |
+
@misc{zhao2024doclayoutyoloenhancingdocumentlayout,
|
181 |
+
title={DocLayout-YOLO: Enhancing Document Layout Analysis through Diverse Synthetic Data and Global-to-Local Adaptive Perception},
|
182 |
+
author={Zhiyuan Zhao and Hengrui Kang and Bin Wang and Conghui He},
|
183 |
+
year={2024},
|
184 |
+
eprint={2410.12628},
|
185 |
+
archivePrefix={arXiv},
|
186 |
+
primaryClass={cs.CV},
|
187 |
+
url={https://arxiv.org/abs/2410.12628},
|
188 |
+
}
|
189 |
+
|
190 |
+
@misc{wang2024unimernet,
|
191 |
+
title={UniMERNet: A Universal Network for Real-World Mathematical Expression Recognition},
|
192 |
+
author={Bin Wang and Zhuangcheng Gu and Chao Xu and Bo Zhang and Botian Shi and Conghui He},
|
193 |
+
year={2024},
|
194 |
+
eprint={2404.15254},
|
195 |
+
archivePrefix={arXiv},
|
196 |
+
primaryClass={cs.CV}
|
197 |
+
}
|
198 |
+
|
199 |
+
@article{he2024opendatalab,
|
200 |
+
title={Opendatalab: Empowering general artificial intelligence with open datasets},
|
201 |
+
author={He, Conghui and Li, Wei and Jin, Zhenjiang and Xu, Chao and Wang, Bin and Lin, Dahua},
|
202 |
+
journal={arXiv preprint arXiv:2407.13773},
|
203 |
+
year={2024}
|
204 |
+
}
|
205 |
+
```
|
206 |
+
|
207 |
+
## Star History
|
208 |
+
|
209 |
+
<a>
|
210 |
+
<picture>
|
211 |
+
<source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=opendatalab/PDF-Extract-Kit&type=Date&theme=dark" />
|
212 |
+
<source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/svg?repos=opendatalab/PDF-Extract-Kit&type=Date" />
|
213 |
+
<img alt="Star History Chart" src="https://api.star-history.com/svg?repos=opendatalab/PDF-Extract-Kit&type=Date" />
|
214 |
+
</picture>
|
215 |
+
</a>
|
216 |
+
|
217 |
+
## Related Links
|
218 |
+
- [UniMERNet (Real-World Formula Recognition Algorithm)](https://github.com/opendatalab/UniMERNet)
|
219 |
+
- [LabelU (Lightweight Multimodal Annotation Tool)](https://github.com/opendatalab/labelU)
|
220 |
+
- [LabelLLM (Open Source LLM Dialogue Annotation Platform)](https://github.com/opendatalab/LabelLLM)
|
221 |
+
- [MinerU (One-Stop High-Quality Data Extraction Tool)](https://github.com/opendatalab/MinerU)
|
PDF-Extract-Kit/README_zh-CN.md
ADDED
@@ -0,0 +1,239 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
<p align="center">
|
3 |
+
<img src="assets/readme/pdf-extract-kit_logo.png" width="220px" style="vertical-align:middle;">
|
4 |
+
</p>
|
5 |
+
|
6 |
+
<div align="center">
|
7 |
+
|
8 |
+
[English](./README.md) | 简体中文
|
9 |
+
|
10 |
+
[PDF-Extract-Kit-1.0中文教程](https://pdf-extract-kit.readthedocs.io/zh-cn/latest/get_started/pretrained_model.html)
|
11 |
+
|
12 |
+
[[Models (🤗Hugging Face)]](https://huggingface.co/opendatalab/PDF-Extract-Kit-1.0) | [[Models(<img src="./assets/readme/modelscope_logo.png" width="20px">ModelScope)]](https://www.modelscope.cn/models/OpenDataLab/PDF-Extract-Kit-1.0)
|
13 |
+
|
14 |
+
🔥🔥🔥 [MinerU:基于PDF-Extract-Kit的高效文档内容提取工具](https://github.com/opendatalab/MinerU)
|
15 |
+
</div>
|
16 |
+
|
17 |
+
<p align="center">
|
18 |
+
👋 join us on <a href="https://discord.gg/JYsXDXXN" target="_blank">Discord</a> and <a href="https://r.vansin.top/?r=MinerU" target="_blank">WeChat</a>
|
19 |
+
</p>
|
20 |
+
|
21 |
+
|
22 |
+
## 整体介绍
|
23 |
+
|
24 |
+
`PDF-Extract-Kit` 是一款功能强大的开源工具箱,旨在从复杂多样的 PDF 文档中高效提取高质量内容。以下是其主要功能和优势:
|
25 |
+
|
26 |
+
- **集成文档解析主流模型**:汇聚布局检测、公式检测、公式识别、OCR等文档解析核心任务的众多SOTA模型;
|
27 |
+
- **多样性文档下高质量解析结果**:结合多样性文档标注数据在进行模型微调,在复杂多样的文档下提供高质量解析结果;
|
28 |
+
- **模块化设计**:模块化设计使用户可以通过修改配置文件及少量代码即可自由组合构建各种应用,让应用构建像搭积木一样简便;
|
29 |
+
- **全面评测基准**:提供多样性全面的PDF评测基准,用户可根据评测结果选择最适合自己的模型。
|
30 |
+
|
31 |
+
**立即体验 PDF-Extract-Kit,解锁 PDF 文档的无限潜力!**
|
32 |
+
|
33 |
+
> **注意:** PDF-Extract-Kit 专注于高质量文档处理,适合作为模型工具箱使用。
|
34 |
+
> 如果你想提取高质量文档内容(PDF转Markdown),请直接使用[MinerU](https://github.com/opendatalab/MinerU),MinerU结合PDF-Extract-Kit的高质量预测结果,进行了专门的工程优化,使得PDF文档内容提取更加便捷高效;
|
35 |
+
> 如果你是一位开发者,希望搭建更多有意思的应用(如文档翻译,文档问答,文档助手等),基于PDF-Extract-Kit自行进行DIY将会十分便捷。特别地,我们会在`PDF-Extract-Kit/project`下面不定期更新一些有趣的应用,敬请期待!
|
36 |
+
|
37 |
+
**我们欢迎社区研究员和工程师贡献优秀模型和创新应用,通过提交 PR 成为 PDF-Extract-Kit 的贡献者。**
|
38 |
+
|
39 |
+
|
40 |
+
## 模型概览
|
41 |
+
|
42 |
+
| **任务类型** | **任务描述** | **模型** |
|
43 |
+
|--------------|---------------------------------------------------------------------------------|------------------------------|
|
44 |
+
| **布局检测** | 定位文档中不同元素位置:包含图像、表格、文本、标题、公式等 | `DocLayout-YOLO_ft`, `YOLO-v10_ft`, `LayoutLMv3_ft` |
|
45 |
+
| **公式检测** | 定位文档中公式位置:包含行内公式和行间公式 | `YOLOv8_ft` |
|
46 |
+
| **公式识别** | 识别公式图像为latex源码 | `UniMERNet` |
|
47 |
+
| **OCR** | 提取图像中的文本内容(包括定位和识别) | `PaddleOCR` |
|
48 |
+
| **表格识别** | 识别表格图像为对应源码(Latex/HTML/Markdown) | `PaddleOCR+TableMaster`,`StructEqTable` |
|
49 |
+
| **阅读顺序** | 将离散的文本段落进行排序拼接 | Coming Soon ! |
|
50 |
+
|
51 |
+
|
52 |
+
|
53 |
+
## 新闻和更新
|
54 |
+
- `2024.10.22` 🎉🎉🎉 支持LaTex和HTML等多种输出格式的表格模型[StructTable-InternVL2-1B](https://huggingface.co/U4R/StructTable-InternVL2-1B)正式接入`PDF-Extract-Kit 1.0`,请参考[表格识别算法文档](https://pdf-extract-kit.readthedocs.io/zh-cn/latest/algorithm/table_recognition.html)进行使用!
|
55 |
+
- `2024.10.17` 🎉🎉🎉 检测结果更准确,速度更快的布局检测模型`DocLayout-YOLO`正式接入`PDF-Extract-Kit 1.0`,请参考[布局检测算法文档](https://pdf-extract-kit.readthedocs.io/zh-cn/latest/algorithm/layout_detection.html)进行使用!
|
56 |
+
- `2024.10.10` 🎉🎉🎉 基于模块化重构的`PDF-Extract-Kit 1.0`正式版本正式发布,模型使用更加便捷灵活!老版本请切换至[release/0.1.1](https://github.com/opendatalab/PDF-Extract-Kit/tree/release/0.1.1)分支进行使用。
|
57 |
+
- `2024.08.01` 🎉🎉🎉 新增了[StructEqTable](demo/TabRec/StructEqTable/README_TABLE.md)表格识别模块用于表格内容提取,欢迎使用!
|
58 |
+
- `2024.07.01` 🎉🎉🎉 我们发布了`PDF-Extract-Kit`,一个用于高质量PDF内容提取的综合工具包,包括`布局检测`、`公式检测`、`公式识别`和`OCR`。
|
59 |
+
|
60 |
+
|
61 |
+
|
62 |
+
## 效果展示
|
63 |
+
|
64 |
+
当前的一些开源SOTA模型多基于学术数据集进行训练评测,仅能在单一的文档类型上获取高质量结果。为了使得模型能够在多样性文档上也能获得稳定鲁棒的高质量结果,我们构建多样性的微调数据集,并在一些SOTA模型上微调已得到可实用解析模型。下边是一些模型的可视化结果。
|
65 |
+
|
66 |
+
### 布局检测
|
67 |
+
|
68 |
+
结合多样性PDF文档标注,我们训练了鲁棒的`布局检测`模型。在论文、教材、研报、财报等多样性的PDF文档上,我们微调后的模型都能得到准确的提取结果,对于扫描模糊、水印等情况也有较高鲁棒性。下面可视化示例是经过微调后的LayoutLMv3模型的推理结果。
|
69 |
+
|
70 |
+

|
71 |
+
|
72 |
+
|
73 |
+
### 公式检测
|
74 |
+
|
75 |
+
同样的,我们收集了包含公式的中英文文档进行标注,基于先进的公式检测模型进行微调,下面可视化结果是微调后的YOLO公式检测模型的推理结果:
|
76 |
+
|
77 |
+

|
78 |
+
|
79 |
+
|
80 |
+
### 公式识别
|
81 |
+
|
82 |
+
[UniMERNet](https://github.com/opendatalab/UniMERNet)是针对真实场景下多样性公式识别的算法,通过构建大规模训练数据及精心设计的结果,使得其可以对复杂长公式、手写公式、含噪声的截图公式均有不错的识别效果。
|
83 |
+
|
84 |
+
### 表格识别
|
85 |
+
|
86 |
+
[StructEqTable](https://github.com/UniModal4Reasoning/StructEqTable-Deploy)是一个高效表格内容提取工具,能够将表格图像转换为LaTeX/HTML/Markdown格式,最新版本使用InternVL2-1B基础模型,提高了中文识别准确度并增加了多格式输出能力。
|
87 |
+
|
88 |
+
#### 更多模型的可视化结果及推理结果可以参考[PDF-Extract-Kit教程文档](xxx)
|
89 |
+
|
90 |
+
|
91 |
+
## 评测指标
|
92 |
+
|
93 |
+
Coming Soon!
|
94 |
+
|
95 |
+
## 使用教程
|
96 |
+
|
97 |
+
### 环境安装
|
98 |
+
|
99 |
+
```bash
|
100 |
+
conda create -n pdf-extract-kit-1.0 python=3.10
|
101 |
+
conda activate pdf-extract-kit-1.0
|
102 |
+
pip install -r requirements.txt
|
103 |
+
```
|
104 |
+
> **注意:** 如果你的设备不支持 GPU,请使用 `requirements-cpu.txt` 安装 CPU 版本的依赖。
|
105 |
+
|
106 |
+
> **注意:** 目前doclayout-yolo仅支持从pypi源安装,如果出现doclayout-yolo无法安装,请通过 `pip3 install doclayout-yolo==0.0.2 --extra-index-url=https://pypi.org/simple` 安装。
|
107 |
+
|
108 |
+
### 模型下载
|
109 |
+
|
110 |
+
参考[模型权重下载教程](https://pdf-extract-kit.readthedocs.io/zh-cn/latest/get_started/pretrained_model.html)下载所需模型权重。注:可以选择全部下载,也可以选择部分下载,具体操作参考教程。
|
111 |
+
|
112 |
+
|
113 |
+
### Demo运行
|
114 |
+
|
115 |
+
#### 布局检测模型
|
116 |
+
|
117 |
+
```bash
|
118 |
+
python scripts/layout_detection.py --config=configs/layout_detection.yaml
|
119 |
+
```
|
120 |
+
布局检测模型支持**DocLayout-YOLO**(默认模型),YOLO-v10,以及LayoutLMv3。对于YOLO-v10和LayoutLMv3的布局检测,请参考[Layout Detection Algorithm](https://pdf-extract-kit.readthedocs.io/zh-cn/latest/algorithm/layout_detection.html)。你可以在 `outputs/layout_detection` 文件夹下查看布局检测结果。
|
121 |
+
|
122 |
+
#### 公式检测模型
|
123 |
+
|
124 |
+
```bash
|
125 |
+
python scripts/formula_detection.py --config=configs/formula_detection.yaml
|
126 |
+
```
|
127 |
+
你可以在 `outputs/formula_detection` 文件夹下查看公式检测结果。
|
128 |
+
|
129 |
+
|
130 |
+
#### 文本识别(OCR)模型
|
131 |
+
|
132 |
+
```bash
|
133 |
+
python scripts/ocr.py --config=configs/ocr.yaml
|
134 |
+
```
|
135 |
+
你可以在 `outputs/ocr` 文件夹下查看OCR结果。
|
136 |
+
|
137 |
+
|
138 |
+
#### 公式识别模型
|
139 |
+
|
140 |
+
```bash
|
141 |
+
python scripts/formula_recognition.py --config=configs/formula_recognition.yaml
|
142 |
+
```
|
143 |
+
你可以在 `outputs/formula_recognition` 文件夹下查看公式识别结果。
|
144 |
+
|
145 |
+
|
146 |
+
#### 表格识别模型
|
147 |
+
|
148 |
+
```bash
|
149 |
+
python scripts/table_parsing.py --config configs/table_parsing.yaml
|
150 |
+
```
|
151 |
+
你可以在 `outputs/table_parsing` 文件夹下查看表格内容识别结果。
|
152 |
+
|
153 |
+
|
154 |
+
> **注意:** 更多模型使用细节请查看[PDF-Extract-Kit-1.0 中文教程](https://pdf-extract-kit.readthedocs.io/zh-cn/latest/get_started/pretrained_model.html).
|
155 |
+
|
156 |
+
> 本项目专注使用模型对`多样性`文档进行`高质量`内容提取,不涉及提取后内容拼接成新文档,如PDF转Markdown。如果有此类需求,请参考我们另一个Github项目: [MinerU](https://github.com/opendatalab/MinerU)
|
157 |
+
|
158 |
+
|
159 |
+
## 待办事项
|
160 |
+
|
161 |
+
- [x] **表格解析**:开发能够将表格图像转换成对应的LaTeX/Markdown格式源码的功能。
|
162 |
+
- [ ] **化学方程式检测**:实现对化学方程式的自动检测。
|
163 |
+
- [ ] **化学方程式/图解识别**:开发识别并解析化学方程式的模型。
|
164 |
+
- [ ] **阅读顺序排序模型**:构建模型以确定文档中文本的正确阅读顺序。
|
165 |
+
|
166 |
+
**PDF-Extract-Kit** 旨在提供高质量PDF文件的提取能力。我们鼓励社区提出具体且有价值的需求,并欢迎大家共同参与,以不断改进PDF-Extract-Kit工具,推动科研及产业发展。
|
167 |
+
|
168 |
+
|
169 |
+
## 协议
|
170 |
+
|
171 |
+
本项目采用 [AGPL-3.0](LICENSE) 协议开源。
|
172 |
+
|
173 |
+
由于本项目中使用了 YOLO 代码和 PyMuPDF 进行文件处理,这些组件都需要遵循 AGPL-3.0 协议。因此,为了确保遵守这些依赖项的许可证要求,本仓库整体采用 AGPL-3.0 协议。
|
174 |
+
|
175 |
+
|
176 |
+
## 致谢
|
177 |
+
|
178 |
+
- [LayoutLMv3](https://github.com/microsoft/unilm/tree/master/layoutlmv3): 布局检测模型
|
179 |
+
- [UniMERNet](https://github.com/opendatalab/UniMERNet): 公式识别模型
|
180 |
+
- [StructEqTable](https://github.com/UniModal4Reasoning/StructEqTable-Deploy): 表格识别模型
|
181 |
+
- [YOLO](https://github.com/ultralytics/ultralytics): 公式检测模型
|
182 |
+
- [PaddleOCR](https://github.com/PaddlePaddle/PaddleOCR): OCR模型
|
183 |
+
- [DocLayout-YOLO](https://github.com/opendatalab/DocLayout-YOLO): 布局检测模型
|
184 |
+
|
185 |
+
|
186 |
+
## Citation
|
187 |
+
|
188 |
+
如果你觉得我们模型/代码/技术报告对你有帮助,请给我们⭐和引用📝,谢谢 :)
|
189 |
+
```bibtex
|
190 |
+
@article{wang2024mineru,
|
191 |
+
title={MinerU: An Open-Source Solution for Precise Document Content Extraction},
|
192 |
+
author={Wang, Bin and Xu, Chao and Zhao, Xiaomeng and Ouyang, Linke and Wu, Fan and Zhao, Zhiyuan and Xu, Rui and Liu, Kaiwen and Qu, Yuan and Shang, Fukai and others},
|
193 |
+
journal={arXiv preprint arXiv:2409.18839},
|
194 |
+
year={2024}
|
195 |
+
}
|
196 |
+
|
197 |
+
@misc{wang2024unimernet,
|
198 |
+
title={UniMERNet: A Universal Network for Real-World Mathematical Expression Recognition},
|
199 |
+
author={Bin Wang and Zhuangcheng Gu and Chao Xu and Bo Zhang and Botian Shi and Conghui He},
|
200 |
+
year={2024},
|
201 |
+
eprint={2404.15254},
|
202 |
+
archivePrefix={arXiv},
|
203 |
+
primaryClass={cs.CV}
|
204 |
+
}
|
205 |
+
|
206 |
+
@misc{zhao2024doclayoutyoloenhancingdocumentlayout,
|
207 |
+
title={DocLayout-YOLO: Enhancing Document Layout Analysis through Diverse Synthetic Data and Global-to-Local Adaptive Perception},
|
208 |
+
author={Zhiyuan Zhao and Hengrui Kang and Bin Wang and Conghui He},
|
209 |
+
year={2024},
|
210 |
+
eprint={2410.12628},
|
211 |
+
archivePrefix={arXiv},
|
212 |
+
primaryClass={cs.CV},
|
213 |
+
url={https://arxiv.org/abs/2410.12628},
|
214 |
+
}
|
215 |
+
|
216 |
+
@article{he2024opendatalab,
|
217 |
+
title={Opendatalab: Empowering general artificial intelligence with open datasets},
|
218 |
+
author={He, Conghui and Li, Wei and Jin, Zhenjiang and Xu, Chao and Wang, Bin and Lin, Dahua},
|
219 |
+
journal={arXiv preprint arXiv:2407.13773},
|
220 |
+
year={2024}
|
221 |
+
}
|
222 |
+
```
|
223 |
+
|
224 |
+
|
225 |
+
## Star历史
|
226 |
+
|
227 |
+
<a>
|
228 |
+
<picture>
|
229 |
+
<source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=opendatalab/PDF-Extract-Kit&type=Date&theme=dark" />
|
230 |
+
<source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/svg?repos=opendatalab/PDF-Extract-Kit&type=Date" />
|
231 |
+
<img alt="Star History Chart" src="https://api.star-history.com/svg?repos=opendatalab/PDF-Extract-Kit&type=Date" />
|
232 |
+
</picture>
|
233 |
+
</a>
|
234 |
+
|
235 |
+
## 友情链接
|
236 |
+
- [UniMERNet(真实场景公式识别算法)](https://github.com/opendatalab/UniMERNet)
|
237 |
+
- [LabelU(轻量级多模态标注工具)](https://github.com/opendatalab/labelU)
|
238 |
+
- [LabelLLM(开源LLM对话标注平台)](https://github.com/opendatalab/LabelLLM)
|
239 |
+
- [MinerU(一站式高质量数据提取工具)](https://github.com/opendatalab/MinerU)
|
PDF-Extract-Kit/assets/demo/PDFs/DDPM.pdf
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:aee5e07a802e8dfd2a386374c94fd61d1d056cb7e1e0fec4f28e8120ff5d8505
|
3 |
+
size 10267274
|
PDF-Extract-Kit/assets/demo/PDFs/UniMERNet.pdf
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:66a7fb0a7ea057c3222893b838cdae1ef20d79acecb265bbc35333509a99e2dd
|
3 |
+
size 6888984
|
PDF-Extract-Kit/assets/demo/formula_detection/textbook.png
ADDED
![]() |
Git LFS Details
|
PDF-Extract-Kit/assets/demo/formula_detection/wikipedia_sce.png
ADDED
![]() |
Git LFS Details
|
PDF-Extract-Kit/assets/demo/formula_recognition/cpe.png
ADDED
![]() |
PDF-Extract-Kit/assets/demo/formula_recognition/hwe.png
ADDED
![]() |
PDF-Extract-Kit/assets/demo/formula_recognition/sce.png
ADDED
![]() |
PDF-Extract-Kit/assets/demo/formula_recognition/spe.png
ADDED
![]() |
PDF-Extract-Kit/assets/demo/layout_detection/exam_paper.png
ADDED
![]() |
Git LFS Details
|
PDF-Extract-Kit/assets/demo/layout_detection/financial_report.png
ADDED
![]() |
Git LFS Details
|
PDF-Extract-Kit/assets/demo/layout_detection/fuzzy_scan.png
ADDED
![]() |
Git LFS Details
|
PDF-Extract-Kit/assets/demo/layout_detection/paper.png
ADDED
![]() |
Git LFS Details
|
PDF-Extract-Kit/assets/demo/layout_detection/slides.png
ADDED
![]() |
Git LFS Details
|
PDF-Extract-Kit/assets/demo/layout_detection/watermark.png
ADDED
![]() |
Git LFS Details
|
PDF-Extract-Kit/assets/demo/ocr/ocr_001.png
ADDED
![]() |
Git LFS Details
|
PDF-Extract-Kit/assets/demo/ocr/ocr_002.png
ADDED
![]() |
Git LFS Details
|
PDF-Extract-Kit/assets/demo/table_parsing/table_001.png
ADDED
![]() |
Git LFS Details
|
PDF-Extract-Kit/assets/readme/datalab_logo.png
ADDED
![]() |
PDF-Extract-Kit/assets/readme/layout_example.png
ADDED
![]() |
Git LFS Details
|
PDF-Extract-Kit/assets/readme/mfd_example.png
ADDED
![]() |
Git LFS Details
|
PDF-Extract-Kit/assets/readme/modelscope_logo.png
ADDED
![]() |
PDF-Extract-Kit/assets/readme/pdf-extract-kit_logo.png
ADDED
![]() |
PDF-Extract-Kit/assets/readme/pipeline.png
ADDED
![]() |
Git LFS Details
|
PDF-Extract-Kit/assets/readme/table_expamle.png
ADDED
![]() |
Git LFS Details
|
PDF-Extract-Kit/assets/readme/unimernet_result.jpg
ADDED
![]() |
Git LFS Details
|
PDF-Extract-Kit/configs/config.yaml
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
inputs: assets/demo/formula_detection_pdfs
|
2 |
+
outputs: outputs/formula_detection_pdfs
|
3 |
+
tasks:
|
4 |
+
formula_detection:
|
5 |
+
model: formula_detection_yolo
|
6 |
+
model_config:
|
7 |
+
img_size: 1280
|
8 |
+
conf_thres: 0.25
|
9 |
+
iou_thres: 0.45
|
10 |
+
model_path: models/MFD/weights.pt
|
11 |
+
visualize: True
|
12 |
+
formula_recognition:
|
13 |
+
model: formula_recognition_unimernet
|
14 |
+
model_config:
|
15 |
+
cfg_path: pdf_extract_kit/configs/unimernet.yaml
|
16 |
+
model_path: models/MFR/UniMERNet
|
17 |
+
visualize: True
|
PDF-Extract-Kit/configs/formula_detection.yaml
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
inputs: assets/demo/formula_detection
|
2 |
+
outputs: outputs/formula_detection
|
3 |
+
tasks:
|
4 |
+
formula_detection:
|
5 |
+
model: formula_detection_yolo
|
6 |
+
model_config:
|
7 |
+
img_size: 1280
|
8 |
+
conf_thres: 0.25
|
9 |
+
iou_thres: 0.45
|
10 |
+
batch_size: 1
|
11 |
+
model_path: models/MFD/YOLO/yolo_v8_ft.pt
|
12 |
+
visualize: True
|
PDF-Extract-Kit/configs/formula_recognition.yaml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
inputs: assets/demo/formula_recognition
|
2 |
+
outputs: outputs/formula_recognition
|
3 |
+
tasks:
|
4 |
+
formula_recognition:
|
5 |
+
model: formula_recognition_unimernet
|
6 |
+
model_config:
|
7 |
+
cfg_path: pdf_extract_kit/configs/unimernet.yaml
|
8 |
+
model_path: models/MFR/unimernet_tiny
|
9 |
+
visualize: False
|
PDF-Extract-Kit/configs/layout_detection.yaml
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
inputs: assets/demo/layout_detection
|
2 |
+
outputs: outputs/layout_detection
|
3 |
+
tasks:
|
4 |
+
layout_detection:
|
5 |
+
model: layout_detection_yolo
|
6 |
+
model_config:
|
7 |
+
img_size: 1024
|
8 |
+
conf_thres: 0.25
|
9 |
+
iou_thres: 0.45
|
10 |
+
model_path: models/Layout/YOLO/doclayout_yolo_ft.pt
|
11 |
+
visualize: True
|
PDF-Extract-Kit/configs/layout_detection_layoutlmv3.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
inputs: assets/demo/layout_detection
|
2 |
+
outputs: outputs/layout_detection
|
3 |
+
tasks:
|
4 |
+
layout_detection:
|
5 |
+
model: layout_detection_layoutlmv3
|
6 |
+
model_config:
|
7 |
+
model_path: models/Layout/LayoutLMv3/model_final.pth
|
PDF-Extract-Kit/configs/layout_detection_yolo.yaml
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
inputs: assets/demo/layout_detection
|
2 |
+
outputs: outputs/layout_detection
|
3 |
+
tasks:
|
4 |
+
layout_detection:
|
5 |
+
model: layout_detection_yolo
|
6 |
+
model_config:
|
7 |
+
img_size: 1024
|
8 |
+
conf_thres: 0.25
|
9 |
+
iou_thres: 0.45
|
10 |
+
model_path: models/Layout/YOLO/doclayout_yolo_ft.pt
|
11 |
+
visualize: True
|
12 |
+
device: 0
|
PDF-Extract-Kit/configs/ocr.yaml
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
inputs: assets/demo/ocr
|
2 |
+
outputs: outputs/ocr
|
3 |
+
visualize: True
|
4 |
+
tasks:
|
5 |
+
ocr:
|
6 |
+
model: ocr_ppocr
|
7 |
+
model_config:
|
8 |
+
lang: ch
|
9 |
+
show_log: True
|
10 |
+
det_model_dir: models/OCR/PaddleOCR/det/ch_PP-OCRv4_det
|
11 |
+
rec_model_dir: models/OCR/PaddleOCR/rec/ch_PP-OCRv4_rec
|
12 |
+
det_db_box_thresh: 0.3
|
PDF-Extract-Kit/configs/table_parsing.yaml
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
inputs: assets/demo/table_parsing
|
2 |
+
outputs: outputs/table_parsing
|
3 |
+
tasks:
|
4 |
+
table_parsing:
|
5 |
+
model: table_parsing_struct_eqtable
|
6 |
+
model_config:
|
7 |
+
model_path: models/TabRec/StructEqTable
|
8 |
+
max_new_tokens: 1024
|
9 |
+
max_time: 30
|
10 |
+
output_format: latex
|
11 |
+
lmdeploy: False
|
12 |
+
flash_atten: True
|
PDF-Extract-Kit/docs/en/.readthedocs.yaml
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
version: 2
|
2 |
+
|
3 |
+
build:
|
4 |
+
os: ubuntu-22.04
|
5 |
+
tools:
|
6 |
+
python: "3.10"
|
7 |
+
|
8 |
+
formats:
|
9 |
+
- epub
|
10 |
+
|
11 |
+
python:
|
12 |
+
install:
|
13 |
+
- requirements: requirements/docs.txt
|
14 |
+
|
15 |
+
sphinx:
|
16 |
+
configuration: docs/en/conf.py
|
PDF-Extract-Kit/docs/en/Makefile
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Minimal makefile for Sphinx documentation
|
2 |
+
#
|
3 |
+
|
4 |
+
# You can set these variables from the command line, and also
|
5 |
+
# from the environment for the first two.
|
6 |
+
SPHINXOPTS ?=
|
7 |
+
SPHINXBUILD ?= sphinx-build
|
8 |
+
SOURCEDIR = .
|
9 |
+
BUILDDIR = _build
|
10 |
+
|
11 |
+
# Put it first so that "make" without argument is like "make help".
|
12 |
+
help:
|
13 |
+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
14 |
+
|
15 |
+
.PHONY: help Makefile
|
16 |
+
|
17 |
+
# Catch-all target: route all unknown targets to Sphinx using the new
|
18 |
+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
|
19 |
+
%: Makefile
|
20 |
+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
PDF-Extract-Kit/docs/en/_static/image/logo.png
ADDED
![]() |
PDF-Extract-Kit/docs/en/algorithm/formula_detection.rst
ADDED
@@ -0,0 +1,91 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.. _algorithm_formula_detection:
|
2 |
+
|
3 |
+
====================
|
4 |
+
Formula Detection Algorithm
|
5 |
+
====================
|
6 |
+
|
7 |
+
Introduction
|
8 |
+
====================
|
9 |
+
|
10 |
+
Formula detection involves identifying the positions of all formulas (including inline and block formulas) in a given input image.
|
11 |
+
|
12 |
+
.. note::
|
13 |
+
|
14 |
+
Formula detection is technically a subtask of layout detection. However, due to its complexity, we recommend using a dedicated formula detection model to decouple it. This approach typically makes data annotation easier and improves detection performance.
|
15 |
+
|
16 |
+
Model Usage
|
17 |
+
====================
|
18 |
+
|
19 |
+
With the environment properly set up, simply run the layout detection algorithm script by executing ``scripts/formula_detection.py``.
|
20 |
+
|
21 |
+
.. code:: shell
|
22 |
+
|
23 |
+
$ python scripts/formula_detection.py --config configs/formula_detection.yaml
|
24 |
+
|
25 |
+
Model Configuration
|
26 |
+
--------------------
|
27 |
+
|
28 |
+
.. code:: yaml
|
29 |
+
|
30 |
+
inputs: assets/demo/formula_detection
|
31 |
+
outputs: outputs/formula_detection
|
32 |
+
tasks:
|
33 |
+
formula_detection:
|
34 |
+
model: formula_detection_yolo
|
35 |
+
model_config:
|
36 |
+
img_size: 1280
|
37 |
+
conf_thres: 0.25
|
38 |
+
iou_thres: 0.45
|
39 |
+
batch_size: 1
|
40 |
+
model_path: models/MFD/yolov8/weights.pt
|
41 |
+
visualize: True
|
42 |
+
|
43 |
+
- inputs/outputs: Define the input file path and the visualization output directory, respectively.
|
44 |
+
- tasks: Define the task type, currently only a formula detection task is included.
|
45 |
+
- model: Define the specific model type: currently, only the YOLO formula detection model is available.
|
46 |
+
- model_config: Define the model configuration.
|
47 |
+
- img_size: Define the image's longer side size; the shorter side will be scaled proportionally.
|
48 |
+
- conf_thres: Define the confidence threshold; only targets above this threshold will be detected.
|
49 |
+
- iou_thres: Define the IoU threshold to remove targets with an overlap greater than this value.
|
50 |
+
- batch_size: Define the batch size; the number of images inferred simultaneously. Generally, the larger the batch size, the faster the inference speed. A better GPU allows for a larger batch size.
|
51 |
+
- model_path: Path to the model weights.
|
52 |
+
- visualize: Whether to visualize the model results. Visualized results will be saved in the outputs directory.
|
53 |
+
|
54 |
+
Diverse Input Support
|
55 |
+
--------------------
|
56 |
+
|
57 |
+
The formula detection script in PDF-Extract-Kit supports various input formats such as ``a single image``, ``a directory of image files``, ``a single PDF file``, and ``a directory of PDF files``.
|
58 |
+
|
59 |
+
.. note::
|
60 |
+
|
61 |
+
Modify the ``inputs`` path in ``configs/formula_detection.yaml`` according to your actual data format:
|
62 |
+
- Single image: path/to/image
|
63 |
+
- Image directory: path/to/images
|
64 |
+
- Single PDF file: path/to/pdf
|
65 |
+
- PDF directory: path/to/pdfs
|
66 |
+
|
67 |
+
.. note::
|
68 |
+
|
69 |
+
When using a PDF as input, you need to change ``predict_images`` to ``predict_pdfs`` in ``formula_detection.py``.
|
70 |
+
|
71 |
+
.. code:: python
|
72 |
+
|
73 |
+
# for image detection
|
74 |
+
detection_results = model_formula_detection.predict_images(input_data, result_path)
|
75 |
+
|
76 |
+
Change to:
|
77 |
+
|
78 |
+
.. code:: python
|
79 |
+
|
80 |
+
# for pdf detection
|
81 |
+
detection_results = model_formula_detection.predict_pdfs(input_data, result_path)
|
82 |
+
|
83 |
+
|
84 |
+
Viewing Visualization Results
|
85 |
+
--------------------
|
86 |
+
|
87 |
+
When the ``visualize`` option in the config file is set to ``True``, visualization results will be saved in the ``outputs/formula_detection`` directory.
|
88 |
+
|
89 |
+
.. note::
|
90 |
+
|
91 |
+
Visualization facilitates the analysis of model results. However, for large-scale tasks, it is recommended to disable visualization (set ``visualize`` to ``False`` ) to reduce memory and disk usage.
|
PDF-Extract-Kit/docs/en/algorithm/formula_recognition.rst
ADDED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.. _algorithm_formula_recognition:
|
2 |
+
|
3 |
+
============
|
4 |
+
Formula Recognition Algorithm
|
5 |
+
============
|
6 |
+
|
7 |
+
Introduction
|
8 |
+
=================
|
9 |
+
|
10 |
+
Formula detection involves recognizing the content of a given input formula image and converting it to ``LaTeX`` format.
|
11 |
+
|
12 |
+
Model Usage
|
13 |
+
=================
|
14 |
+
|
15 |
+
With the environment properly configured, you can run the layout detection algorithm script by executing ``scripts/formula_recognition.py``.
|
16 |
+
|
17 |
+
.. code:: shell
|
18 |
+
|
19 |
+
$ python scripts/formula_recognition.py --config configs/formula_recognition.yaml
|
20 |
+
|
21 |
+
Model Configuration
|
22 |
+
-----------------
|
23 |
+
|
24 |
+
.. code:: yaml
|
25 |
+
|
26 |
+
inputs: assets/demo/formula_recognition
|
27 |
+
outputs: outputs/formula_recognition
|
28 |
+
tasks:
|
29 |
+
formula_recognition:
|
30 |
+
model: formula_recognition_unimernet
|
31 |
+
model_config:
|
32 |
+
cfg_path: pdf_extract_kit/configs/unimernet.yaml
|
33 |
+
model_path: models/MFR/unimernet_tiny
|
34 |
+
visualize: False
|
35 |
+
|
36 |
+
- inputs/outputs: Define the input file path and the directory for LaTeX prediction results, respectively.
|
37 |
+
- tasks: Define the task type, currently only containing a formula recognition task.
|
38 |
+
- model: Define the specific model type: Currently, only the `UniMERNet <https://github.com/opendatalab/UniMERNet>`_ formula recognition model is provided.
|
39 |
+
- model_config: Define the model configuration.
|
40 |
+
- cfg_path: Path to the UniMERNet configuration file.
|
41 |
+
- model_path: Path to the model weights.
|
42 |
+
- visualize: Whether to visualize the model results. Visualized results will be saved in the outputs directory.
|
43 |
+
|
44 |
+
Support for Diverse Inputs
|
45 |
+
-----------------
|
46 |
+
|
47 |
+
The formula detection script in PDF-Extract-Kit supports ``single formula images`` and ``document images with corresponding formula regions``.
|
48 |
+
|
49 |
+
Viewing Visualization Results
|
50 |
+
-----------------
|
51 |
+
|
52 |
+
When the visualize setting in the config file is set to True, ``LaTeX`` prediction results will be saved in the outputs directory.
|
PDF-Extract-Kit/docs/en/algorithm/layout_detection.rst
ADDED
@@ -0,0 +1,190 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.. _algorithm_layout_detection:
|
2 |
+
|
3 |
+
=================
|
4 |
+
Layout Detection Algorithm
|
5 |
+
=================
|
6 |
+
|
7 |
+
Introduction
|
8 |
+
=================
|
9 |
+
|
10 |
+
Layout detection is a fundamental task in document content extraction, aiming to locate different types of regions on a page, such as images, tables, text, and headings, to facilitate high-quality content extraction. For text and heading regions, OCR models can be used for text recognition, while table regions can be converted using table recognition models.
|
11 |
+
|
12 |
+
Model Usage
|
13 |
+
=================
|
14 |
+
|
15 |
+
Layout detection supports following models:
|
16 |
+
|
17 |
+
.. raw:: html
|
18 |
+
|
19 |
+
<style type="text/css">
|
20 |
+
.tg {border-collapse:collapse;border-color:#9ABAD9;border-spacing:0;}
|
21 |
+
.tg td{background-color:#EBF5FF;border-color:#9ABAD9;border-style:solid;border-width:1px;color:#444;
|
22 |
+
font-family:Arial, sans-serif;font-size:14px;overflow:hidden;padding:10px 5px;word-break:normal;}
|
23 |
+
.tg th{background-color:#409cff;border-color:#9ABAD9;border-style:solid;border-width:1px;color:#fff;
|
24 |
+
font-family:Arial, sans-serif;font-size:14px;font-weight:normal;overflow:hidden;padding:10px 5px;word-break:normal;}
|
25 |
+
.tg .tg-f8tz{background-color:#409cff;border-color:inherit;text-align:left;vertical-align:top}
|
26 |
+
.tg .tg-0lax{text-align:left;vertical-align:top}
|
27 |
+
.tg .tg-0pky{border-color:inherit;text-align:left;vertical-align:top}
|
28 |
+
</style>
|
29 |
+
<table class="tg"><thead>
|
30 |
+
<tr>
|
31 |
+
<th class="tg-0lax">Model</th>
|
32 |
+
<th class="tg-f8tz">Description</th>
|
33 |
+
<th class="tg-f8tz">Characteristics</th>
|
34 |
+
<th class="tg-f8tz">Model weight</th>
|
35 |
+
<th class="tg-f8tz">Config file</th>
|
36 |
+
</tr></thead>
|
37 |
+
<tbody>
|
38 |
+
<tr>
|
39 |
+
<td class="tg-0lax">DocLayout-YOLO</td>
|
40 |
+
<td class="tg-0pky">Improved based on YOLO-v10:<br>1. Generate diverse pre-training data,enhance generalization ability across multiple document types<br>2. Model architecture improvement, improve perception ability on scale-varing instances<br>Details in <a href="https://github.com/opendatalab/DocLayout-YOLO" target="_blank" rel="noopener noreferrer">DocLayout-YOLO</a></td>
|
41 |
+
<td class="tg-0pky">Speed:Fast, Accuracy:High</td>
|
42 |
+
<td class="tg-0pky"><a href="https://huggingface.co/opendatalab/PDF-Extract-Kit-1.0/blob/main/models/Layout/YOLO/doclayout_yolo_ft.pt" target="_blank" rel="noopener noreferrer">doclayout_yolo_ft.pt</a></td>
|
43 |
+
<td class="tg-0pky">layout_detection.yaml</td>
|
44 |
+
</tr>
|
45 |
+
<tr>
|
46 |
+
<td class="tg-0lax">YOLO-v10</td>
|
47 |
+
<td class="tg-0pky">Base YOLO-v10 model</td>
|
48 |
+
<td class="tg-0pky">Speed:Fast, Accuracy:Moderate</td>
|
49 |
+
<td class="tg-0pky"><a href="https://huggingface.co/opendatalab/PDF-Extract-Kit-1.0/blob/main/models/Layout/YOLO/yolov10l_ft.pt" target="_blank" rel="noopener noreferrer">yolov10l_ft.pt</a></td>
|
50 |
+
<td class="tg-0pky">layout_detection_yolo.yaml</td>
|
51 |
+
</tr>
|
52 |
+
<tr>
|
53 |
+
<td class="tg-0lax">LayoutLMv3</td>
|
54 |
+
<td class="tg-0pky">Base LayoutLMv3 model</td>
|
55 |
+
<td class="tg-0pky">Speed:Slow, Accuracy:High</td>
|
56 |
+
<td class="tg-0pky"><a href="https://huggingface.co/opendatalab/PDF-Extract-Kit-1.0/tree/main/models/Layout/LayoutLMv3" target="_blank" rel="noopener noreferrer">layoutlmv3_ft</a></td>
|
57 |
+
<td class="tg-0pky">layout_detection_layoutlmv3.yaml</td>
|
58 |
+
</tr>
|
59 |
+
</tbody></table>
|
60 |
+
|
61 |
+
Once enciroment is setup, you can perform layout detection by executing ``scripts/layout_detection.py`` directly.
|
62 |
+
|
63 |
+
**Run demo**
|
64 |
+
|
65 |
+
.. code:: shell
|
66 |
+
|
67 |
+
$ python scripts/layout_detection.py --config configs/layout_detection.yaml
|
68 |
+
|
69 |
+
Model Configuration
|
70 |
+
-----------------
|
71 |
+
|
72 |
+
**1. DocLayout-YOLO / YOLO-v10**
|
73 |
+
|
74 |
+
.. code:: yaml
|
75 |
+
|
76 |
+
inputs: assets/demo/layout_detection
|
77 |
+
outputs: outputs/layout_detection
|
78 |
+
tasks:
|
79 |
+
layout_detection:
|
80 |
+
model: layout_detection_yolo
|
81 |
+
model_config:
|
82 |
+
img_size: 1024
|
83 |
+
conf_thres: 0.25
|
84 |
+
iou_thres: 0.45
|
85 |
+
model_path: path/to/doclayout_yolo_model
|
86 |
+
visualize: True
|
87 |
+
|
88 |
+
- inputs/outputs: Define the input file path and the directory for visualization output.
|
89 |
+
- tasks: Define the task type, currently only a layout detection task is included.
|
90 |
+
- model: Specify the specific model type, e.g., layout_detection_yolo.
|
91 |
+
- model_config: Define the model configuration.
|
92 |
+
- img_size: Define the image long edge size; the short edge will be scaled proportionally based on the long edge, with the default long edge being 1024.
|
93 |
+
- conf_thres: Define the confidence threshold, detecting only targets above this threshold.
|
94 |
+
- iou_thres: Define the IoU threshold, removing targets with an overlap greater than this threshold.
|
95 |
+
- model_path: Path to the model weights.
|
96 |
+
- visualize: Whether to visualize the model results; visualized results will be saved in the outputs directory.
|
97 |
+
|
98 |
+
|
99 |
+
**2. layoutlmv3**
|
100 |
+
|
101 |
+
.. note::
|
102 |
+
|
103 |
+
LayoutLMv3 cannot run directly by default. Please follow the steps below to modify the configuration:
|
104 |
+
|
105 |
+
1. **Detectron2 Environment Setup**
|
106 |
+
|
107 |
+
.. code-block:: bash
|
108 |
+
|
109 |
+
# For Linux
|
110 |
+
pip install https://wheels-1251341229.cos.ap-shanghai.myqcloud.com/assets/whl/detectron2/detectron2-0.6-cp310-cp310-linux_x86_64.whl
|
111 |
+
|
112 |
+
# For macOS
|
113 |
+
pip install https://wheels-1251341229.cos.ap-shanghai.myqcloud.com/assets/whl/detectron2/detectron2-0.6-cp310-cp310-macosx_10_9_universal2.whl
|
114 |
+
|
115 |
+
# For Windows
|
116 |
+
pip install https://wheels-1251341229.cos.ap-shanghai.myqcloud.com/assets/whl/detectron2/detectron2-0.6-cp310-cp310-win_amd64.whl
|
117 |
+
|
118 |
+
2. **Enable LayoutLMv3 Registration Code**
|
119 |
+
|
120 |
+
Uncomment the lines at the following links:
|
121 |
+
|
122 |
+
- `line 2 <https://github.com/opendatalab/PDF-Extract-Kit/blob/main/pdf_extract_kit/tasks/layout_detection/__init__.py#L2>`_
|
123 |
+
- `line 8 <https://github.com/opendatalab/PDF-Extract-Kit/blob/main/pdf_extract_kit/tasks/layout_detection/__init__.py#L8>`_
|
124 |
+
|
125 |
+
.. code-block:: python
|
126 |
+
|
127 |
+
from pdf_extract_kit.tasks.layout_detection.models.yolo import LayoutDetectionYOLO
|
128 |
+
from pdf_extract_kit.tasks.layout_detection.models.layoutlmv3 import LayoutDetectionLayoutlmv3
|
129 |
+
from pdf_extract_kit.registry.registry import MODEL_REGISTRY
|
130 |
+
|
131 |
+
__all__ = [
|
132 |
+
"LayoutDetectionYOLO",
|
133 |
+
"LayoutDetectionLayoutlmv3",
|
134 |
+
]
|
135 |
+
|
136 |
+
|
137 |
+
.. code:: yaml
|
138 |
+
|
139 |
+
inputs: assets/demo/layout_detection
|
140 |
+
outputs: outputs/layout_detection
|
141 |
+
tasks:
|
142 |
+
layout_detection:
|
143 |
+
model: layout_detection_layoutlmv3
|
144 |
+
model_config:
|
145 |
+
model_path: path/to/layoutlmv3_model
|
146 |
+
|
147 |
+
- inputs/outputs: Define the input file path and the directory for visualization output.
|
148 |
+
- tasks: Define the task type, currently only a layout detection task is included.
|
149 |
+
- model: Specify the specific model type, e.g., layout_detection_layoutlmv3.
|
150 |
+
- model_config: Define the model configuration.
|
151 |
+
- model_path: Path to the model weights.
|
152 |
+
|
153 |
+
|
154 |
+
|
155 |
+
Diverse Input Support
|
156 |
+
-----------------
|
157 |
+
|
158 |
+
The layout detection script in PDF-Extract-Kit supports input formats such as a ``single image``, a ``directory containing only image files``, a ``single PDF file``, and a ``directory containing only PDF files``.
|
159 |
+
|
160 |
+
.. note::
|
161 |
+
|
162 |
+
Modify the path to inputs in configs/layout_detection.yaml according to your actual data format:
|
163 |
+
- Single image: path/to/image
|
164 |
+
- Image directory: path/to/images
|
165 |
+
- Single PDF file: path/to/pdf
|
166 |
+
- PDF directory: path/to/pdfs
|
167 |
+
|
168 |
+
.. note::
|
169 |
+
When using PDF as input, you need to change ``predict_images`` to ``predict_pdfs`` in ``layout_detection.py``.
|
170 |
+
|
171 |
+
.. code:: python
|
172 |
+
|
173 |
+
# for image detection
|
174 |
+
detection_results = model_layout_detection.predict_images(input_data, result_path)
|
175 |
+
|
176 |
+
Change to:
|
177 |
+
|
178 |
+
.. code:: python
|
179 |
+
|
180 |
+
# for pdf detection
|
181 |
+
detection_results = model_layout_detection.predict_pdfs(input_data, result_path)
|
182 |
+
|
183 |
+
Viewing Visualization Results
|
184 |
+
-----------------
|
185 |
+
|
186 |
+
When ``visualize`` is set to ``True`` in the config file, the visualization results will be saved in the ``outputs`` directory.
|
187 |
+
|
188 |
+
.. note::
|
189 |
+
|
190 |
+
Visualization is helpful for analyzing model results, but for large-scale tasks, it is recommended to turn off visualization (set ``visualize`` to ``False`` ) to reduce memory and disk usage.
|
PDF-Extract-Kit/docs/en/algorithm/ocr.rst
ADDED
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.. _algorithm_ocr:
|
2 |
+
==========================
|
3 |
+
OCR (Optical Character Recognition) Algorithm
|
4 |
+
==========================
|
5 |
+
|
6 |
+
Introduction
|
7 |
+
====================
|
8 |
+
|
9 |
+
OCR(Optical Character Recognition) involves identifying the positions ajnd contents of all text blocks in pictures.
|
10 |
+
|
11 |
+
|
12 |
+
Model Usage
|
13 |
+
====================
|
14 |
+
|
15 |
+
With the environment properly set up, simply run the ocr algorithm script by executing ``scripts/ocr.py`` .
|
16 |
+
|
17 |
+
.. code:: shell
|
18 |
+
|
19 |
+
$ python scripts/ocr.py --config configs/ocr.yaml
|
20 |
+
|
21 |
+
|
22 |
+
Model Configuration
|
23 |
+
--------------------
|
24 |
+
|
25 |
+
.. code:: yaml
|
26 |
+
|
27 |
+
inputs: assets/demo/ocr
|
28 |
+
outputs: outputs/ocr
|
29 |
+
visualize: True
|
30 |
+
tasks:
|
31 |
+
ocr:
|
32 |
+
model: ocr_ppocr
|
33 |
+
model_config:
|
34 |
+
lang: ch
|
35 |
+
show_log: True
|
36 |
+
det_model_dir: models/OCR/PaddleOCR/det/ch_PP-OCRv4_det
|
37 |
+
rec_model_dir: models/OCR/PaddleOCR/rec/ch_PP-OCRv4_rec
|
38 |
+
det_db_box_thresh: 0.3
|
39 |
+
|
40 |
+
- inputs/outputs: Define the input path and the output path, respectively.
|
41 |
+
- visualize: Whether to visualize the model results. Visualized results will be saved in the outputs directory.
|
42 |
+
- tasks: Define the task type, currently only a OCR task is included.
|
43 |
+
- model: Define the specific model type, currently, only the PaddleOCR model is available.
|
44 |
+
- model_config: Define the model configuration.
|
45 |
+
- lang: Define the language, default language ch supports both english and chinese.
|
46 |
+
- show_log: Whether to print running logs.
|
47 |
+
- det_model_dir: Define the path of PaddleOCR' detection model, If the specified path does not exist, the model weight will be automatically downloaded to the path.
|
48 |
+
- rec_model_dir: Define the path of PaddleOCR' recognize model, If the specified path does not exist, the model weight will be automatically downloaded to the path.
|
49 |
+
- det_db_box_thresh: Confidence filter threshold, bounding boxes whose confidence is lower than the threshold are discarded.
|
50 |
+
|
51 |
+
|
52 |
+
Diverse Input Support
|
53 |
+
--------------------
|
54 |
+
|
55 |
+
The OCR script in PDF-Extract-Kit supports various input formats such as ``a single image/PDF``, ``a directory of image/PDF files``.
|
56 |
+
|
57 |
+
|
58 |
+
Viewing Visualization Results
|
59 |
+
--------------------
|
60 |
+
|
61 |
+
When the ``visualize`` option in the config file is set to ``True``, visualization results will be saved in the ``outputs`` directory.
|
62 |
+
|
63 |
+
.. note::
|
64 |
+
|
65 |
+
Visualization facilitates the analysis of model results. However, for large-scale tasks, it is recommended to disable visualization (set ``visualize`` to ``False`` ) to reduce memory and disk usage.
|
PDF-Extract-Kit/docs/en/algorithm/reading_order.rst
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.. _algorithm_reading_oder:
|
2 |
+
==============
|
3 |
+
Reading Order Algorithm
|
4 |
+
==============
|
5 |
+
|
6 |
+
Comming soon.
|
PDF-Extract-Kit/docs/en/algorithm/table_recognition.rst
ADDED
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.. _algorithm_table_recognition:
|
2 |
+
|
3 |
+
========================
|
4 |
+
Table Recognition Algorithm
|
5 |
+
========================
|
6 |
+
|
7 |
+
Introduction
|
8 |
+
=================
|
9 |
+
|
10 |
+
Table recognition refers to the process of inputting a table image, identifying the table structure and content, and converting it into formats such as ``LaTeX`` or ``HTML``.
|
11 |
+
|
12 |
+
Model Usage
|
13 |
+
=================
|
14 |
+
|
15 |
+
With the environment properly configured, you can run the table recognition algorithm script by directly executing ``scripts/table_parsing.py``.
|
16 |
+
|
17 |
+
.. code:: shell
|
18 |
+
|
19 |
+
$ python scripts/table_parsing.py --config configs/table_parsing.yaml
|
20 |
+
|
21 |
+
Model Configuration
|
22 |
+
-----------------
|
23 |
+
|
24 |
+
.. code:: yaml
|
25 |
+
|
26 |
+
inputs: assets/demo/table_parsing
|
27 |
+
outputs: outputs/table_parsing
|
28 |
+
tasks:
|
29 |
+
table_parsing:
|
30 |
+
model: table_parsing_struct_eqtable
|
31 |
+
model_config:
|
32 |
+
model_path: models/TabRec/StructEqTable
|
33 |
+
max_new_tokens: 1024
|
34 |
+
max_time: 30
|
35 |
+
output_format: latex
|
36 |
+
lmdeploy: False
|
37 |
+
flash_attn: True
|
38 |
+
|
39 |
+
- inputs/outputs: Define the input file path and table recognition result directory respectively
|
40 |
+
- tasks: Define the task type, currently only including one table recognition task
|
41 |
+
- model: Define the specific model type: currently using the `StructEqTable <https://github.com/UniModal4Reasoning/StructEqTable-Deploy>`_ table recognition model
|
42 |
+
- model_config: Define the model configuration
|
43 |
+
- model_path: Path to the model weights
|
44 |
+
- max_new_tokens: Maximum number of tokens to generate, default is 1024, maximum supported is 4096
|
45 |
+
- max_time: Maximum runtime for the model (in seconds)
|
46 |
+
- output_format: Output format, default is set to ``latex``, options include ``html`` and ``markdown``
|
47 |
+
- lmdeploy: Whether to use LMDeploy for deployment, currently set to False
|
48 |
+
- flash_attn: Whether to use flash attention, only available for Ampere GPUs
|
49 |
+
|
50 |
+
Diverse Input Support
|
51 |
+
-----------------
|
52 |
+
|
53 |
+
The table recognition script in PDF-Extract-Kit supports ``single table images`` and ``multiple table images`` as input.
|
54 |
+
|
55 |
+
.. note::
|
56 |
+
|
57 |
+
The StructEqTable model only supports running on GPU devices
|
58 |
+
|
59 |
+
.. note::
|
60 |
+
|
61 |
+
Adjust ``max_new_tokens`` and ``max_time`` according to the table content, defaults are 1024 and 30 respectively.
|
62 |
+
|
63 |
+
.. note::
|
64 |
+
|
65 |
+
lmdeploy is an option for accelerated inference. If set to True, it will use LMDeploy for accelerated inference deployment.
|
66 |
+
To use LMDeploy deployment, you need to install LMDeploy. For installation methods, refer to `LMDeploy <https://github.com/InternLM/lmdeploy>`_.
|
PDF-Extract-Kit/docs/en/conf copy.py
ADDED
@@ -0,0 +1,121 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Configuration file for the Sphinx documentation builder.
|
2 |
+
#
|
3 |
+
# This file only contains a selection of the most common options. For a full
|
4 |
+
# list see the documentation:
|
5 |
+
# https://www.sphinx-doc.org/en/master/usage/configuration.html
|
6 |
+
|
7 |
+
# -- Path setup --------------------------------------------------------------
|
8 |
+
|
9 |
+
# If extensions (or modules to document with autodoc) are in another directory,
|
10 |
+
# add these directories to sys.path here. If the directory is relative to the
|
11 |
+
# documentation root, use os.path.abspath to make it absolute, like shown here.
|
12 |
+
|
13 |
+
import os
|
14 |
+
import subprocess
|
15 |
+
import sys
|
16 |
+
|
17 |
+
# def install(package):
|
18 |
+
# subprocess.check_call([sys.executable, "-m", "pip", "install", package])
|
19 |
+
|
20 |
+
# # 安装 requirements.txt 中的依赖项
|
21 |
+
# requirements_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'requirements.txt'))
|
22 |
+
# if os.path.exists(requirements_path):
|
23 |
+
# with open(requirements_path) as f:
|
24 |
+
# packages = f.readlines()
|
25 |
+
# for package in packages:
|
26 |
+
# install(package.strip())
|
27 |
+
|
28 |
+
from sphinx.ext import autodoc
|
29 |
+
|
30 |
+
sys.path.insert(0, os.path.abspath('../..'))
|
31 |
+
|
32 |
+
# -- Project information -----------------------------------------------------
|
33 |
+
|
34 |
+
project = 'PDF-Extract-Kit'
|
35 |
+
copyright = '2024, OpenDataLab'
|
36 |
+
author = 'PDF-Extract-Kit Contributors'
|
37 |
+
|
38 |
+
# The full version, including alpha/beta/rc tags
|
39 |
+
version_file = '../../pdf_extract_kit/version.py'
|
40 |
+
with open(version_file) as f:
|
41 |
+
exec(compile(f.read(), version_file, 'exec'))
|
42 |
+
__version__ = locals()['__version__']
|
43 |
+
# The short X.Y version
|
44 |
+
version = __version__
|
45 |
+
# The full version, including alpha/beta/rc tags
|
46 |
+
release = __version__
|
47 |
+
|
48 |
+
# -- General configuration ---------------------------------------------------
|
49 |
+
|
50 |
+
# Add any Sphinx extension module names here, as strings. They can be
|
51 |
+
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
|
52 |
+
# ones.
|
53 |
+
extensions = [
|
54 |
+
'sphinx.ext.napoleon',
|
55 |
+
'sphinx.ext.viewcode',
|
56 |
+
'sphinx.ext.intersphinx',
|
57 |
+
'sphinx_copybutton',
|
58 |
+
'sphinx.ext.autodoc',
|
59 |
+
'sphinx.ext.autosummary',
|
60 |
+
'myst_parser',
|
61 |
+
'sphinxarg.ext',
|
62 |
+
]
|
63 |
+
|
64 |
+
# Add any paths that contain templates here, relative to this directory.
|
65 |
+
templates_path = ['_templates']
|
66 |
+
|
67 |
+
# List of patterns, relative to source directory, that match files and
|
68 |
+
# directories to ignore when looking for source files.
|
69 |
+
# This pattern also affects html_static_path and html_extra_path.
|
70 |
+
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
|
71 |
+
|
72 |
+
# Exclude the prompt "$" when copying code
|
73 |
+
copybutton_prompt_text = r'\$ '
|
74 |
+
copybutton_prompt_is_regexp = True
|
75 |
+
|
76 |
+
language = 'zh_CN'
|
77 |
+
|
78 |
+
# -- Options for HTML output -------------------------------------------------
|
79 |
+
|
80 |
+
# The theme to use for HTML and HTML Help pages. See the documentation for
|
81 |
+
# a list of builtin themes.
|
82 |
+
#
|
83 |
+
html_theme = 'sphinx_book_theme'
|
84 |
+
html_logo = '_static/image/logo.png'
|
85 |
+
html_theme_options = {
|
86 |
+
'path_to_docs': 'docs/zh_cn',
|
87 |
+
'repository_url': 'https://github.com/opendatalab/PDF-Extract-Kit',
|
88 |
+
'use_repository_button': True,
|
89 |
+
}
|
90 |
+
# Add any paths that contain custom static files (such as style sheets) here,
|
91 |
+
# relative to this directory. They are copied after the builtin static files,
|
92 |
+
# so a file named "default.css" will overwrite the builtin "default.css".
|
93 |
+
# html_static_path = ['_static']
|
94 |
+
|
95 |
+
# Mock out external dependencies here.
|
96 |
+
autodoc_mock_imports = [
|
97 |
+
'cpuinfo',
|
98 |
+
'torch',
|
99 |
+
'transformers',
|
100 |
+
'psutil',
|
101 |
+
'prometheus_client',
|
102 |
+
'sentencepiece',
|
103 |
+
'vllm.cuda_utils',
|
104 |
+
'vllm._C',
|
105 |
+
'numpy',
|
106 |
+
'tqdm',
|
107 |
+
]
|
108 |
+
|
109 |
+
|
110 |
+
class MockedClassDocumenter(autodoc.ClassDocumenter):
|
111 |
+
"""Remove note about base class when a class is derived from object."""
|
112 |
+
|
113 |
+
def add_line(self, line: str, source: str, *lineno: int) -> None:
|
114 |
+
if line == ' Bases: :py:class:`object`':
|
115 |
+
return
|
116 |
+
super().add_line(line, source, *lineno)
|
117 |
+
|
118 |
+
|
119 |
+
autodoc.ClassDocumenter = MockedClassDocumenter
|
120 |
+
|
121 |
+
navigation_with_keys = False
|