mirror of
https://github.com/PaddlePaddle/FastDeploy.git
synced 2025-10-06 09:07:10 +08:00

* Update README_CN.md 之前的readme cn复制错了,导致存在死链 * Update README_CN.md * Update README_CN.md * Update README.md * Update README.md * Update README.md * Update README_CN.md * Update README_CN.md * Update README.md * Update README_CN.md * Update README.md * Update README_CN.md * Update README.md * Update RNN.md * Update RNN_CN.md * Update WebDemo.md * Update WebDemo_CN.md * Update install_rknn_toolkit2.md * Update export.md * Update use_cpp_sdk_on_android.md * Update README.md * Update README_Pу́сский_язы́к.md * Update README_Pу́сский_язы́к.md * Update README_Pу́сский_язы́к.md * Update README_Pу́сский_язы́к.md * Update README_हिन्दी.md * Update README_日本語.md * Update README_한국인.md * Update README_日本語.md * Update README_CN.md * Update README_CN.md * Update README.md * Update README_CN.md * Update README.md * Update README.md * Update README_CN.md * Update README_CN.md * Update README_CN.md * Update README_CN.md
60 lines
3.4 KiB
Markdown
60 lines
3.4 KiB
Markdown
English | [简体中文](README_CN.md)
|
|
# PPOCRv3 C++ multi-thread Deployment Example
|
|
|
|
This directory provides examples file `multi_thread_ocr.cc` to fast deploy PPOCRv3 on CPU/GPU and GPU accelerated by TensorRT.
|
|
|
|
Two steps before deployment
|
|
|
|
- 1. Software and hardware should meet the requirements. Please refer to [FastDeploy Environment Requirements](../../../../docs/cn/build_and_install/download_prebuilt_libraries.md)
|
|
- 2. Download the precompiled deployment library and samples code according to your development environment. Refer to [FastDeploy Precompiled Library](../../../../docs/cn/build_and_install/download_prebuilt_libraries.md)
|
|
|
|
Taking the PPOCRv3 inference on Linux as an example, the compilation test can be completed by executing the following command in this directory. FastDeploy version 0.7.0 or above (x.x.x>=0.7.0) is required to support this model.
|
|
|
|
```bash
|
|
mkdir build
|
|
cd build
|
|
# Download the FastDeploy precompiled library. Users can choose your appropriate version in the `FastDeploy Precompiled Library` mentioned above
|
|
wget https://bj.bcebos.com/fastdeploy/release/cpp/fastdeploy-linux-x64-x.x.x.tgz
|
|
tar xvf fastdeploy-linux-x64-x.x.x.tgz
|
|
cmake .. -DFASTDEPLOY_INSTALL_DIR=${PWD}/fastdeploy-linux-x64-x.x.x
|
|
make -j
|
|
|
|
|
|
# Download model, image, and dictionary files
|
|
wget https://paddleocr.bj.bcebos.com/PP-OCRv3/chinese/ch_PP-OCRv3_det_infer.tar
|
|
tar -xvf ch_PP-OCRv3_det_infer.tar
|
|
|
|
wget https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_mobile_v2.0_cls_infer.tar
|
|
tar -xvf ch_ppocr_mobile_v2.0_cls_infer.tar
|
|
|
|
wget https://paddleocr.bj.bcebos.com/PP-OCRv3/chinese/ch_PP-OCRv3_rec_infer.tar
|
|
tar -xvf ch_PP-OCRv3_rec_infer.tar
|
|
|
|
wget https://gitee.com/paddlepaddle/PaddleOCR/raw/release/2.6/doc/imgs/12.jpg
|
|
|
|
wget https://gitee.com/paddlepaddle/PaddleOCR/raw/release/2.6/ppocr/utils/ppocr_keys_v1.txt
|
|
|
|
# CPU multi-thread inference
|
|
./multi_thread_demo ./ch_PP-OCRv3_det_infer ./ch_ppocr_mobile_v2.0_cls_infer ./ch_PP-OCRv3_rec_infer ./ppocr_keys_v1.txt ./12.jpg 0 1
|
|
# GPU multi-thread inference
|
|
./multi_thread_demo ./ch_PP-OCRv3_det_infer ./ch_ppocr_mobile_v2.0_cls_infer ./ch_PP-OCRv3_rec_infer ./ppocr_keys_v1.txt ./12.jpg 1 1
|
|
# TensorRT multi-thread inference on GPU
|
|
./multi_thread_demo ./ch_PP-OCRv3_det_infer ./ch_ppocr_mobile_v2.0_cls_infer ./ch_PP-OCRv3_rec_infer ./ppocr_keys_v1.txt ./12.jpg 2 1
|
|
# Paddle-TRT multi-thread inference on GPU
|
|
./multi_thread_demo ./ch_PP-OCRv3_det_infer ./ch_ppocr_mobile_v2.0_cls_infer ./ch_PP-OCRv3_rec_infer ./ppocr_keys_v1.txt ./12.jpg 3 1
|
|
# KunlunXin XPU multi-thread inference
|
|
./multi_thread_demo ./ch_PP-OCRv3_det_infer ./ch_ppocr_mobile_v2.0_cls_infer ./ch_PP-OCRv3_rec_infer ./ppocr_keys_v1.txt ./12.jpg 4 1
|
|
>> **Notice**: the last number in above command is thread number
|
|
```
|
|
The above command works for Linux or MacOS. For SDK in Windows, refer to:
|
|
- [How to use FastDeploy C++ SDK in Windows](../../../../docs/cn/faq/use_sdk_on_windows.md)
|
|
|
|
The result returned after running is as follows
|
|
```
|
|
Thread Id: 0
|
|
det boxes: [[42,413],[483,391],[484,428],[43,450]]rec text: 上海斯格威铂尔大酒店 rec score:0.980085 cls label: 0 cls score: 1.000000
|
|
det boxes: [[187,456],[399,448],[400,480],[188,488]]rec text: 打浦路15号 rec score:0.964993 cls label: 0 cls score: 1.000000
|
|
det boxes: [[23,507],[513,488],[515,529],[24,548]]rec text: 绿洲仕格维花园公寓 rec score:0.993727 cls label: 0 cls score: 1.000000
|
|
det boxes: [[74,553],[427,542],[428,571],[75,582]]rec text: 打浦路252935号 rec score:0.947723 cls label: 0 cls score: 1.000000
|
|
```
|