Skip to content

Commit

Permalink
update multy_devices_use_guide docs (#2740)
Browse files Browse the repository at this point in the history
  • Loading branch information
a31413510 authored Dec 30, 2024
1 parent cbfd7c1 commit 0a83956
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 2 deletions.
37 changes: 36 additions & 1 deletion docs/other_devices_support/multi_devices_use_guide.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,4 +164,39 @@ All packages are installed.

## 2. Usage

The usage of PaddleX model pipeline development tool on hardware platforms such as Ascend NPU, Cambricon MLU, Kunlun XPU, and Hygon DCU is identical to that on GPU. You only need to modify the device configuration parameters according to your hardware platform. For detailed usage tutorials, please refer to [PaddleX Pipeline Development Tool Local Usage Guide](../pipeline_usage/pipeline_develop_guide.en.md).
The usage of PaddleX model pipeline development tool on hardware platforms such as Ascend NPU, Cambricon MLU, Kunlun XPU, Hygon DCU and Enflame GCU is identical to that on GPU. You only need to modify the device configuration parameters according to your hardware platform.
Taking the general OCR pipeline as an example to introduce the pipeline development tools.The General OCR Pipeline is designed to solve text recognition tasks, extracting text information from images and outputting it in text form. PP-OCRv4 is an end-to-end OCR system that achieves millisecond-level text content prediction on CPUs, reaching state-of-the-art (SOTA) performance in open-source projects for general scenarios.You can directly use the pre-trained models provided by OCR pipeline for inference.
* Command line

```bash
paddlex --pipeline OCR --input general_ocr_002.png --device npu:0 # change the device name to npu, mlu, xpu, dcu or gcu
```
* Python Script

```python
from paddlex import create_pipeline

pipeline = create_pipeline(pipeline="OCR", device="npu:0") # change the device name to npu, mlu, xpu, dcu or gcu

output = pipeline.predict("general_ocr_002.png")
for res in output:
res.print()
res.save_to_img("./output/")
```
If you are not satisfied with the performance of the pre-trained model, you can fine-tune it. For example, let's discuss single model development using the PP-OCRv4 mobile text detection model (PP-OCRv4_mobile_det).

```bash
# train
python main.py -c paddlex/configs/text_detection/PP-OCRv4_mobile_det.yaml \
-o Global.mode=train \
-o Global.dataset_dir=./dataset/ocr_det_dataset_examples \ # change the dataset_dir to your own dataset path
-o Global.device=npu:0,1,2,3 # change the device name to npu, mlu, xpu, dcu or gcu

# predict
python main.py -c paddlex/configs/text_detection/PP-OCRv4_mobile_det.yaml \
-o Global.mode=predict \
-o Predict.model_dir="./output/best_accuracy/inference" \
-o Predict.input="general_ocr_001.png"
-o Global.device=npu # change the device name to npu, mlu, xpu, dcu or gcu
```
For more detailed usage tutorials, please refer to [PaddleX Pipeline Development Tool Local Usage Guide](../pipeline_usage/pipeline_develop_guide.en.md).
37 changes: 36 additions & 1 deletion docs/other_devices_support/multi_devices_use_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,4 +161,39 @@ paddlex --install --platform gitee.com
All packages are installed.
```
## 2、使用
基于昇腾 NPU、寒武纪 MLU、昆仑 XPU、海光DCU 硬件平台的 PaddleX 模型产线开发工具使用方法与 GPU 相同,只需根据所属硬件平台,修改配置设备的参数,详细的使用教程可以查阅[PaddleX产线开发工具本地使用教程](../pipeline_usage/pipeline_develop_guide.md)
基于昇腾 NPU、寒武纪 MLU、昆仑 XPU、海光DCU、燧原 GCU 硬件平台的 PaddleX 模型产线开发工具使用方法与 GPU 相同,只需根据所属硬件平台,修改配置设备的参数。
下面以通用 OCR 产线为例介绍使用方法。通用 OCR 产线用于解决文字识别任务,提取图片中的文字信息以文本形式输出,PP-OCRv4 是一个端到端 OCR 串联系统,可实现 CPU 上毫秒级的文本内容精准预测,在通用场景上达到开源SOTA,可以直接使用该产线提供的预训练模型进行推理:
* 命令行方式

```bash
paddlex --pipeline OCR --input general_ocr_002.png --device npu:0 # 将设备名修改为 npu、mlu、xpu、dcu 或 gcu
```
* Python脚本方式

```python
from paddlex import create_pipeline

pipeline = create_pipeline(pipeline="OCR", device="npu:0") # 将设备名修改为 npu、mlu、xpu、dcu 或 gcu

output = pipeline.predict("general_ocr_002.png")
for res in output:
res.print()
res.save_to_img("./output/")
```
如果对预训练模型的效果不满意,可以进行模型微调,以 PP-OCRv4 移动端文本检测模型(`PP-OCRv4_mobile_det`)为例介绍单模型开发:

```bash
# 训练
python main.py -c paddlex/configs/text_detection/PP-OCRv4_mobile_det.yaml \
-o Global.mode=train \
-o Global.dataset_dir=./dataset/ocr_det_dataset_examples \ # 修改为自己的数据集路径
-o Global.device=npu:0,1,2,3 # 多卡训练,将设备名修改为 npu、mlu、xpu 或 dcu

# 推理
python main.py -c paddlex/configs/text_detection/PP-OCRv4_mobile_det.yaml \
-o Global.mode=predict \
-o Predict.model_dir="./output/best_accuracy/inference" \
-o Predict.input="general_ocr_001.png"
-o Global.device=npu # 将设备名修改为 npu、mlu、xpu、dcu 或 gcu
```
更多产线的使用教程可以查阅[PaddleX产线开发工具本地使用教程](../pipeline_usage/pipeline_develop_guide.md)

0 comments on commit 0a83956

Please sign in to comment.