Skip to content

Commit 308f19d

Browse files
authored
update multy_devices_use_guide docs (#2670)
1 parent e05a420 commit 308f19d

File tree

2 files changed

+72
-2
lines changed

2 files changed

+72
-2
lines changed

docs/other_devices_support/multi_devices_use_guide.en.md

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,4 +166,39 @@ All packages are installed.
166166

167167
## 2. Usage
168168

169-
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. For detailed usage tutorials, please refer to [PaddleX Pipeline Development Tool Local Usage Guide](../pipeline_usage/pipeline_develop_guide.en.md).
169+
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.
170+
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.
171+
* Command line
172+
173+
```bash
174+
paddlex --pipeline OCR --input general_ocr_002.png --device npu:0 # change the device name to npu, mlu, xpu, dcu or gcu
175+
```
176+
* Python Script
177+
178+
```python
179+
from paddlex import create_pipeline
180+
181+
pipeline = create_pipeline(pipeline="OCR", device="npu:0") # change the device name to npu, mlu, xpu, dcu or gcu
182+
183+
output = pipeline.predict("general_ocr_002.png")
184+
for res in output:
185+
res.print()
186+
res.save_to_img("./output/")
187+
```
188+
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).
189+
190+
```bash
191+
# train
192+
python main.py -c paddlex/configs/text_detection/PP-OCRv4_mobile_det.yaml \
193+
-o Global.mode=train \
194+
-o Global.dataset_dir=./dataset/ocr_det_dataset_examples \ # change the dataset_dir to your own dataset path
195+
-o Global.device=npu:0,1,2,3 # change the device name to npu, mlu, xpu, dcu or gcu
196+
197+
# predict
198+
python main.py -c paddlex/configs/text_detection/PP-OCRv4_mobile_det.yaml \
199+
-o Global.mode=predict \
200+
-o Predict.model_dir="./output/best_accuracy/inference" \
201+
-o Predict.input="general_ocr_001.png"
202+
-o Global.device=npu # change the device name to npu, mlu, xpu, dcu or gcu
203+
```
204+
For more detailed usage tutorials, please refer to [PaddleX Pipeline Development Tool Local Usage Guide](../pipeline_usage/pipeline_develop_guide.en.md).

docs/other_devices_support/multi_devices_use_guide.md

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,4 +163,39 @@ paddlex --install --platform gitee.com
163163
All packages are installed.
164164
```
165165
## 2、使用
166-
基于昇腾 NPU、寒武纪 MLU、昆仑 XPU、海光DCU、燧原 GCU 硬件平台的 PaddleX 模型产线开发工具使用方法与 GPU 相同,只需根据所属硬件平台,修改配置设备的参数,详细的使用教程可以查阅[PaddleX产线开发工具本地使用教程](../pipeline_usage/pipeline_develop_guide.md)
166+
基于昇腾 NPU、寒武纪 MLU、昆仑 XPU、海光DCU、燧原 GCU 硬件平台的 PaddleX 模型产线开发工具使用方法与 GPU 相同,只需根据所属硬件平台,修改配置设备的参数。
167+
下面以通用 OCR 产线为例介绍使用方法。通用 OCR 产线用于解决文字识别任务,提取图片中的文字信息以文本形式输出,PP-OCRv4 是一个端到端 OCR 串联系统,可实现 CPU 上毫秒级的文本内容精准预测,在通用场景上达到开源SOTA,可以直接使用该产线提供的预训练模型进行推理:
168+
* 命令行方式
169+
170+
```bash
171+
paddlex --pipeline OCR --input general_ocr_002.png --device npu:0 # 将设备名修改为 npu、mlu、xpu、dcu 或 gcu
172+
```
173+
* Python脚本方式
174+
175+
```python
176+
from paddlex import create_pipeline
177+
178+
pipeline = create_pipeline(pipeline="OCR", device="npu:0") # 将设备名修改为 npu、mlu、xpu、dcu 或 gcu
179+
180+
output = pipeline.predict("general_ocr_002.png")
181+
for res in output:
182+
res.print()
183+
res.save_to_img("./output/")
184+
```
185+
如果对预训练模型的效果不满意,可以进行模型微调,以 PP-OCRv4 移动端文本检测模型(`PP-OCRv4_mobile_det`)为例介绍单模型开发:
186+
187+
```bash
188+
# 训练
189+
python main.py -c paddlex/configs/text_detection/PP-OCRv4_mobile_det.yaml \
190+
-o Global.mode=train \
191+
-o Global.dataset_dir=./dataset/ocr_det_dataset_examples \ # 修改为自己的数据集路径
192+
-o Global.device=npu:0,1,2,3 # 多卡训练,将设备名修改为 npu、mlu、xpu 或 dcu
193+
194+
# 推理
195+
python main.py -c paddlex/configs/text_detection/PP-OCRv4_mobile_det.yaml \
196+
-o Global.mode=predict \
197+
-o Predict.model_dir="./output/best_accuracy/inference" \
198+
-o Predict.input="general_ocr_001.png"
199+
-o Global.device=npu # 将设备名修改为 npu、mlu、xpu、dcu 或 gcu
200+
```
201+
更多产线的使用教程可以查阅[PaddleX产线开发工具本地使用教程](../pipeline_usage/pipeline_develop_guide.md)

0 commit comments

Comments
 (0)