Tingquan commited on
Commit
9d62e6c
·
verified ·
1 Parent(s): c69621d

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +152 -0
README.md ADDED
@@ -0,0 +1,152 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ ---
4
+
5
+ # PP-DocBee-2B
6
+
7
+ ## Introduction
8
+
9
+ The PaddleOCR team has developed PP-DocBee-2B, a multimodal large model focusing on document understanding, and it performs excellently in Chinese document understanding tasks. The model is fine-tuned and optimized using nearly 5 million multimodal datasets for document understanding, including general VQA, OCR, charts, text-rich documents, mathematics and complex reasoning, synthetic data, and pure text data, with different training data ratios set. On several authoritative English document understanding evaluation lists in academia, PP-DocBee has basically achieved SOTA for models of the same parameter scale. In terms of internal business Chinese scenario indicators, PP-DocBee also outperforms the current popular open-source and closed-source models. The key accuracy metrics are as follow:
10
+
11
+ | Model | Model Storage Size(GB) | Total Score |
12
+ |-------|--------------------------|-----------|
13
+ | **PP-DocBee-2B** | 4.2 | 765 |
14
+ | PP-DocBee-7B | 15.8 | - |
15
+
16
+
17
+ **Note**: The total scores of the above models are test results from an internal evaluation set, where all images have a resolution (height, width) of (1680, 1204), with a total of 1196 data entries, covering scenarios such as financial reports, laws and regulations, scientific and technical papers, manuals, humanities papers, contracts, research reports, etc. There are no plans for public release at the moment.
18
+
19
+ ## Quick Start
20
+
21
+ ### Installation
22
+
23
+ 1. PaddlePaddle
24
+
25
+ Please refer to the following commands to install PaddlePaddle using pip:
26
+
27
+ ```bash
28
+ # for CUDA11.8
29
+ python -m pip install paddlepaddle-gpu==3.0.0 -i https://www.paddlepaddle.org.cn/packages/stable/cu118/
30
+
31
+ # for CUDA12.6
32
+ python -m pip install paddlepaddle-gpu==3.0.0 -i https://www.paddlepaddle.org.cn/packages/stable/cu126/
33
+
34
+ # for CPU
35
+ python -m pip install paddlepaddle==3.0.0 -i https://www.paddlepaddle.org.cn/packages/stable/cpu/
36
+ ```
37
+
38
+ For details about PaddlePaddle installation, please refer to the [PaddlePaddle official website](https://www.paddlepaddle.org.cn/en/install/quick).
39
+
40
+ 2. PaddleOCR
41
+
42
+ Install the latest version of the PaddleOCR inference package from PyPI:
43
+
44
+ ```bash
45
+ python -m pip install paddleocr
46
+ ```
47
+
48
+ ### Model Usage
49
+
50
+ You can quickly experience the functionality with a single command:
51
+
52
+ ```bash
53
+ paddleocr doc_vlm \
54
+ --model_name PP-DocBee-2B \
55
+ -i "{'image': 'https://paddle-model-ecology.bj.bcebos.com/paddlex/imgs/demo_image/medal_table.png', 'query': '识别这份表格的内容, 以markdown格式输出'}"
56
+ ```
57
+
58
+ You can also integrate the model inference of the text recognition module into your project. Before running the following code, please download the sample image to your local machine.
59
+
60
+ ```python
61
+ from paddleocr import DocVLM
62
+ model = DocVLM(model_name="PP-DocBee-2B")
63
+ results = model.predict(
64
+ input={"image": "medal_table.png", "query": "识别这份表格的内容, 以markdown格式输出"},
65
+ batch_size=1
66
+ )
67
+ for res in results:
68
+ res.print()
69
+ res.save_to_json(f"./output/res.json")
70
+ ```
71
+
72
+ After running, the obtained result is as follows:
73
+
74
+ ```bash
75
+ {"res": {'image': 'medal_table.png', 'query': '识别这份表格的内容, 以markdown格式输出', 'result': '| 名次 | 国家/地区 | 金牌 | 银牌 | 铜牌 | 奖牌总数 |\n| --- | --- | --- | --- | --- | --- |\n| 1 | 中国(CHN) | 48 | 22 | 30 | 100 |\n| 2 | 美国(USA) | 36 | 39 | 37 | 112 |\n| 3 | 俄罗斯(RUS) | 24 | 13 | 23 | 60 |\n| 4 | 英国(GBR) | 19 | 13 | 19 | 51 |\n| 5 | 德国(GER) | 16 | 11 | 14 | 41 |\n| 6 | 澳大利亚(AUS) | 14 | 15 | 17 | 46 |\n| 7 | 韩国(KOR) | 13 | 11 | 8 | 32 |\n| 8 | 日本(JPN) | 9 | 8 | 8 | 25 |\n| 9 | 意大利(ITA) | 8 | 9 | 10 | 27 |\n| 10 | 法国(FRA) | 7 | 16 | 20 | 43 |\n| 11 | 荷兰(NED) | 7 | 5 | 4 | 16 |\n| 12 | 乌克兰(UKR) | 7 | 4 | 11 | 22 |\n| 13 | 肯尼亚(KEN) | 6 | 4 | 6 | 16 |\n| 14 | 西班牙(ESP) | 5 | 11 | 3 | 19 |\n| 15 | 牙买加(JAM) | 5 | 4 | 2 | 11 |\n'}}
76
+ ```
77
+
78
+ The visualized result is as follows:
79
+
80
+ ```bash
81
+ | 名次 | 国家/地区 | 金牌 | 银牌 | 铜牌 | 奖牌总数 |
82
+ | --- | --- | --- | --- | --- | --- |
83
+ | 1 | 中国(CHN) | 48 | 22 | 30 | 100 |
84
+ | 2 | 美国(USA) | 36 | 39 | 37 | 112 |
85
+ | 3 | 俄罗斯(RUS) | 24 | 13 | 23 | 60 |
86
+ | 4 | 英国(GBR) | 19 | 13 | 19 | 51 |
87
+ | 5 | 德国(GER) | 16 | 11 | 14 | 41 |
88
+ | 6 | 澳大利亚(AUS) | 14 | 15 | 17 | 46 |
89
+ | 7 | 韩国(KOR) | 13 | 11 | 8 | 32 |
90
+ | 8 | 日本(JPN) | 9 | 8 | 8 | 25 |
91
+ | 9 | 意大利(ITA) | 8 | 9 | 10 | 27 |
92
+ | 10 | 法国(FRA) | 7 | 16 | 20 | 43 |
93
+ | 11 | 荷兰(NED) | 7 | 5 | 4 | 16 |
94
+ | 12 | 乌克兰(UKR) | 7 | 4 | 11 | 22 |
95
+ | 13 | 肯尼亚(KEN) | 6 | 4 | 6 | 16 |
96
+ | 14 | 西班牙(ESP) | 5 | 11 | 3 | 19 |
97
+ | 15 | 牙买加(JAM) | 5 | 4 | 2 | 11 |
98
+ ```
99
+
100
+ For details about usage command and descriptions of parameters, please refer to the [Document](https://paddlepaddle.github.io/PaddleOCR/latest/en/version3.x/module_usage/doc_vlm.html#iii-quick-start).
101
+
102
+ ### Pipeline Usage
103
+
104
+ The ability of a single model is limited. But the pipeline consists of several models can provide more capacity to resolve difficult problems in real-world scenarios.
105
+
106
+ #### doc_understanding
107
+
108
+ The document understanding pipeline is an advanced document processing technology based on Visual-Language Models (VLM), designed to overcome the limitations of traditional document processing. And there is only 1 module in the pipeline:
109
+ * Document Visual Language Module
110
+
111
+ Run a single command to quickly experience the OCR pipeline:
112
+
113
+ ```bash
114
+ paddleocr doc_understanding -i "{'image': 'https://paddle-model-ecology.bj.bcebos.com/paddlex/imgs/demo_image/medal_table.png', 'query': '识别这份表格的内容, 以markdown格式输出'}"
115
+ ```
116
+
117
+ Results are printed to the terminal:
118
+
119
+ ```bash
120
+ {"res": {"image": 'https://paddle-model-ecology.bj.bcebos.com/paddlex/imgs/demo_image/medal_table.png', 'query': '识别这份表格的内容, 以markdown格式输出', 'result': '| 名次 | 国家/地区 | 金牌 | 银牌 | 铜牌 | 奖牌总数 |\n| --- | --- | --- | --- | --- | --- |\n| 1 | 中国(CHN) | 48 | 22 | 30 | 100 |\n| 2 | 美国(USA) | 36 | 39 | 37 | 112 |\n| 3 | 俄罗斯(RUS) | 24 | 13 | 23 | 60 |\n| 4 | 英国(GBR) | 19 | 13 | 19 | 51 |\n| 5 | 德国(GER) | 16 | 11 | 14 | 41 |\n| 6 | 澳大利亚(AUS) | 14 | 15 | 17 | 46 |\n| 7 | 韩国(KOR) | 13 | 11 | 8 | 32 |\n| 8 | 日本(JPN) | 9 | 8 | 8 | 25 |\n| 9 | 意大利(ITA) | 8 | 9 | 10 | 27 |\n| 10 | 法国(FRA) | 7 | 16 | 20 | 43 |\n| 11 | 荷兰(NED) | 7 | 5 | 4 | 16 |\n| 12 | 乌克兰(UKR) | 7 | 4 | 11 | 22 |\n| 13 | 肯尼亚(KEN) | 6 | 4 | 6 | 16 |\n| 14 | 西班牙(ESP) | 5 | 11 | 3 | 19 |\n| 15 | 牙买加(JAM) | 5 | 4 | 2 | 11 |\n'}}
121
+ ```
122
+
123
+ If save_path is specified, the visualization results will be saved under `save_path`. The visualization output is shown below:
124
+
125
+ ![image/png](https://raw.githubusercontent.com/cuicheng01/PaddleX_doc_images/refs/heads/main/images/pipelines/doc_understanding/doc_understanding.png)
126
+
127
+ The command-line method is for quick experience. For project integration, also only a few codes are needed as well:
128
+
129
+ ```python
130
+ from paddleocr import DocUnderstanding
131
+
132
+ pipeline = DocUnderstanding(
133
+ doc_understanding_model_name="PP-DocBee-2B"
134
+ )
135
+ output = pipeline.predict(
136
+ {
137
+ "image": "https://paddle-model-ecology.bj.bcebos.com/paddlex/imgs/demo_image/medal_table.png",
138
+ "query": "识别这份表格的内容, 以markdown格式输出"
139
+ }
140
+ )
141
+ for res in output:
142
+ res.print() ## Print the structured output of the prediction
143
+ res.save_to_json("./output/")
144
+ ```
145
+
146
+ The default model used in pipeline is `PP-DocBee2-3B`, so it is needed that specifing to `PP-DocBee-2B` by argument `doc_understanding_model_name`. And you can also use the local model file by argument `doc_understanding_model_dir`. For details about usage command and descriptions of parameters, please refer to the [Document](https://paddlepaddle.github.io/PaddleOCR/latest/en/version3.x/pipeline_usage/doc_understanding.html#2-quick-start).
147
+
148
+ ## Links
149
+
150
+ [PaddleOCR Repo](https://github.com/paddlepaddle/paddleocr)
151
+
152
+ [PaddleOCR Documentation](https://paddlepaddle.github.io/PaddleOCR/latest/en/index.html)