This commit is contained in:
2440
docs/version3.x/pipeline_usage/OCR.en.md
Normal file
2440
docs/version3.x/pipeline_usage/OCR.en.md
Normal file
File diff suppressed because it is too large
Load Diff
2442
docs/version3.x/pipeline_usage/OCR.md
Normal file
2442
docs/version3.x/pipeline_usage/OCR.md
Normal file
File diff suppressed because it is too large
Load Diff
3873
docs/version3.x/pipeline_usage/PP-ChatOCRv4.en.md
Normal file
3873
docs/version3.x/pipeline_usage/PP-ChatOCRv4.en.md
Normal file
File diff suppressed because it is too large
Load Diff
3747
docs/version3.x/pipeline_usage/PP-ChatOCRv4.md
Normal file
3747
docs/version3.x/pipeline_usage/PP-ChatOCRv4.md
Normal file
File diff suppressed because it is too large
Load Diff
2878
docs/version3.x/pipeline_usage/PP-DocTranslation.en.md
Normal file
2878
docs/version3.x/pipeline_usage/PP-DocTranslation.en.md
Normal file
File diff suppressed because it is too large
Load Diff
2998
docs/version3.x/pipeline_usage/PP-DocTranslation.md
Normal file
2998
docs/version3.x/pipeline_usage/PP-DocTranslation.md
Normal file
File diff suppressed because it is too large
Load Diff
3526
docs/version3.x/pipeline_usage/PP-StructureV3.en.md
Normal file
3526
docs/version3.x/pipeline_usage/PP-StructureV3.en.md
Normal file
File diff suppressed because one or more lines are too long
3603
docs/version3.x/pipeline_usage/PP-StructureV3.md
Normal file
3603
docs/version3.x/pipeline_usage/PP-StructureV3.md
Normal file
File diff suppressed because one or more lines are too long
1234
docs/version3.x/pipeline_usage/doc_preprocessor.en.md
Normal file
1234
docs/version3.x/pipeline_usage/doc_preprocessor.en.md
Normal file
File diff suppressed because it is too large
Load Diff
1239
docs/version3.x/pipeline_usage/doc_preprocessor.md
Normal file
1239
docs/version3.x/pipeline_usage/doc_preprocessor.md
Normal file
File diff suppressed because it is too large
Load Diff
811
docs/version3.x/pipeline_usage/doc_understanding.en.md
Normal file
811
docs/version3.x/pipeline_usage/doc_understanding.en.md
Normal file
@@ -0,0 +1,811 @@
|
||||
---
|
||||
comments: true
|
||||
---
|
||||
|
||||
# Document Understanding Pipeline Usage Tutorial
|
||||
|
||||
## 1. Introduction to the Document Understanding Pipeline
|
||||
|
||||
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. Traditional methods rely on fixed templates or predefined rules to parse documents, whereas this pipeline leverages the multimodal capabilities of VLM to accurately answer user queries by inputting document images and user questions, integrating visual and language information. This technology does not require pre-training for specific document formats, allowing it to flexibly handle diverse document content, significantly enhancing the generalization and practicality of document processing. It has broad application prospects in intelligent Q&A, information extraction, and other scenarios. Currently, the pipeline does not support secondary development of VLM models, but plans to support it in the future.
|
||||
|
||||
<img src="https://raw.githubusercontent.com/cuicheng01/PaddleX_doc_images/refs/heads/main/images/pipelines/doc_understanding/doc_understanding.png">
|
||||
|
||||
<b>The document understanding pipeline includes the following module. Each module can be trained and inferred independently and contains multiple models. For more details, click the corresponding module to view the documentation.</b>
|
||||
|
||||
- [Document-like Vision Language Model Module](../module_usage/doc_vlm.md)
|
||||
|
||||
In this pipeline, you can choose the model to use based on the benchmark data below.
|
||||
|
||||
<details>
|
||||
<summary> <b>Document-like Vision Language Model Module:</b></summary>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th>Model</th><th>Model Download Link</th>
|
||||
<th>Model Storage Size (GB)</th>
|
||||
<th>Total Score</th>
|
||||
<th>Description</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>PP-DocBee-2B</td><td><a href="https://paddle-model-ecology.bj.bcebos.com/paddlex/official_inference_model/paddle3.0.0/PP-DocBee-2B_infer.tar">Inference Model</a></td>
|
||||
<td>4.2</td>
|
||||
<td>765</td>
|
||||
<td rowspan="2">PP-DocBee is a multimodal large model independently developed by the PaddlePaddle team, focusing on document understanding, with excellent performance in Chinese document understanding tasks. The model is fine-tuned and optimized using nearly 5 million multimodal datasets related to document understanding, including general VQA, OCR, chart, text-rich documents, math and complex reasoning, synthetic data, pure text data, etc., with different training data ratios set. In several authoritative English document understanding evaluation lists in academia, PP-DocBee has generally achieved SOTA for models of the same parameter scale. In internal business Chinese scenarios, PP-DocBee also outperforms current popular open and closed-source models.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>PP-DocBee-7B</td><td><a href="https://paddle-model-ecology.bj.bcebos.com/paddlex/official_inference_model/paddle3.0.0/PP-DocBee-7B_infer.tar">Inference Model</a></td>
|
||||
<td>15.8</td>
|
||||
<td>-</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>PP-DocBee2-3B</td><td><a href="https://paddle-model-ecology.bj.bcebos.com/paddlex/official_inference_model/paddle3.0.0/PP-DocBee2-3B_infer.tar">Inference Model</a></td>
|
||||
<td>7.6</td>
|
||||
<td>852</td>
|
||||
<td>PP-DocBee2 is a multimodal large model independently developed by the PaddlePaddle team, focusing on document understanding. It further optimizes the basic model based on PP-DocBee and introduces new data optimization schemes to improve data quality. With only 470,000 data generated using self-developed data synthesis strategy, PP-DocBee2 performs better in Chinese document understanding tasks. In internal business Chinese scenarios, PP-DocBee2 improves by about 11.4% compared to PP-DocBee and also outperforms current popular open and closed-source models of the same scale.</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<b>Note: The above total scores are the model test results of the internal evaluation set. All images in the internal evaluation set have a resolution (height, width) of (1680,1204), with a total of 1196 data, including scenarios such as financial reports, laws and regulations, science and engineering papers, manuals, humanities papers, contracts, and research reports, with no plans to make it public for now.</b>
|
||||
</details>
|
||||
|
||||
<br />
|
||||
<b>If you focus more on model accuracy, choose a model with higher accuracy; if you care more about inference speed, choose a model with faster inference speed; if you are concerned about storage size, choose a model with a smaller storage volume.</b>
|
||||
|
||||
## 2. Quick Start
|
||||
|
||||
Before using the document understanding pipeline locally, ensure that you have completed the installation of the wheel package according to the [installation tutorial](../installation.en.md). After installation, you can experience it locally using the command line or Python integration.
|
||||
|
||||
Please note: If you encounter issues such as the program becoming unresponsive, unexpected program termination, running out of memory resources, or extremely slow inference during execution, please try adjusting the configuration according to the documentation, such as disabling unnecessary features or using lighter-weight models.
|
||||
|
||||
### 2.1 Command Line Experience
|
||||
|
||||
Experience the doc_understanding pipeline with just one command line:
|
||||
|
||||
```bash
|
||||
paddleocr doc_understanding -i "{'image': 'https://paddle-model-ecology.bj.bcebos.com/paddlex/imgs/demo_image/medal_table.png', 'query': '识别这份表格的内容,以markdown格式输出'}"
|
||||
```
|
||||
|
||||
<details><summary><b>The command line supports more parameter settings, click to expand for a detailed explanation of the command line parameters</b></summary>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Parameter</th>
|
||||
<th>Description</th>
|
||||
<th>Type</th>
|
||||
<th>Default Value</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><code>input</code></td>
|
||||
<td>Data to be predicted, required.
|
||||
"{'image': 'https://paddle-model-ecology.bj.bcebos.com/paddlex/imgs/demo_image/medal_table.png', 'query': 'Recognize the content of this table and output it in markdown format'}".
|
||||
</td>
|
||||
<td><code>str</code></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>save_path</code></td>
|
||||
<td>Specify the path for saving the inference result file. If not set, the inference result will not be saved locally.</td>
|
||||
<td><code>str</code></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>doc_understanding_model_name</code></td>
|
||||
<td>The name of the document understanding model. If not set, the default model of the pipeline will be used.</td>
|
||||
<td><code>str</code></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>doc_understanding_model_dir</code></td>
|
||||
<td>The directory path of the document understanding model. If not set, the official model will be downloaded.</td>
|
||||
<td><code>str</code></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>doc_understanding_batch_size</code></td>
|
||||
<td>The batch size of the document understanding model. If not set, the default batch size will be set to <code>1</code>.</td>
|
||||
<td><code>int</code></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>device</code></td>
|
||||
<td>The device used for inference. Supports specifying a specific card number:
|
||||
<ul>
|
||||
<li><b>CPU</b>: For example, <code>cpu</code> indicates using the CPU for inference;</li>
|
||||
<li><b>GPU</b>: For example, <code>gpu:0</code> indicates using the first GPU for inference;</li>
|
||||
<li><b>NPU</b>: For example, <code>npu:0</code> indicates using the first NPU for inference;</li>
|
||||
<li><b>XPU</b>: For example, <code>xpu:0</code> indicates using the first XPU for inference;</li>
|
||||
<li><b>MLU</b>: For example, <code>mlu:0</code> indicates using the first MLU for inference;</li>
|
||||
<li><b>DCU</b>: For example, <code>dcu:0</code> indicates using the first DCU for inference;</li>
|
||||
</ul>If not set, the pipeline initialized value for this parameter will be used. During initialization, the local GPU device 0 will be preferred; if unavailable, the CPU device will be used.
|
||||
</td>
|
||||
<td><code>str</code></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>paddlex_config</code></td>
|
||||
<td>Path to PaddleX pipeline configuration file.</td>
|
||||
<td><code>str</code></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</details>
|
||||
<br />
|
||||
|
||||
The results will be printed to the terminal, and the default configuration of the doc_understanding pipeline will produce the following output:
|
||||
|
||||
```bash
|
||||
{'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'}}
|
||||
```
|
||||
|
||||
### 2.2 Python Script Integration
|
||||
|
||||
The command line method is for quickly experiencing the effect. Generally, in projects, code integration is often required. You can complete quick inference of the pipeline with just a few lines of code. The inference code is as follows:
|
||||
|
||||
```python
|
||||
from paddleocr import DocUnderstanding
|
||||
|
||||
pipeline = DocUnderstanding()
|
||||
output = pipeline.predict(
|
||||
{
|
||||
"image": "https://paddle-model-ecology.bj.bcebos.com/paddlex/imgs/demo_image/medal_table.png",
|
||||
"query": "识别这份表格的内容,以markdown格式输出"
|
||||
}
|
||||
)
|
||||
for res in output:
|
||||
res.print() ## Print the structured output of the prediction
|
||||
res.save_to_json("./output/")
|
||||
```
|
||||
|
||||
In the above Python script, the following steps are performed:
|
||||
|
||||
(1) Instantiate a Document Understanding Pipeline object through `DocUnderstanding()`. The specific parameter descriptions are as follows:
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Parameter</th>
|
||||
<th>Description</th>
|
||||
<th>Type</th>
|
||||
<th>Default Value</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><code>doc_understanding_model_name</code></td>
|
||||
<td>The name of the document understanding model. If set to <code>None</code>, the default model of the pipeline will be used.</td>
|
||||
<td><code>str|None</code></td>
|
||||
<td><code>None</code></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>doc_understanding_model_dir</code></td>
|
||||
<td>The directory path of the document understanding model. If set to <code>None</code>, the official model will be downloaded.</td>
|
||||
<td><code>str|None</code></td>
|
||||
<td><code>None</code></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>doc_understanding_batch_size</code></td>
|
||||
<td>The batch size of the document understanding model. If set to <code>None</code>, the default batch size will be set to <code>1</code>.</td>
|
||||
<td><code>int|None</code></td>
|
||||
<td><code>None</code></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>device</code></td>
|
||||
<td>The device used for inference. Supports specifying a specific card number:
|
||||
<ul>
|
||||
<li><b>CPU</b>: For example, <code>cpu</code> indicates using the CPU for inference;</li>
|
||||
<li><b>GPU</b>: For example, <code>gpu:0</code> indicates using the first GPU for inference;</li>
|
||||
<li><b>NPU</b>: For example, <code>npu:0</code> indicates using the first NPU for inference;</li>
|
||||
<li><b>XPU</b>: For example, <code>xpu:0</code> indicates using the first XPU for inference;</li>
|
||||
<li><b>MLU</b>: For example, <code>mlu:0</code> indicates using the first MLU for inference;</li>
|
||||
<li><b>DCU</b>: For example, <code>dcu:0</code> indicates using the first DCU for inference;</li>
|
||||
<li><b>None</b>: If set to <code>None</code>, the pipeline initialized value for this parameter will be used. During initialization, the local GPU device 0 will be preferred; if unavailable, the CPU device will be used.</li>
|
||||
</ul>
|
||||
</td>
|
||||
<td><code>str|None</code></td>
|
||||
<td><code>None</code></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>paddlex_config</code></td>
|
||||
<td>Path to PaddleX pipeline configuration file.</td>
|
||||
<td><code>str|None</code></td>
|
||||
<td><code>None</code></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
(2) Call the `predict()` method of the Document Understanding Pipeline object for inference prediction, which will return a result list.
|
||||
|
||||
Additionally, the pipeline also provides a `predict_iter()` method. Both methods are consistent in terms of parameter acceptance and result return. The difference is that `predict_iter()` returns a `generator` that can process and obtain prediction results step by step, suitable for handling large datasets or scenarios where memory saving is desired. You can choose to use either method according to your actual needs.
|
||||
|
||||
Below are the parameters and their descriptions for the `predict()` method:
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Parameter</th>
|
||||
<th>Description</th>
|
||||
<th>Type</th>
|
||||
<th>Default Value</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tr>
|
||||
<td><code>input</code></td>
|
||||
<td>Data to be predicted, currently only supports dictionary type input
|
||||
<ul>
|
||||
<li><b>Python Dict</b>: The input format for PP-DocBee is: <code>{"image":/path/to/image, "query": user question}</code>, representing the input image and corresponding user question.</li>
|
||||
</ul>
|
||||
</td>
|
||||
<td><code>Python Dict</code></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
||||
(3) Process the prediction results. The prediction result for each sample is a corresponding Result object, which supports printing and saving as a `json` file:
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Method</th>
|
||||
<th>Description</th>
|
||||
<th>Parameter</th>
|
||||
<th>Type</th>
|
||||
<th>Parameter Description</th>
|
||||
<th>Default Value</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tr>
|
||||
<td rowspan = "3"><code>print()</code></td>
|
||||
<td rowspan = "3">Print the result to the terminal</td>
|
||||
<td><code>format_json</code></td>
|
||||
<td><code>bool</code></td>
|
||||
<td>Whether to format the output content using <code>JSON</code> indentation.</td>
|
||||
<td><code>True</code></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>indent</code></td>
|
||||
<td><code>int</code></td>
|
||||
<td>Specifies the indentation level to beautify the output <code>JSON</code> data, making it more readable, effective only when <code>format_json</code> is <code>True</code>.</td>
|
||||
<td>4</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>ensure_ascii</code></td>
|
||||
<td><code>bool</code></td>
|
||||
<td>Controls whether to escape non-<code>ASCII</code> characters into <code>Unicode</code>. When set to <code>True</code>, all non-<code>ASCII</code> characters will be escaped; <code>False</code> will retain the original characters, effective only when <code>format_json</code> is <code>True</code>.</td>
|
||||
<td><code>False</code></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td rowspan = "3"><code>save_to_json()</code></td>
|
||||
<td rowspan = "3">Save the result as a JSON format file</td>
|
||||
<td><code>save_path</code></td>
|
||||
<td><code>str</code></td>
|
||||
<td>The path to save the file. When specified as a directory, the saved file is named consistent with the input file type.</td>
|
||||
<td>None</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>indent</code></td>
|
||||
<td><code>int</code></td>
|
||||
<td>Specifies the indentation level to beautify the output <code>JSON</code> data, making it more readable, effective only when <code>format_json</code> is <code>True</code>.</td>
|
||||
<td>4</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>ensure_ascii</code></td>
|
||||
<td><code>bool</code></td>
|
||||
<td>Controls whether to escape non-<code>ASCII</code> characters into <code>Unicode</code>. When set to <code>True</code>, all non-<code>ASCII</code> characters will be escaped; <code>False</code> will retain the original characters, effective only when <code>format_json</code> is <code>True</code>.</td>
|
||||
<td><code>False</code></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
- Calling the `print()` method will print the result to the terminal. The content printed to the terminal is explained as follows:
|
||||
|
||||
- `image`: `(str)` Input path of the image
|
||||
|
||||
- `query`: `(str)` Question regarding the input image
|
||||
|
||||
- `result`: `(str)` Output result of the model
|
||||
|
||||
- Calling the `save_to_json()` method will save the above content to the specified `save_path`. If specified as a directory, the path saved will be `save_path/{your_img_basename}_res.json`, and if specified as a file, it will be saved directly to that file.
|
||||
|
||||
* Additionally, the result can be obtained through attributes that provide the visualized images with results and the prediction results, as follows:
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Attribute</th>
|
||||
<th>Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tr>
|
||||
<td rowspan = "1"><code>json</code></td>
|
||||
<td rowspan = "1">Get the prediction result in <code>json</code> format</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td rowspan = "2"><code>img</code></td>
|
||||
<td rowspan = "2">Get the visualized image in <code>dict</code> format</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
- The prediction result obtained through the `json` attribute is data of the dict type, consistent with the content saved by calling the `save_to_json()` method.
|
||||
|
||||
## 3. Development Integration/Deployment
|
||||
|
||||
If the pipeline meets your requirements for pipeline inference speed and accuracy, you can proceed with development integration/deployment directly.
|
||||
|
||||
If you need to apply the pipeline directly to your Python project, you can refer to the example code in [2.2 Python Script Integration](#22-python-script-integration).
|
||||
|
||||
In addition, PaddleOCR also provides two other deployment methods, detailed descriptions are as follows:
|
||||
|
||||
🚀 High-Performance Inference: In real production environments, many applications have strict standards for the performance indicators of deployment strategies (especially response speed) to ensure efficient system operation and smooth user experience. To this end, PaddleOCR provides high-performance inference capabilities, aiming to deeply optimize the performance of model inference and pre-and post-processing, achieving significant acceleration of the end-to-end process. For detailed high-performance inference processes, refer to [High-Performance Inference](../deployment/high_performance_inference.md).
|
||||
|
||||
☁️ Service Deployment: Service deployment is a common form of deployment in real production environments. By encapsulating inference functions as services, clients can access these services through network requests to obtain inference results. For detailed pipeline service deployment processes, refer to [Serving](../deployment/serving.md).
|
||||
|
||||
Below is the API reference for basic service deployment and examples of service invocation in multiple languages:
|
||||
|
||||
<details><summary>API Reference</summary>
|
||||
|
||||
<p>For the main operations provided by the service:</p>
|
||||
<ul>
|
||||
<li>The HTTP request method is POST.</li>
|
||||
<li>Both the request body and response body are JSON data (JSON object).</li>
|
||||
<li>When the request is processed successfully, the response status code is <code>200</code>, and the response body has the following attributes:</li>
|
||||
</ul>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Type</th>
|
||||
<th>Meaning</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><code>logId</code></td>
|
||||
<td><code>string</code></td>
|
||||
<td>UUID of the request.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>errorCode</code></td>
|
||||
<td><code>integer</code></td>
|
||||
<td>Error code. Fixed as <code>0</code>.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>errorMsg</code></td>
|
||||
<td><code>string</code></td>
|
||||
<td>Error description. Fixed as <code>"Success"</code>.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>result</code></td>
|
||||
<td><code>object</code></td>
|
||||
<td>Operation result.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<ul>
|
||||
<li>When the request is not processed successfully, the response body has the following attributes:</li>
|
||||
</ul>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Type</th>
|
||||
<th>Meaning</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><code>logId</code></td>
|
||||
<td><code>string</code></td>
|
||||
<td>UUID of the request.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>errorCode</code></td>
|
||||
<td><code>integer</code></td>
|
||||
<td>Error code. Same as the response status code.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>errorMsg</code></td>
|
||||
<td><code>string</code></td>
|
||||
<td>Error description.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<p>The main operations provided by the service are as follows:</p>
|
||||
<ul>
|
||||
<li><b><code>infer</code></b></li>
|
||||
</ul>
|
||||
<p>Perform inference on the input message to generate a response.</p>
|
||||
<p><code>POST /document-understanding</code></p>
|
||||
<p>Note: The above interface is also known as /chat/completion, compatible with OpenAI interfaces.</p>
|
||||
|
||||
<ul>
|
||||
<li>The attributes of the request body are as follows:</li>
|
||||
</ul>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Type</th>
|
||||
<th>Meaning</th>
|
||||
<th>Required</th>
|
||||
<th>Default Value</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><code>model</code></td>
|
||||
<td><code>string</code></td>
|
||||
<td>The name of the model to use</td>
|
||||
<td>Yes</td>
|
||||
<td>-</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>messages</code></td>
|
||||
<td><code>array</code></td>
|
||||
<td>List of dialogue messages</td>
|
||||
<td>Yes</td>
|
||||
<td>-</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>max_tokens</code></td>
|
||||
<td><code>integer</code></td>
|
||||
<td>Maximum number of tokens to generate</td>
|
||||
<td>No</td>
|
||||
<td>1024</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>temperature</code></td>
|
||||
<td><code>float</code></td>
|
||||
<td>Sampling temperature</td>
|
||||
<td>No</td>
|
||||
<td>0.1</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>top_p</code></td>
|
||||
<td><code>float</code></td>
|
||||
<td>Core sampling probability</td>
|
||||
<td>No</td>
|
||||
<td>0.95</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>stream</code></td>
|
||||
<td><code>boolean</code></td>
|
||||
<td>Whether to output in streaming mode</td>
|
||||
<td>No</td>
|
||||
<td>false</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>max_image_tokens</code></td>
|
||||
<td><code>int</code></td>
|
||||
<td>Maximum number of input tokens for images</td>
|
||||
<td>No</td>
|
||||
<td>None</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<p>Each element in <code>messages</code> is an <code>object</code> with the following attributes:</p>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Type</th>
|
||||
<th>Meaning</th>
|
||||
<th>Required</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><code>role</code></td>
|
||||
<td><code>string</code></td>
|
||||
<td>Message role (user/assistant/system)</td>
|
||||
<td>Yes</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>content</code></td>
|
||||
<td><code>string</code> or <code>array</code></td>
|
||||
<td>Message content (text or mixed media)</td>
|
||||
<td>Yes</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<p>When <code>content</code> is an array, each element is an <code>object</code> with the following attributes:</p>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Type</th>
|
||||
<th>Meaning</th>
|
||||
<th>Required</th>
|
||||
<th>Default Value</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><code>type</code></td>
|
||||
<td><code>string</code></td>
|
||||
<td>Content type (text/image_url)</td>
|
||||
<td>Yes</td>
|
||||
<td>-</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>text</code></td>
|
||||
<td><code>string</code></td>
|
||||
<td>Text content (when type is text)</td>
|
||||
<td>Conditionally required</td>
|
||||
<td>-</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>image_url</code></td>
|
||||
<td><code>string</code> or <code>object</code></td>
|
||||
<td>Image URL or object (when type is image_url)</td>
|
||||
<td>Conditionally required</td>
|
||||
<td>-</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<p>When <code>image_url</code> is an object, it has the following attributes:</p>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Type</th>
|
||||
<th>Meaning</th>
|
||||
<th>Required</th>
|
||||
<th>Default Value</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><code>url</code></td>
|
||||
<td><code>string</code></td>
|
||||
<td>Image URL</td>
|
||||
<td>Yes</td>
|
||||
<td>-</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>detail</code></td>
|
||||
<td><code>string</code></td>
|
||||
<td>Image detail processing method (low/high/auto)</td>
|
||||
<td>No</td>
|
||||
<td>auto</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<p>When the request is processed successfully, the <code>result</code> in the response body has the following attributes:</p>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Type</th>
|
||||
<th>Meaning</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><code>id</code></td>
|
||||
<td><code>string</code></td>
|
||||
<td>Request ID</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>object</code></td>
|
||||
<td><code>string</code></td>
|
||||
<td>Object type (chat.completion)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>created</code></td>
|
||||
<td><code>integer</code></td>
|
||||
<td>Creation timestamp</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>choices</code></td>
|
||||
<td><code>array</code></td>
|
||||
<td>Generated result options</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>usage</code></td>
|
||||
<td><code>object</code></td>
|
||||
<td>Token usage</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<p>Each element in <code>choices</code> is a <code>Choice</code> object with the following attributes:</p>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Type</th>
|
||||
<th>Meaning</th>
|
||||
<th>Optional Values</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><code>finish_reason</code></td>
|
||||
<td><code>string</code></td>
|
||||
<td>Reason for the model to stop generating tokens</td>
|
||||
<td><code>stop</code> (natural stop)<br><code>length</code> (reached max token count)<br><code>tool_calls</code> (called a tool)<br><code>content_filter</code> (content filtering)<br><code>function_call</code> (called a function, deprecated)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>index</code></td>
|
||||
<td><code>integer</code></td>
|
||||
<td>Index of the option in the list</td>
|
||||
<td>-</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>logprobs</code></td>
|
||||
<td><code>object</code> | <code>null</code></td>
|
||||
<td>Log probability information of the option</td>
|
||||
<td>-</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>message</code></td>
|
||||
<td><code>ChatCompletionMessage</code></td>
|
||||
<td>Chat message generated by the model</td>
|
||||
<td>-</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<p>The <code>message</code> object has the following attributes:</p>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Type</th>
|
||||
<th>Meaning</th>
|
||||
<th>Remarks</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><code>content</code></td>
|
||||
<td><code>string</code> | <code>null</code></td>
|
||||
<td>Message content</td>
|
||||
<td>May be empty</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>refusal</code></td>
|
||||
<td><code>string</code> | <code>null</code></td>
|
||||
<td>Refusal message generated by the model</td>
|
||||
<td>Provided when content is refused</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>role</code></td>
|
||||
<td><code>string</code></td>
|
||||
<td>Role of the message author</td>
|
||||
<td>Fixed as <code>"assistant"</code></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>audio</code></td>
|
||||
<td><code>object</code> | <code>null</code></td>
|
||||
<td>Audio output data</td>
|
||||
<td>Provided when audio output is requested<br><a href="https://platform.openai.com/docs/guides/audio">Learn more</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>function_call</code></td>
|
||||
<td><code>object</code> | <code>null</code></td>
|
||||
<td>Name and parameters of the function to be called</td>
|
||||
<td>Deprecated, recommended to use <code>tool_calls</code></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>tool_calls</code></td>
|
||||
<td><code>array</code> | <code>null</code></td>
|
||||
<td>Tool calls generated by the model</td>
|
||||
<td>Such as function calls</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<p>The <code>usage</code> object has the following attributes:</p>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Type</th>
|
||||
<th>Meaning</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><code>prompt_tokens</code></td>
|
||||
<td><code>integer</code></td>
|
||||
<td>Number of prompt tokens</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>completion_tokens</code></td>
|
||||
<td><code>integer</code></td>
|
||||
<td>Number of generated tokens</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>total_tokens</code></td>
|
||||
<td><code>integer</code></td>
|
||||
<td>Total number of tokens</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<p>An example of a <code>result</code> is as follows:</p>
|
||||
<pre><code class="language-json">{
|
||||
"id": "ed960013-eb19-43fa-b826-3c1b59657e35",
|
||||
"choices": [
|
||||
{
|
||||
"finish_reason": "stop",
|
||||
"index": 0,
|
||||
"message": {
|
||||
"content": "| 名次 | 国家/地区 | 金牌 | 银牌 | 铜牌 | 奖牌总数 |\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",
|
||||
"role": "assistant"
|
||||
}
|
||||
}
|
||||
],
|
||||
"created": 1745218041,
|
||||
"model": "pp-docbee",
|
||||
"object": "chat.completion"
|
||||
}
|
||||
</code></pre></details>
|
||||
|
||||
<details><summary>Multi-language Service Invocation Examples</summary>
|
||||
|
||||
<details>
|
||||
<summary>Python</summary>
|
||||
OpenAI interface invocation example
|
||||
|
||||
<pre><code class="language-python">import base64
|
||||
from openai import OpenAI
|
||||
|
||||
API_BASE_URL = "http://127.0.0.1:8080"
|
||||
|
||||
# Initialize OpenAI client
|
||||
client = OpenAI(
|
||||
api_key='xxxxxxxxx',
|
||||
base_url=f'{API_BASE_URL}'
|
||||
)
|
||||
|
||||
# Function to convert image to base64
|
||||
def encode_image(image_path):
|
||||
with open(image_path, "rb") as image_file:
|
||||
return base64.b64encode(image_file.read()).decode('utf-8')
|
||||
|
||||
# Input image path
|
||||
image_path = "medal_table.png"
|
||||
|
||||
# Convert original image to base64
|
||||
base64_image = encode_image(image_path)
|
||||
|
||||
# Submit information to PP-DocBee model
|
||||
response = client.chat.completions.create(
|
||||
model="pp-docbee",# Choose Model
|
||||
messages=[
|
||||
{
|
||||
"role": "system",
|
||||
"content": "You are a helpful assistant."
|
||||
},
|
||||
{
|
||||
"role": "user",
|
||||
"content":[
|
||||
{
|
||||
"type": "text",
|
||||
"text": "识别这份表格的内容,输出html格式的内容"
|
||||
},
|
||||
{
|
||||
"type": "image_url",
|
||||
"image_url": {"url": f"data:image/jpeg;base64,{base64_image}"}
|
||||
},
|
||||
]
|
||||
},
|
||||
],
|
||||
)
|
||||
content = response.choices[0].message.content
|
||||
print('Reply:', content)
|
||||
</code></pre></details>
|
||||
</details>
|
||||
<br/>
|
||||
|
||||
## 4. Secondary Development
|
||||
|
||||
The current pipeline does not support fine-tuning training and only supports inference integration. Concerning fine-tuning training for this pipeline, there are plans to support it in the future.
|
||||
809
docs/version3.x/pipeline_usage/doc_understanding.md
Normal file
809
docs/version3.x/pipeline_usage/doc_understanding.md
Normal file
@@ -0,0 +1,809 @@
|
||||
---
|
||||
comments: true
|
||||
---
|
||||
|
||||
# 文档理解产线使用教程
|
||||
|
||||
## 1. 文档理解产线介绍
|
||||
|
||||
文档理解产线是基于视觉-语言模型(VLM)打造的先进文档处理技术,旨在突破传统文档处理的局限。传统方法依赖固定模板或预定义规则解析文档,而该产线借助VLM的多模态能力,仅需输入文档图片和用户问题,即可通过融合视觉与语言信息,精准回答用户提问。这种技术无需针对特定文档格式预训练,能够灵活应对多样化文档内容,显著提升文档处理的泛化性与实用性,在智能问答、信息提取等场景中具有广阔应用前景。本产线目前暂不支持对VLM模型的二次开发,后续计划支持。
|
||||
|
||||
<img src="https://raw.githubusercontent.com/cuicheng01/PaddleX_doc_images/refs/heads/main/images/pipelines/doc_understanding/doc_understanding.png">
|
||||
|
||||
<b>文档理解产线中包含以下1个模块。每个模块均可独立进行训练和推理,并包含多个模型。有关详细信息,请点击相应模块以查看文档。</b>
|
||||
|
||||
- [文档类视觉语言模型模块](../module_usage/doc_vlm.md)
|
||||
|
||||
在本产线中,您可以根据下方的基准测试数据选择使用的模型。
|
||||
|
||||
<details>
|
||||
<summary> <b>文档类视觉语言模型模块:</b></summary>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th>模型</th><th>模型下载链接</th>
|
||||
<th>模型存储大小(GB)</th>
|
||||
<th>模型总分</th>
|
||||
<th>介绍</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>PP-DocBee-2B</td><td><a href="https://paddle-model-ecology.bj.bcebos.com/paddlex/official_inference_model/paddle3.0.0/PP-DocBee-2B_infer.tar">推理模型</a></td>
|
||||
<td>4.2</td>
|
||||
<td>765</td>
|
||||
<td rowspan="2">PP-DocBee 是飞桨团队自研的一款专注于文档理解的多模态大模型,在中文文档理解任务上具有卓越表现。该模型通过近 500 万条文档理解类多模态数据集进行微调优化,各种数据集包括了通用VQA类、OCR类、图表类、text-rich文档类、数学和复杂推理类、合成数据类、纯文本数据等,并设置了不同训练数据配比。在学术界权威的几个英文文档理解评测榜单上,PP-DocBee基本都达到了同参数量级别模型的SOTA。在内部业务中文场景类的指标上,PP-DocBee也高于目前的热门开源和闭源模型。</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>PP-DocBee-7B</td><td><a href="https://paddle-model-ecology.bj.bcebos.com/paddlex/official_inference_model/paddle3.0.0/PP-DocBee-7B_infer.tar">推理模型</a></td>
|
||||
<td>15.8</td>
|
||||
<td>-</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>PP-DocBee2-3B</td><td><a href="https://paddle-model-ecology.bj.bcebos.com/paddlex/official_inference_model/paddle3.0.0/PP-DocBee2-3B_infer.tar">推理模型</a></td>
|
||||
<td>7.6</td>
|
||||
<td>852</td>
|
||||
<td>PP-DocBee2 是飞桨团队自研的一款专注于文档理解的多模态大模型,在PP-DocBee的基础上进一步优化了基础模型,并引入了新的数据优化方案,提高了数据质量,使用自研数据合成策略生成的少量的47万数据便使得PP-DocBee2在中文文档理解任务上表现更佳。在内部业务中文场景类的指标上,PP-DocBee2相较于PP-DocBee提升了约11.4%,同时也高于目前的同规模热门开源和闭源模型。</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<b>注:以上模型总分为内部评估集模型测试结果,内部评估集所有图像分辨率 (height,width) 为 (1680,1204),共1196条数据,包括了财报、法律法规、理工科论文、说明书、文科论文、合同、研报等场景,暂时未有计划公开。</b>
|
||||
</details>
|
||||
|
||||
<br />
|
||||
<b>如果您更注重模型的精度,请选择精度较高的模型;如果您更在意模型的推理速度,请选择推理速度较快的模型;如果您关注模型的存储大小,请选择存储体积较小的模型。</b>
|
||||
|
||||
## 2. 快速开始
|
||||
|
||||
在本地使用文档理解产线前,请确保您已经按照[安装教程](../installation.md)完成了wheel包安装。安装完成后,可以在本地使用命令行体验或 Python 集成。
|
||||
|
||||
**请注意,如果在执行过程中遇到程序失去响应、程序异常退出、内存资源耗尽、推理速度极慢等问题,请尝试参考文档调整配置,例如关闭不需要使用的功能或使用更轻量的模型。**
|
||||
|
||||
### 2.1 命令行方式体验
|
||||
|
||||
一行命令即可快速体验 doc_understanding 产线效果:
|
||||
|
||||
```bash
|
||||
paddleocr doc_understanding -i "{'image': 'https://paddle-model-ecology.bj.bcebos.com/paddlex/imgs/demo_image/medal_table.png', 'query': '识别这份表格的内容,以markdown格式输出'}"
|
||||
```
|
||||
|
||||
<details><summary><b>命令行支持更多参数设置,点击展开以查看命令行参数的详细说明</b></summary>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>参数</th>
|
||||
<th>参数说明</th>
|
||||
<th>参数类型</th>
|
||||
<th>默认值</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><code>input</code></td>
|
||||
<td>待预测数据,必填。如"{'image': 'https://paddle-model-ecology.bj.bcebos.com/paddlex/imgs/demo_image/medal_table.png', 'query': '识别这份表格的内容,以markdown格式输出'}"。
|
||||
</td>
|
||||
<td><code>str</code></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>save_path</code></td>
|
||||
<td>指定推理结果文件保存的路径。如果不设置,推理结果将不会保存到本地。</td>
|
||||
<td><code>str</code></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>doc_understanding_model_name</code></td>
|
||||
<td>文档理解模型的名称。如果不设置,将会使用产线默认模型。</td>
|
||||
<td><code>str</code></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>doc_understanding_model_dir</code></td>
|
||||
<td>文档理解模型的目录路径。如果不设置,将会下载官方模型。</td>
|
||||
<td><code>str</code></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>doc_understanding_batch_size</code></td>
|
||||
<td>文档理解模型的batch size。如果设置为<code>None</code>,将默认设置batch size为<code>1</code>。</td>
|
||||
<td><code>int</code></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>device</code></td>
|
||||
<td>用于推理的设备。支持指定具体卡号:
|
||||
<ul>
|
||||
<li><b>CPU</b>:如 <code>cpu</code> 表示使用 CPU 进行推理;</li>
|
||||
<li><b>GPU</b>:如 <code>gpu:0</code> 表示使用第 1 块 GPU 进行推理;</li>
|
||||
<li><b>NPU</b>:如 <code>npu:0</code> 表示使用第 1 块 NPU 进行推理;</li>
|
||||
<li><b>XPU</b>:如 <code>xpu:0</code> 表示使用第 1 块 XPU 进行推理;</li>
|
||||
<li><b>MLU</b>:如 <code>mlu:0</code> 表示使用第 1 块 MLU 进行推理;</li>
|
||||
<li><b>DCU</b>:如 <code>dcu:0</code> 表示使用第 1 块 DCU 进行推理;</li>
|
||||
</ul>如果不设置,将默认使用产线初始化的该参数值,初始化时,会优先使用本地的 GPU 0号设备,如果没有,则使用 CPU 设备。
|
||||
</td>
|
||||
<td><code>str</code></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>paddlex_config</code></td>
|
||||
<td>PaddleX产线配置文件路径。</td>
|
||||
<td><code>str</code></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</details>
|
||||
<br />
|
||||
|
||||
运行结果会被打印到终端上,默认配置的 doc_understanding 产线的运行结果如下:
|
||||
|
||||
```bash
|
||||
{'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'}}
|
||||
```
|
||||
|
||||
### 2.2 Python脚本方式集成
|
||||
|
||||
命令行方式是为了快速体验查看效果,一般来说,在项目中,往往需要通过代码集成,您可以通过几行代码即可完成产线的快速推理,推理代码如下:
|
||||
|
||||
```python
|
||||
from paddleocr import DocUnderstanding
|
||||
|
||||
pipeline = DocUnderstanding()
|
||||
output = pipeline.predict(
|
||||
{
|
||||
"image": "https://paddle-model-ecology.bj.bcebos.com/paddlex/imgs/demo_image/medal_table.png",
|
||||
"query": "识别这份表格的内容,以markdown格式输出"
|
||||
}
|
||||
)
|
||||
for res in output:
|
||||
res.print() ## 打印预测的结构化输出
|
||||
res.save_to_json("./output/")
|
||||
```
|
||||
|
||||
在上述 Python 脚本中,执行了如下几个步骤:
|
||||
|
||||
(1)通过 `DocUnderstanding()` 实例化文档理解产线产线对象,具体参数说明如下:
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>参数</th>
|
||||
<th>参数说明</th>
|
||||
<th>参数类型</th>
|
||||
<th>默认值</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><code>doc_understanding_model_name</code></td>
|
||||
<td>文档理解模型的名称。如果设置为<code>None</code>,将会使用产线默认模型。</td>
|
||||
<td><code>str|None</code></td>
|
||||
<td><code>None</code></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>doc_understanding_model_dir</code></td>
|
||||
<td>文档理解模型的目录路径。如果设置为<code>None</code>,将会下载官方模型。</td>
|
||||
<td><code>str|None</code></td>
|
||||
<td><code>None</code></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>doc_understanding_batch_size</code></td>
|
||||
<td>文档理解模型的batch size。如果设置为<code>None</code>,将默认设置batch size为<code>1</code>。</td>
|
||||
<td><code>int|None</code></td>
|
||||
<td><code>None</code></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>device</code></td>
|
||||
<td>用于推理的设备。支持指定具体卡号:
|
||||
<ul>
|
||||
<li><b>CPU</b>:如 <code>cpu</code> 表示使用 CPU 进行推理;</li>
|
||||
<li><b>GPU</b>:如 <code>gpu:0</code> 表示使用第 1 块 GPU 进行推理;</li>
|
||||
<li><b>NPU</b>:如 <code>npu:0</code> 表示使用第 1 块 NPU 进行推理;</li>
|
||||
<li><b>XPU</b>:如 <code>xpu:0</code> 表示使用第 1 块 XPU 进行推理;</li>
|
||||
<li><b>MLU</b>:如 <code>mlu:0</code> 表示使用第 1 块 MLU 进行推理;</li>
|
||||
<li><b>DCU</b>:如 <code>dcu:0</code> 表示使用第 1 块 DCU 进行推理;</li>
|
||||
<li><b>None</b>:如果设置为<code>None</code>,将默认使用产线初始化的该参数值,初始化时,会优先使用本地的 GPU 0号设备,如果没有,则使用 CPU 设备。</li>
|
||||
</ul>
|
||||
</td>
|
||||
<td><code>str|None</code></td>
|
||||
<td><code>None</code></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>paddlex_config</code></td>
|
||||
<td>PaddleX产线配置文件路径。</td>
|
||||
<td><code>str|None</code></td>
|
||||
<td><code>None</code></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
(2)调用 文档理解产线 产线对象的 `predict()` 方法进行推理预测,该方法会返回一个结果列表。
|
||||
|
||||
另外,产线还提供了 `predict_iter()` 方法。两者在参数接受和结果返回方面是完全一致的,区别在于 `predict_iter()` 返回的是一个 `generator`,能够逐步处理和获取预测结果,适合处理大型数据集或希望节省内存的场景。可以根据实际需求选择使用这两种方法中的任意一种。
|
||||
|
||||
以下是 `predict()` 方法的参数及其说明:
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>参数</th>
|
||||
<th>参数说明</th>
|
||||
<th>参数类型</th>
|
||||
<th>默认值</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tr>
|
||||
<td><code>input</code></td>
|
||||
<td>待预测数据,目前仅支持dict类型的输入
|
||||
<ul>
|
||||
<li><b>Python Dict</b>:如PP-DocBee的输入形式为: <code>{"image":/path/to/image, "query": user question}</code> ,分别表示输入的图像和对应的用户问题。</li>
|
||||
</ul>
|
||||
</td>
|
||||
<td><code>Python Dict</code></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
(3)对预测结果进行处理,每个样本的预测结果均为对应的Result对象,且支持打印、保存为`json`文件的操作:
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>方法</th>
|
||||
<th>方法说明</th>
|
||||
<th>参数</th>
|
||||
<th>参数类型</th>
|
||||
<th>参数说明</th>
|
||||
<th>默认值</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tr>
|
||||
<td rowspan = "3"><code>print()</code></td>
|
||||
<td rowspan = "3">打印结果到终端</td>
|
||||
<td><code>format_json</code></td>
|
||||
<td><code>bool</code></td>
|
||||
<td>是否对输出内容进行使用 <code>JSON</code> 缩进格式化。</td>
|
||||
<td><code>True</code></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>indent</code></td>
|
||||
<td><code>int</code></td>
|
||||
<td>指定缩进级别,以美化输出的 <code>JSON</code> 数据,使其更具可读性,仅当 <code>format_json</code> 为 <code>True</code> 时有效。</td>
|
||||
<td>4</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>ensure_ascii</code></td>
|
||||
<td><code>bool</code></td>
|
||||
<td>控制是否将非 <code>ASCII</code> 字符转义为 <code>Unicode</code>。设置为 <code>True</code> 时,所有非 <code>ASCII</code> 字符将被转义;<code>False</code> 则保留原始字符,仅当<code>format_json</code>为<code>True</code>时有效。</td>
|
||||
<td><code>False</code></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td rowspan = "3"><code>save_to_json()</code></td>
|
||||
<td rowspan = "3">将结果保存为json格式的文件</td>
|
||||
<td><code>save_path</code></td>
|
||||
<td><code>str</code></td>
|
||||
<td>保存的文件路径,当为目录时,保存文件命名与输入文件类型命名一致。</td>
|
||||
<td>无</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>indent</code></td>
|
||||
<td><code>int</code></td>
|
||||
<td>指定缩进级别,以美化输出的 <code>JSON</code> 数据,使其更具可读性,仅当 <code>format_json</code> 为 <code>True</code> 时有效。</td>
|
||||
<td>4</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>ensure_ascii</code></td>
|
||||
<td><code>bool</code></td>
|
||||
<td>控制是否将非 <code>ASCII</code> 字符转义为 <code>Unicode</code>。设置为 <code>True</code> 时,所有非 <code>ASCII</code> 字符将被转义;<code>False</code> 则保留原始字符,仅当<code>format_json</code>为<code>True</code>时有效。</td>
|
||||
<td><code>False</code></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
- 调用`print()` 方法会将结果打印到终端,打印到终端的内容解释如下:
|
||||
|
||||
- `image`: `(str)` 图像的输入路径
|
||||
|
||||
- `query`: `(str)` 针对输入图像的问题
|
||||
|
||||
- `result`: `(str)` 模型的输出结果
|
||||
|
||||
- 调用`save_to_json()` 方法会将上述内容保存到指定的`save_path`中,如果指定为目录,则保存的路径为`save_path/{your_img_basename}_res.json`,如果指定为文件,则直接保存到该文件中。
|
||||
|
||||
* 此外,也支持通过属性获取带结果的可视化图像和预测结果,具体如下:
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>属性</th>
|
||||
<th>属性说明</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tr>
|
||||
<td rowspan = "1"><code>json</code></td>
|
||||
<td rowspan = "1">获取预测的 <code>json</code> 格式的结果</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td rowspan = "2"><code>img</code></td>
|
||||
<td rowspan = "2">获取格式为 <code>dict</code> 的可视化图像</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
- `json` 属性获取的预测结果为dict类型的数据,相关内容与调用 `save_to_json()` 方法保存的内容一致。
|
||||
|
||||
## 3. 开发集成/部署
|
||||
|
||||
如果产线可以达到您对产线推理速度和精度的要求,您可以直接进行开发集成/部署。
|
||||
|
||||
若您需要将产线直接应用在您的Python项目中,可以参考 [2.2 Python脚本方式](#22-python脚本方式集成) 中的示例代码。
|
||||
|
||||
此外,PaddleOCR 也提供了其他两种部署方式,详细说明如下:
|
||||
|
||||
🚀 高性能推理:在实际生产环境中,许多应用对部署策略的性能指标(尤其是响应速度)有着较严苛的标准,以确保系统的高效运行与用户体验的流畅性。为此,PaddleOCR 提供高性能推理功能,旨在对模型推理及前后处理进行深度性能优化,实现端到端流程的显著提速,详细的高性能推理流程请参考[高性能推理](../deployment/high_performance_inference.md)。
|
||||
|
||||
☁️ 服务化部署:服务化部署是实际生产环境中常见的一种部署形式。通过将推理功能封装为服务,客户端可以通过网络请求来访问这些服务,以获取推理结果。详细的产线服务化部署流程请参考[服务化部署](../deployment/serving.md)。
|
||||
|
||||
以下是基础服务化部署的API参考与多语言服务调用示例:
|
||||
|
||||
<details><summary>API参考</summary>
|
||||
|
||||
<p>对于服务提供的主要操作:</p>
|
||||
<ul>
|
||||
<li>HTTP请求方法为POST。</li>
|
||||
<li>请求体和响应体均为JSON数据(JSON对象)。</li>
|
||||
<li>当请求处理成功时,响应状态码为<code>200</code>,响应体的属性如下:</li>
|
||||
</ul>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>名称</th>
|
||||
<th>类型</th>
|
||||
<th>含义</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><code>logId</code></td>
|
||||
<td><code>string</code></td>
|
||||
<td>请求的UUID。</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>errorCode</code></td>
|
||||
<td><code>integer</code></td>
|
||||
<td>错误码。固定为<code>0</code>。</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>errorMsg</code></td>
|
||||
<td><code>string</code></td>
|
||||
<td>错误说明。固定为<code>"Success"</code>。</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>result</code></td>
|
||||
<td><code>object</code></td>
|
||||
<td>操作结果。</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<ul>
|
||||
<li>当请求处理未成功时,响应体的属性如下:</li>
|
||||
</ul>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>名称</th>
|
||||
<th>类型</th>
|
||||
<th>含义</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><code>logId</code></td>
|
||||
<td><code>string</code></td>
|
||||
<td>请求的UUID。</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>errorCode</code></td>
|
||||
<td><code>integer</code></td>
|
||||
<td>错误码。与响应状态码相同。</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>errorMsg</code></td>
|
||||
<td><code>string</code></td>
|
||||
<td>错误说明。</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<p>服务提供的主要操作如下:</p>
|
||||
<ul>
|
||||
<li><b><code>infer</code></b></li>
|
||||
</ul>
|
||||
<p>对输入消息进行推理生成响应。</p>
|
||||
<p><code>POST /document-understanding</code></p>
|
||||
<p>说明 以上接口别名/chat/completion,openai兼容的接口</p>
|
||||
|
||||
<ul>
|
||||
<li>请求体的属性如下:</li>
|
||||
</ul>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>名称</th>
|
||||
<th>类型</th>
|
||||
<th>含义</th>
|
||||
<th>是否必填</th>
|
||||
<th>默认值</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><code>model</code></td>
|
||||
<td><code>string</code></td>
|
||||
<td>要使用的模型名称</td>
|
||||
<td>是</td>
|
||||
<td>-</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>messages</code></td>
|
||||
<td><code>array</code></td>
|
||||
<td>对话消息列表</td>
|
||||
<td>是</td>
|
||||
<td>-</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>max_tokens</code></td>
|
||||
<td><code>integer</code></td>
|
||||
<td>生成的最大token数</td>
|
||||
<td>否</td>
|
||||
<td>1024</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>temperature</code></td>
|
||||
<td><code>float</code></td>
|
||||
<td>采样温度</td>
|
||||
<td>否</td>
|
||||
<td>0.1</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>top_p</code></td>
|
||||
<td><code>float</code></td>
|
||||
<td>核心采样概率</td>
|
||||
<td>否</td>
|
||||
<td>0.95</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>stream</code></td>
|
||||
<td><code>boolean</code></td>
|
||||
<td>是否流式输出</td>
|
||||
<td>否</td>
|
||||
<td>false</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>max_image_tokens</code></td>
|
||||
<td><code>int</code></td>
|
||||
<td>图像的最大输入token数</td>
|
||||
<td>否</td>
|
||||
<td>None</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<p><code>messages</code>中的每个元素为一个<code>object</code>,具有如下属性:</p>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>名称</th>
|
||||
<th>类型</th>
|
||||
<th>含义</th>
|
||||
<th>是否必填</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><code>role</code></td>
|
||||
<td><code>string</code></td>
|
||||
<td>消息角色(user/assistant/system)</td>
|
||||
<td>是</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>content</code></td>
|
||||
<td><code>string</code>或<code>array</code></td>
|
||||
<td>消息内容(文本或图文混合)</td>
|
||||
<td>是</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<p>当<code>content</code>为数组时,每个元素为一个<code>object</code>,具有如下属性:</p>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>名称</th>
|
||||
<th>类型</th>
|
||||
<th>含义</th>
|
||||
<th>是否必填</th>
|
||||
<th>默认值</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><code>type</code></td>
|
||||
<td><code>string</code></td>
|
||||
<td>内容类型(text/image_url)</td>
|
||||
<td>是</td>
|
||||
<td>-</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>text</code></td>
|
||||
<td><code>string</code></td>
|
||||
<td>文本内容(当type为text时)</td>
|
||||
<td>条件必填</td>
|
||||
<td>-</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>image_url</code></td>
|
||||
<td><code>string</code>或<code>object</code></td>
|
||||
<td>图片URL或对象(当type为image_url时)</td>
|
||||
<td>条件必填</td>
|
||||
<td>-</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<p>当<code>image_url</code>为对象时,具有如下属性:</p>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>名称</th>
|
||||
<th>类型</th>
|
||||
<th>含义</th>
|
||||
<th>是否必填</th>
|
||||
<th>默认值</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><code>url</code></td>
|
||||
<td><code>string</code></td>
|
||||
<td>图片URL</td>
|
||||
<td>是</td>
|
||||
<td>-</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>detail</code></td>
|
||||
<td><code>string</code></td>
|
||||
<td>图片细节处理方式(low/high/auto)</td>
|
||||
<td>否</td>
|
||||
<td>auto</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<p>请求处理成功时,响应体的<code>result</code>具有如下属性:</p>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>名称</th>
|
||||
<th>类型</th>
|
||||
<th>含义</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><code>id</code></td>
|
||||
<td><code>string</code></td>
|
||||
<td>请求ID</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>object</code></td>
|
||||
<td><code>string</code></td>
|
||||
<td>对象类型(chat.completion)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>created</code></td>
|
||||
<td><code>integer</code></td>
|
||||
<td>创建时间戳</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>choices</code></td>
|
||||
<td><code>array</code></td>
|
||||
<td>生成结果选项</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>usage</code></td>
|
||||
<td><code>object</code></td>
|
||||
<td>token使用情况</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<p><code>choices</code>中的每个元素为一个<code>Choice</code>对象,具有如下属性:</p>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>名称</th>
|
||||
<th>类型</th>
|
||||
<th>含义</th>
|
||||
<th>可选值</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><code>finish_reason</code></td>
|
||||
<td><code>string</code></td>
|
||||
<td>模型停止生成token的原因</td>
|
||||
<td><code>stop</code>(自然停止)<br><code>length</code>(达到最大token数)<br><code>tool_calls</code>(调用了工具)<br><code>content_filter</code>(内容过滤)<br><code>function_call</code>(调用了函数,已弃用)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>index</code></td>
|
||||
<td><code>integer</code></td>
|
||||
<td>选项在列表中的索引</td>
|
||||
<td>-</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>logprobs</code></td>
|
||||
<td><code>object</code> | <code>null</code></td>
|
||||
<td>选项的log概率信息</td>
|
||||
<td>-</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>message</code></td>
|
||||
<td><code>ChatCompletionMessage</code></td>
|
||||
<td>模型生成的聊天消息</td>
|
||||
<td>-</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<p><code>message</code>对象具有如下属性:</p>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>名称</th>
|
||||
<th>类型</th>
|
||||
<th>含义</th>
|
||||
<th>备注</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><code>content</code></td>
|
||||
<td><code>string</code> | <code>null</code></td>
|
||||
<td>消息内容</td>
|
||||
<td>可能为空</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>refusal</code></td>
|
||||
<td><code>string</code> | <code>null</code></td>
|
||||
<td>模型生成的拒绝消息</td>
|
||||
<td>当内容被拒绝时提供</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>role</code></td>
|
||||
<td><code>string</code></td>
|
||||
<td>消息作者角色</td>
|
||||
<td>固定为<code>"assistant"</code></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>audio</code></td>
|
||||
<td><code>object</code> | <code>null</code></td>
|
||||
<td>音频输出数据</td>
|
||||
<td>当请求音频输出时提供<br><a href="https://platform.openai.com/docs/guides/audio">了解更多</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>function_call</code></td>
|
||||
<td><code>object</code> | <code>null</code></td>
|
||||
<td>应调用的函数名称和参数</td>
|
||||
<td>已弃用,推荐使用<code>tool_calls</code></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>tool_calls</code></td>
|
||||
<td><code>array</code> | <code>null</code></td>
|
||||
<td>模型生成的工具调用</td>
|
||||
<td>如函数调用等</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<p><code>usage</code>对象具有如下属性:</p>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>名称</th>
|
||||
<th>类型</th>
|
||||
<th>含义</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><code>prompt_tokens</code></td>
|
||||
<td><code>integer</code></td>
|
||||
<td>提示token数</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>completion_tokens</code></td>
|
||||
<td><code>integer</code></td>
|
||||
<td>生成token数</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>total_tokens</code></td>
|
||||
<td><code>integer</code></td>
|
||||
<td>总token数</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<p><code>result</code>示例如下:</p>
|
||||
<pre><code class="language-json">{
|
||||
"id": "ed960013-eb19-43fa-b826-3c1b59657e35",
|
||||
"choices": [
|
||||
{
|
||||
"finish_reason": "stop",
|
||||
"index": 0,
|
||||
"message": {
|
||||
"content": "| 名次 | 国家/地区 | 金牌 | 银牌 | 铜牌 | 奖牌总数 |\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",
|
||||
"role": "assistant"
|
||||
}
|
||||
}
|
||||
],
|
||||
"created": 1745218041,
|
||||
"model": "pp-docbee",
|
||||
"object": "chat.completion"
|
||||
}
|
||||
</code></pre></details>
|
||||
|
||||
<details><summary>多语言调用服务示例</summary>
|
||||
|
||||
<details>
|
||||
<summary>Python</summary>
|
||||
openai接口调用示例
|
||||
|
||||
<pre><code class="language-python">import base64
|
||||
from openai import OpenAI
|
||||
|
||||
API_BASE_URL = "http://127.0.0.1:8080"
|
||||
|
||||
# 初始化OpenAI客户端
|
||||
client = OpenAI(
|
||||
api_key='xxxxxxxxx',
|
||||
base_url=f'{API_BASE_URL}'
|
||||
)
|
||||
|
||||
#图片转base64函数
|
||||
def encode_image(image_path):
|
||||
with open(image_path, "rb") as image_file:
|
||||
return base64.b64encode(image_file.read()).decode('utf-8')
|
||||
|
||||
#输入图片路径
|
||||
image_path = "medal_table.png"
|
||||
|
||||
#原图片转base64
|
||||
base64_image = encode_image(image_path)
|
||||
|
||||
#提交信息至PP-DocBee模型
|
||||
response = client.chat.completions.create(
|
||||
model="pp-docbee",#选择模型
|
||||
messages=[
|
||||
{
|
||||
"role": "system",
|
||||
"content": "You are a helpful assistant."
|
||||
},
|
||||
{
|
||||
"role": "user",
|
||||
"content":[
|
||||
{
|
||||
"type": "text",
|
||||
"text": "识别这份表格的内容,输出html格式的内容"
|
||||
},
|
||||
{
|
||||
"type": "image_url",
|
||||
"image_url": {"url": f"data:image/jpeg;base64,{base64_image}"}
|
||||
},
|
||||
]
|
||||
},
|
||||
],
|
||||
)
|
||||
content = response.choices[0].message.content
|
||||
print('Reply:', content)
|
||||
</code></pre></details>
|
||||
</details>
|
||||
<br/>
|
||||
|
||||
## 4. 二次开发
|
||||
|
||||
当前产线暂时不支持微调训练,仅支持推理集成。关于该产线的微调训练,计划在未来支持。
|
||||
1939
docs/version3.x/pipeline_usage/formula_recognition.en.md
Normal file
1939
docs/version3.x/pipeline_usage/formula_recognition.en.md
Normal file
File diff suppressed because one or more lines are too long
1915
docs/version3.x/pipeline_usage/formula_recognition.md
Normal file
1915
docs/version3.x/pipeline_usage/formula_recognition.md
Normal file
File diff suppressed because one or more lines are too long
@@ -0,0 +1,215 @@
|
||||
# Parallel Inference in Pipeline
|
||||
|
||||
## Specifying Multiple Inference Devices
|
||||
|
||||
For some pipelines, both the CLI and Python API of PaddleOCR support specifying multiple inference devices simultaneously. If multiple devices are specified, during pipeline initialization, an instance of the underlying pipeline class will be created on each device, and the received inputs will be processed using parallel inference. For example, for the document image preprocessing pipeline:
|
||||
|
||||
```bash
|
||||
paddleocr doc_preprocessor \
|
||||
--input input_images/ \
|
||||
--device 'gpu:0,1,2,3' \
|
||||
--use_doc_orientation_classify True \
|
||||
--use_doc_unwarping True
|
||||
--save_path ./output \
|
||||
|
||||
```
|
||||
|
||||
```python
|
||||
from paddleocr import DocPreprocessor
|
||||
|
||||
|
||||
pipeline = DocPreprocessor(device="gpu:0,1,2,3")
|
||||
output = pipeline.predict(
|
||||
input="input_images/",
|
||||
use_doc_orientation_classify=True,
|
||||
use_doc_unwarping=True)
|
||||
|
||||
```
|
||||
|
||||
Both examples above use 4 GPUs (numbered 0, 1, 2, 3) to perform parallel inference on the `doc_test_rotated.jpg` image.
|
||||
|
||||
When specifying multiple devices, the inference interface remains consistent with that of single-device usage. Please refer to the production line usage tutorial to check whether a specific production line supports multiple inference devices.
|
||||
|
||||
## Example of Multi-Process Parallel Inference
|
||||
|
||||
Beyond PaddleOCR's built-in multi-device parallel inference capability, users can also implement parallelism by wrapping PaddleOCR pipeline API calls themselves according to their specific scenario, with a view to achieving a better speedup. Below is an example of using Python multiprocessing to perform multi-GPU, multi-instance parallel processing on files in an input directory.
|
||||
|
||||
|
||||
|
||||
```python
|
||||
import argparse
|
||||
import sys
|
||||
from multiprocessing import Manager, Process
|
||||
from pathlib import Path
|
||||
from queue import Empty
|
||||
|
||||
import paddleocr
|
||||
|
||||
|
||||
def load_pipeline(class_name: str, device: str):
|
||||
if not hasattr(paddleocr, class_name):
|
||||
raise ValueError(f"Class {class_name} not found in paddleocr module.")
|
||||
cls = getattr(paddleocr, class_name)
|
||||
return cls(device=device)
|
||||
|
||||
|
||||
def worker(pipeline_class_path, device, task_queue, batch_size, output_dir):
|
||||
pipeline = load_pipeline(pipeline_class_path, device)
|
||||
|
||||
should_end = False
|
||||
batch = []
|
||||
|
||||
while not should_end:
|
||||
try:
|
||||
input_path = task_queue.get_nowait()
|
||||
except Empty:
|
||||
should_end = True
|
||||
else:
|
||||
batch.append(input_path)
|
||||
|
||||
if batch and (len(batch) == batch_size or should_end):
|
||||
try:
|
||||
for result in pipeline.predict(batch):
|
||||
input_path = Path(result["input_path"])
|
||||
if result.get("page_index") is not None:
|
||||
output_path = f"{input_path.stem}_{result['page_index']}.json"
|
||||
else:
|
||||
output_path = f"{input_path.stem}.json"
|
||||
output_path = str(Path(output_dir, output_path))
|
||||
result.save_to_json(output_path)
|
||||
print(f"Processed {repr(str(input_path))}")
|
||||
except Exception as e:
|
||||
print(
|
||||
f"Error processing {batch} on {repr(device)}: {e}",
|
||||
file=sys.stderr
|
||||
)
|
||||
batch.clear()
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
|
||||
parser.add_argument(
|
||||
"--pipeline",
|
||||
type=str,
|
||||
required=True,
|
||||
help="PaddleOCR pipeline, e.g. 'DocPreprocessor'.",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--input_dir", type=str, required=True, help="Input directory."
|
||||
)
|
||||
parser.add_argument(
|
||||
"--device",
|
||||
type=str,
|
||||
required=True,
|
||||
help="Specifies the devices for performing parallel inference.",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--output_dir", type=str, default="output", help="Output directory."
|
||||
)
|
||||
parser.add_argument(
|
||||
"--instances_per_device",
|
||||
type=int,
|
||||
default=1,
|
||||
help="Number of pipeline instances per device.",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--batch_size",
|
||||
type=int,
|
||||
default=1,
|
||||
help="Inference batch size for each pipeline instance.",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--input_glob_pattern",
|
||||
type=str,
|
||||
default="*",
|
||||
help="Pattern to find the input files.",
|
||||
)
|
||||
args = parser.parse_args()
|
||||
|
||||
input_dir = Path(args.input_dir)
|
||||
if not input_dir.exists():
|
||||
print(f"The input directory does not exist: {input_dir}", file=sys.stderr)
|
||||
return 2
|
||||
if not input_dir.is_dir():
|
||||
print(f"{repr(str(input_dir))} is not a directory.", file=sys.stderr)
|
||||
return 2
|
||||
|
||||
output_dir = Path(args.output_dir)
|
||||
if output_dir.exists() and not output_dir.is_dir():
|
||||
print(f"{repr(str(output_dir))} is not a directory.", file=sys.stderr)
|
||||
return 2
|
||||
output_dir.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
from paddlex.utils.device import constr_device, parse_device
|
||||
|
||||
device_type, device_ids = parse_device(args.device)
|
||||
if device_ids is None or len(device_ids) == 1:
|
||||
print(
|
||||
"Please specify at least two devices for performing parallel inference.",
|
||||
file=sys.stderr,
|
||||
)
|
||||
return 2
|
||||
|
||||
if args.batch_size <= 0:
|
||||
print("Batch size must be greater than 0.", file=sys.stderr)
|
||||
return 2
|
||||
|
||||
with Manager() as manager:
|
||||
task_queue = manager.Queue()
|
||||
for img_path in input_dir.glob(args.input_glob_pattern):
|
||||
task_queue.put(str(img_path))
|
||||
|
||||
processes = []
|
||||
for device_id in device_ids:
|
||||
for _ in range(args.instances_per_device):
|
||||
device = constr_device(device_type, [device_id])
|
||||
p = Process(
|
||||
target=worker,
|
||||
args=(
|
||||
args.pipeline,
|
||||
device,
|
||||
task_queue,
|
||||
args.batch_size,
|
||||
str(output_dir),
|
||||
),
|
||||
)
|
||||
p.start()
|
||||
processes.append(p)
|
||||
|
||||
for p in processes:
|
||||
p.join()
|
||||
|
||||
print("All done")
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
|
||||
```
|
||||
Assuming the script is saved as `infer_mp.py`, here are some example commands for running it:
|
||||
```bash
|
||||
# For the exact value of the `--pipeline` parameter, please refer to the **script** import name of the pipeline
|
||||
# This is for the general layout analysis V3 pipeline, corresponding to `PPStructureV3`
|
||||
# Process all files in the `input_images` directory
|
||||
# Use GPUs 0, 1, 2, and 3, with 1 pipeline instance per GPU, and each instance processes 1 input file at a time
|
||||
python infer_mp.py \
|
||||
--pipeline PPStructureV3 \
|
||||
--input_dir input_images/ \
|
||||
--device 'gpu:0,1,2,3' \
|
||||
--output_dir output
|
||||
|
||||
# General layout analysis V3 pipeline
|
||||
# Process all files with the `.jpg` suffix in the `input_images` directory
|
||||
# Use GPUs 0 and 2, with 2 pipeline instances per GPU, and each instance processes 4 input files at a time
|
||||
python infer_mp.py \
|
||||
--pipeline PPStructureV3 \
|
||||
--input_dir input_images/ \
|
||||
--device 'gpu:0,2' \
|
||||
--output_dir output \
|
||||
--instances_per_device 2 \
|
||||
--batch_size 4 \
|
||||
--input_glob_pattern '*.jpg'
|
||||
|
||||
```
|
||||
@@ -0,0 +1,214 @@
|
||||
# 产线并行推理
|
||||
|
||||
## 指定多个推理设备
|
||||
|
||||
对于部分产线的 CLI 和 Python API,PaddleOCR 支持同时指定多个推理设备。如果指定了多个设备,产线初始化时将在每个设备上创建一个底层产线类对象的实例,并对接收到的输入进行并行推理。例如,对于文档图像预处理产线:
|
||||
|
||||
```bash
|
||||
paddleocr doc_preprocessor \
|
||||
--input input_images/ \
|
||||
--device 'gpu:0,1,2,3' \
|
||||
--use_doc_orientation_classify True \
|
||||
--use_doc_unwarping True
|
||||
--save_path ./output \
|
||||
|
||||
```
|
||||
|
||||
```python
|
||||
from paddleocr import DocPreprocessor
|
||||
|
||||
|
||||
pipeline = DocPreprocessor(device="gpu:0,1,2,3")
|
||||
output = pipeline.predict(
|
||||
input="input_images/",
|
||||
use_doc_orientation_classify=True,
|
||||
use_doc_unwarping=True)
|
||||
|
||||
```
|
||||
|
||||
以上两个例子均使用 4 块 GPU(编号为 0、1、2、3)对 `doc_test_rotated.jpg` 图片进行并行推理。
|
||||
|
||||
指定多个设备时,推理接口仍然与指定单设备时保持一致。请查看产线使用教程以了解某一产线是否支持指定多个推理设备。
|
||||
|
||||
## 多进程并行推理示例
|
||||
|
||||
除了使用 PaddleOCR 内置的多设备并行推理功能外,用户也可以结合实际场景,通过封装 PaddleOCR 产线 API 调用来实现并行处理,从而获得更优的加速效果。如下是使用 Python 多进程实现多卡、多实例并行处理输入目录中的文件的示例代码:
|
||||
|
||||
```python
|
||||
import argparse
|
||||
import sys
|
||||
from multiprocessing import Manager, Process
|
||||
from pathlib import Path
|
||||
from queue import Empty
|
||||
|
||||
import paddleocr
|
||||
|
||||
|
||||
def load_pipeline(class_name: str, device: str):
|
||||
if not hasattr(paddleocr, class_name):
|
||||
raise ValueError(f"Class {class_name} not found in paddleocr module.")
|
||||
cls = getattr(paddleocr, class_name)
|
||||
return cls(device=device)
|
||||
|
||||
|
||||
def worker(pipeline_class_path, device, task_queue, batch_size, output_dir):
|
||||
pipeline = load_pipeline(pipeline_class_path, device)
|
||||
|
||||
should_end = False
|
||||
batch = []
|
||||
|
||||
while not should_end:
|
||||
try:
|
||||
input_path = task_queue.get_nowait()
|
||||
except Empty:
|
||||
should_end = True
|
||||
else:
|
||||
batch.append(input_path)
|
||||
|
||||
if batch and (len(batch) == batch_size or should_end):
|
||||
try:
|
||||
for result in pipeline.predict(batch):
|
||||
input_path = Path(result["input_path"])
|
||||
if result.get("page_index") is not None:
|
||||
output_path = f"{input_path.stem}_{result['page_index']}.json"
|
||||
else:
|
||||
output_path = f"{input_path.stem}.json"
|
||||
output_path = str(Path(output_dir, output_path))
|
||||
result.save_to_json(output_path)
|
||||
print(f"Processed {repr(str(input_path))}")
|
||||
except Exception as e:
|
||||
print(
|
||||
f"Error processing {batch} on {repr(device)}: {e}",
|
||||
file=sys.stderr
|
||||
)
|
||||
batch.clear()
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
|
||||
parser.add_argument(
|
||||
"--pipeline",
|
||||
type=str,
|
||||
required=True,
|
||||
help="PaddleOCR pipeline, e.g. 'DocPreprocessor'.",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--input_dir", type=str, required=True, help="Input directory."
|
||||
)
|
||||
parser.add_argument(
|
||||
"--device",
|
||||
type=str,
|
||||
required=True,
|
||||
help="Specifies the devices for performing parallel inference.",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--output_dir", type=str, default="output", help="Output directory."
|
||||
)
|
||||
parser.add_argument(
|
||||
"--instances_per_device",
|
||||
type=int,
|
||||
default=1,
|
||||
help="Number of pipeline instances per device.",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--batch_size",
|
||||
type=int,
|
||||
default=1,
|
||||
help="Inference batch size for each pipeline instance.",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--input_glob_pattern",
|
||||
type=str,
|
||||
default="*",
|
||||
help="Pattern to find the input files.",
|
||||
)
|
||||
args = parser.parse_args()
|
||||
|
||||
input_dir = Path(args.input_dir)
|
||||
if not input_dir.exists():
|
||||
print(f"The input directory does not exist: {input_dir}", file=sys.stderr)
|
||||
return 2
|
||||
if not input_dir.is_dir():
|
||||
print(f"{repr(str(input_dir))} is not a directory.", file=sys.stderr)
|
||||
return 2
|
||||
|
||||
output_dir = Path(args.output_dir)
|
||||
if output_dir.exists() and not output_dir.is_dir():
|
||||
print(f"{repr(str(output_dir))} is not a directory.", file=sys.stderr)
|
||||
return 2
|
||||
output_dir.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
from paddlex.utils.device import constr_device, parse_device
|
||||
|
||||
device_type, device_ids = parse_device(args.device)
|
||||
if device_ids is None or len(device_ids) == 1:
|
||||
print(
|
||||
"Please specify at least two devices for performing parallel inference.",
|
||||
file=sys.stderr,
|
||||
)
|
||||
return 2
|
||||
|
||||
if args.batch_size <= 0:
|
||||
print("Batch size must be greater than 0.", file=sys.stderr)
|
||||
return 2
|
||||
|
||||
with Manager() as manager:
|
||||
task_queue = manager.Queue()
|
||||
for img_path in input_dir.glob(args.input_glob_pattern):
|
||||
task_queue.put(str(img_path))
|
||||
|
||||
processes = []
|
||||
for device_id in device_ids:
|
||||
for _ in range(args.instances_per_device):
|
||||
device = constr_device(device_type, [device_id])
|
||||
p = Process(
|
||||
target=worker,
|
||||
args=(
|
||||
args.pipeline,
|
||||
device,
|
||||
task_queue,
|
||||
args.batch_size,
|
||||
str(output_dir),
|
||||
),
|
||||
)
|
||||
p.start()
|
||||
processes.append(p)
|
||||
|
||||
for p in processes:
|
||||
p.join()
|
||||
|
||||
print("All done")
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
|
||||
```
|
||||
|
||||
假设将上述脚本存储为 `infer_mp.py`,以下是一些调用示例:
|
||||
|
||||
```bash
|
||||
# 确定 `--pipeline` 参数需查看其产线 **脚本方式** 导入类名称
|
||||
# 此处为通用版面解析 v3 产线,对应PPStructureV3
|
||||
# 处理 `input_images` 目录中所有文件
|
||||
# 使用 GPU 0、1、2、3,每块 GPU 上 1 个产线实例,每个实例一次处理 1 个输入文件
|
||||
python infer_mp.py \
|
||||
--pipeline PPStructureV3 \
|
||||
--input_dir input_images/ \
|
||||
--device 'gpu:0,1,2,3' \
|
||||
--output_dir output
|
||||
|
||||
# 通用版面解析 v3 产线
|
||||
# 处理 `input_images` 目录中所有后缀为 `.jpg` 的文件
|
||||
# 使用 GPU 0、2,每块 GPU 上 2 个产线实例,每个实例一次处理 4 个输入文件
|
||||
python infer_mp.py \
|
||||
--pipeline PPStructureV3 \
|
||||
--input_dir input_images/ \
|
||||
--device 'gpu:0,2' \
|
||||
--output_dir output \
|
||||
--instances_per_device 2 \
|
||||
--batch_size 4 \
|
||||
--input_glob_pattern '*.jpg'
|
||||
```
|
||||
3
docs/version3.x/pipeline_usage/pipeline_overview.en.md
Normal file
3
docs/version3.x/pipeline_usage/pipeline_overview.en.md
Normal file
@@ -0,0 +1,3 @@
|
||||
# Pipeline Overview
|
||||
|
||||
A pipeline is a practical functional implementation composed of one or more modules. Through reasonable module combination and configuration, pipelines can meet the needs of complex application scenarios, such as technological applications like Optical Character Recognition (OCR). Pipelines not only demonstrate the integrated application of basic modules but also support capabilities such as high-performance inference and service-oriented deployment, providing users with higher development efficiency and broader application possibilities.
|
||||
3
docs/version3.x/pipeline_usage/pipeline_overview.md
Normal file
3
docs/version3.x/pipeline_usage/pipeline_overview.md
Normal file
@@ -0,0 +1,3 @@
|
||||
# 产线概述
|
||||
|
||||
产线是由一个或多个模块组合而成的实际功能实现。通过合理的模块组合与配置,产线能够满足复杂应用场景的需求,比如光学字符识别(OCR)等技术应用。产线不仅体现了基础模块的整合应用,还支持高性能推理和服务化部署等能力,赋予用户更高的开发效率和更广泛的应用可能性。
|
||||
2382
docs/version3.x/pipeline_usage/seal_recognition.en.md
Normal file
2382
docs/version3.x/pipeline_usage/seal_recognition.en.md
Normal file
File diff suppressed because it is too large
Load Diff
2373
docs/version3.x/pipeline_usage/seal_recognition.md
Normal file
2373
docs/version3.x/pipeline_usage/seal_recognition.md
Normal file
File diff suppressed because it is too large
Load Diff
2703
docs/version3.x/pipeline_usage/table_recognition_v2.en.md
Normal file
2703
docs/version3.x/pipeline_usage/table_recognition_v2.en.md
Normal file
File diff suppressed because it is too large
Load Diff
2702
docs/version3.x/pipeline_usage/table_recognition_v2.md
Normal file
2702
docs/version3.x/pipeline_usage/table_recognition_v2.md
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user