mirror of
https://github.com/PaddlePaddle/FastDeploy.git
synced 2025-12-24 13:28:13 +08:00
[Doc] Rename PPOCRSystem to PPOCR and update comments. (#395)
* Imporve OCR Readme * Improve OCR Readme * Improve OCR Readme * Improve OCR Readme * Improve OCR Readme * Add Initialize function to PP-OCR * Add Initialize function to PP-OCR * Add Initialize function to PP-OCR * Make all the model links come from PaddleOCR * Improve OCR readme * Improve OCR readme * Improve OCR readme * Improve OCR readme * Add Readme for vision results * Add Readme for vision results * Add Readme for vision results * Add Readme for vision results * Add Readme for vision results * Add Readme for vision results * Add Readme for vision results * Add Readme for vision results * Add Readme for vision results * Add Readme for vision results * Add check for label file in postprocess of Rec model * Add check for label file in postprocess of Rec model * Add check for label file in postprocess of Rec model * Add check for label file in postprocess of Rec model * Add check for label file in postprocess of Rec model * Add check for label file in postprocess of Rec model * Add comments to create API docs * Improve OCR comments * Rename OCR and add comments * Make sure previous python example works * Make sure previous python example works Co-authored-by: Jason <jiangjiajun@baidu.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
# PPOCRSystemv2 C++部署示例
|
||||
# PPOCRv2 C++部署示例
|
||||
|
||||
本目录下提供`infer.cc`快速完成PPOCRSystemv2在CPU/GPU,以及GPU上通过TensorRT加速部署的示例。
|
||||
本目录下提供`infer.cc`快速完成PPOCRv2在CPU/GPU,以及GPU上通过TensorRT加速部署的示例。
|
||||
|
||||
在部署前,需确认以下两个步骤
|
||||
|
||||
@@ -19,14 +19,14 @@ make -j
|
||||
|
||||
|
||||
# 下载模型,图片和字典文件
|
||||
wget https://bj.bcebos.com/paddlehub/fastdeploy/ch_PP-OCRv2_det_infer.tar.gz
|
||||
tar -xvf ch_PP-OCRv2_det_infer.tar.gz
|
||||
wget https://paddleocr.bj.bcebos.com/PP-OCRv2/chinese/ch_PP-OCRv2_det_infer.tar
|
||||
tar -xvf ch_PP-OCRv2_det_infer.tar
|
||||
|
||||
wget https://bj.bcebos.com/paddlehub/fastdeploy/ch_ppocr_mobile_v2.0_cls_infer.tar.gz
|
||||
tar -xvf ch_ppocr_mobile_v2.0_cls_infer.tar.gz
|
||||
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://bj.bcebos.com/paddlehub/fastdeploy/ch_PP-OCRv2_rec_infer.tar.gz
|
||||
tar -xvf ch_PP-OCRv2_rec_infer.tar.gz
|
||||
wgethttps://paddleocr.bj.bcebos.com/PP-OCRv2/chinese/ch_PP-OCRv2_rec_infer.tar
|
||||
tar -xvf ch_PP-OCRv2_rec_infer.tar
|
||||
|
||||
wget https://gitee.com/paddlepaddle/PaddleOCR/raw/release/2.6/doc/imgs/12.jpg
|
||||
|
||||
@@ -48,17 +48,17 @@ wget https://gitee.com/paddlepaddle/PaddleOCR/raw/release/2.6/ppocr/utils/ppocr_
|
||||
<img width="640" src="https://user-images.githubusercontent.com/109218879/185826024-f7593a0c-1bd2-4a60-b76c-15588484fa08.jpg">
|
||||
|
||||
|
||||
## PPOCRSystemv2 C++接口
|
||||
## PPOCRv2 C++接口
|
||||
|
||||
### PPOCRSystemv2类
|
||||
### PPOCRv2类
|
||||
|
||||
```
|
||||
fastdeploy::application::ocrsystem::PPOCRSystemv2(fastdeploy::vision::ocr::DBDetector* det_model,
|
||||
fastdeploy::pipeline::PPOCRv2(fastdeploy::vision::ocr::DBDetector* det_model,
|
||||
fastdeploy::vision::ocr::Classifier* cls_model,
|
||||
fastdeploy::vision::ocr::Recognizer* rec_model);
|
||||
```
|
||||
|
||||
PPOCRSystemv2 的初始化,由检测,分类和识别模型串联构成
|
||||
PPOCRv2 的初始化,由检测,分类和识别模型串联构成
|
||||
|
||||
**参数**
|
||||
|
||||
@@ -67,10 +67,10 @@ PPOCRSystemv2 的初始化,由检测,分类和识别模型串联构成
|
||||
> * **Recognizer**(model): OCR中的识别模型
|
||||
|
||||
```
|
||||
fastdeploy::application::ocrsystem::PPOCRSystemv2(fastdeploy::vision::ocr::DBDetector* det_model,
|
||||
fastdeploy::pipeline::PPOCRv2(fastdeploy::vision::ocr::DBDetector* det_model,
|
||||
fastdeploy::vision::ocr::Recognizer* rec_model);
|
||||
```
|
||||
PPOCRSystemv2 的初始化,由检测,识别模型串联构成(无分类器)
|
||||
PPOCRv2 的初始化,由检测,识别模型串联构成(无分类器)
|
||||
|
||||
**参数**
|
||||
|
||||
|
||||
@@ -37,12 +37,12 @@ void InitAndInfer(const std::string& det_model_dir, const std::string& cls_model
|
||||
assert(cls_model.Initialized());
|
||||
assert(rec_model.Initialized());
|
||||
|
||||
// The classification model is optional, so the OCR system can also be connected in series as follows
|
||||
// auto ocr_system_v2 = fastdeploy::application::ocrsystem::PPOCRSystemv2(&det_model, &rec_model);
|
||||
auto ocr_system_v2 = fastdeploy::application::ocrsystem::PPOCRSystemv2(&det_model, &cls_model, &rec_model);
|
||||
// The classification model is optional, so the PP-OCR can also be connected in series as follows
|
||||
// auto ppocr_v2 = fastdeploy::pipeline::PPOCRv2(&det_model, &rec_model);
|
||||
auto ppocr_v2 = fastdeploy::pipeline::PPOCRv2(&det_model, &cls_model, &rec_model);
|
||||
|
||||
if(!ocr_system_v2.Initialized()){
|
||||
std::cerr << "Failed to initialize OCR system." << std::endl;
|
||||
if(!ppocr_v2.Initialized()){
|
||||
std::cerr << "Failed to initialize PP-OCR." << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -50,14 +50,14 @@ void InitAndInfer(const std::string& det_model_dir, const std::string& cls_model
|
||||
auto im_bak = im.clone();
|
||||
|
||||
fastdeploy::vision::OCRResult result;
|
||||
if (!ocr_system_v2.Predict(&im, &result)) {
|
||||
if (!ppocr_v2.Predict(&im, &result)) {
|
||||
std::cerr << "Failed to predict." << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
std::cout << result.Str() << std::endl;
|
||||
|
||||
auto vis_im = fastdeploy::vision::Visualize::VisOcr(im_bak, result);
|
||||
auto vis_im = fastdeploy::vision::VisOcr(im_bak, result);
|
||||
cv::imwrite("vis_result.jpg", vis_im);
|
||||
std::cout << "Visualized result saved in ./vis_result.jpg" << std::endl;
|
||||
}
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
# PPOCRSystemv2 Python部署示例
|
||||
# PPOCRv2 Python部署示例
|
||||
|
||||
在部署前,需确认以下两个步骤
|
||||
|
||||
- 1. 软硬件环境满足要求,参考[FastDeploy环境要求](../../../../../docs/cn/build_and_install/download_prebuilt_libraries.md)
|
||||
- 2. FastDeploy Python whl包安装,参考[FastDeploy Python安装](../../../../../docs/cn/build_and_install/download_prebuilt_libraries.md)
|
||||
|
||||
本目录下提供`infer.py`快速完成PPOCRSystemv2在CPU/GPU,以及GPU上通过TensorRT加速部署的示例。执行如下脚本即可完成
|
||||
本目录下提供`infer.py`快速完成PPOCRv2在CPU/GPU,以及GPU上通过TensorRT加速部署的示例。执行如下脚本即可完成
|
||||
|
||||
```
|
||||
|
||||
# 下载模型,图片和字典文件
|
||||
wget https://bj.bcebos.com/paddlehub/fastdeploy/ch_PP-OCRv2_det_infer.tar.gz
|
||||
tar -xvf ch_PP-OCRv2_det_infer.tar.gz
|
||||
wget https://paddleocr.bj.bcebos.com/PP-OCRv2/chinese/ch_PP-OCRv2_det_infer.tar
|
||||
tar -xvf ch_PP-OCRv2_det_infer.tar
|
||||
|
||||
wget https://bj.bcebos.com/paddlehub/fastdeploy/ch_ppocr_mobile_v2.0_cls_infer.tar.gz
|
||||
tar -xvf ch_ppocr_mobile_v2.0_cls_infer.tar.gz
|
||||
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://bj.bcebos.com/paddlehub/fastdeploy/ch_PP-OCRv2_rec_infer.tar.gz
|
||||
tar -xvf ch_PP-OCRv2_rec_infer.tar.gz
|
||||
wgethttps://paddleocr.bj.bcebos.com/PP-OCRv2/chinese/ch_PP-OCRv2_rec_infer.tar
|
||||
tar -xvf ch_PP-OCRv2_rec_infer.tar
|
||||
|
||||
wget https://gitee.com/paddlepaddle/PaddleOCR/raw/release/2.6/doc/imgs/12.jpg
|
||||
|
||||
@@ -39,12 +39,12 @@ python infer.py --det_model ch_PP-OCRv2_det_infer --cls_model ch_ppocr_mobile_v2
|
||||
运行完成可视化结果如下图所示
|
||||
<img width="640" src="https://user-images.githubusercontent.com/109218879/185826024-f7593a0c-1bd2-4a60-b76c-15588484fa08.jpg">
|
||||
|
||||
## PPOCRSystemv2 Python接口
|
||||
## PPOCRv2 Python接口
|
||||
|
||||
```
|
||||
fd.vision.ocr.PPOCRSystemv2(det_model=det_model, cls_model=cls_model, rec_model=rec_model)
|
||||
fd.vision.ocr.PPOCRv2(det_model=det_model, cls_model=cls_model, rec_model=rec_model)
|
||||
```
|
||||
PPOCRSystemv2的初始化,输入的参数是检测模型,分类模型和识别模型,其中cls_model可选,如无需求,可设置为None
|
||||
PPOCRv2的初始化,输入的参数是检测模型,分类模型和识别模型,其中cls_model可选,如无需求,可设置为None
|
||||
|
||||
**参数**
|
||||
|
||||
@@ -55,7 +55,7 @@ PPOCRSystemv2的初始化,输入的参数是检测模型,分类模型和识别
|
||||
### predict函数
|
||||
|
||||
> ```
|
||||
> result = ocr_system.predict(im)
|
||||
> result = ppocr_v2.predict(im)
|
||||
> ```
|
||||
>
|
||||
> 模型预测接口,输入是一张图片
|
||||
|
||||
@@ -110,15 +110,15 @@ rec_model = fd.vision.ocr.Recognizer(
|
||||
rec_label_file,
|
||||
runtime_option=runtime_option)
|
||||
|
||||
# 创建OCR系统,串联3个模型,其中cls_model可选,如无需求,可设置为None
|
||||
ocr_system = fd.vision.ocr.PPOCRSystemv2(
|
||||
# 创建PP-OCR,串联3个模型,其中cls_model可选,如无需求,可设置为None
|
||||
ppocr_v2 = fd.vision.ocr.PPOCRv2(
|
||||
det_model=det_model, cls_model=cls_model, rec_model=rec_model)
|
||||
|
||||
# 预测图片准备
|
||||
im = cv2.imread(args.image)
|
||||
|
||||
#预测并打印结果
|
||||
result = ocr_system.predict(im)
|
||||
result = ppocr_v2.predict(im)
|
||||
|
||||
print(result)
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# PPOCRSystemv3 C++部署示例
|
||||
# PPOCRv3 C++部署示例
|
||||
|
||||
本目录下提供`infer.cc`快速完成PPOCRSystemv3在CPU/GPU,以及GPU上通过TensorRT加速部署的示例。
|
||||
本目录下提供`infer.cc`快速完成PPOCRv3在CPU/GPU,以及GPU上通过TensorRT加速部署的示例。
|
||||
|
||||
在部署前,需确认以下两个步骤
|
||||
|
||||
@@ -22,8 +22,8 @@ make -j
|
||||
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://bj.bcebos.com/paddlehub/fastdeploy/ch_ppocr_mobile_v2.0_cls_infer.tar.gz
|
||||
tar -xvf ch_ppocr_mobile_v2.0_cls_infer.tar.gz
|
||||
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
|
||||
@@ -48,17 +48,17 @@ wget https://gitee.com/paddlepaddle/PaddleOCR/raw/release/2.6/ppocr/utils/ppocr_
|
||||
<img width="640" src="https://user-images.githubusercontent.com/109218879/185826024-f7593a0c-1bd2-4a60-b76c-15588484fa08.jpg">
|
||||
|
||||
|
||||
## PPOCRSystemv3 C++接口
|
||||
## PPOCRv3 C++接口
|
||||
|
||||
### PPOCRSystemv3类
|
||||
### PPOCRv3类
|
||||
|
||||
```
|
||||
fastdeploy::application::ocrsystem::PPOCRSystemv3(fastdeploy::vision::ocr::DBDetector* det_model,
|
||||
fastdeploy::pipeline::PPOCRv3(fastdeploy::vision::ocr::DBDetector* det_model,
|
||||
fastdeploy::vision::ocr::Classifier* cls_model,
|
||||
fastdeploy::vision::ocr::Recognizer* rec_model);
|
||||
```
|
||||
|
||||
PPOCRSystemv3 的初始化,由检测,分类和识别模型串联构成
|
||||
PPOCRv3 的初始化,由检测,分类和识别模型串联构成
|
||||
|
||||
**参数**
|
||||
|
||||
@@ -67,10 +67,10 @@ PPOCRSystemv3 的初始化,由检测,分类和识别模型串联构成
|
||||
> * **Recognizer**(model): OCR中的识别模型
|
||||
|
||||
```
|
||||
fastdeploy::application::ocrsystem::PPOCRSystemv3(fastdeploy::vision::ocr::DBDetector* det_model,
|
||||
fastdeploy::pipeline::PPOCRv3(fastdeploy::vision::ocr::DBDetector* det_model,
|
||||
fastdeploy::vision::ocr::Recognizer* rec_model);
|
||||
```
|
||||
PPOCRSystemv3 的初始化,由检测,识别模型串联构成(无分类器)
|
||||
PPOCRv3 的初始化,由检测,识别模型串联构成(无分类器)
|
||||
|
||||
**参数**
|
||||
|
||||
|
||||
@@ -37,12 +37,12 @@ void InitAndInfer(const std::string& det_model_dir, const std::string& cls_model
|
||||
assert(cls_model.Initialized());
|
||||
assert(rec_model.Initialized());
|
||||
|
||||
// The classification model is optional, so the OCR system can also be connected in series as follows
|
||||
// auto ocr_system_v3 = fastdeploy::application::ocrsystem::PPOCRSystemv3(&det_model, &rec_model);
|
||||
auto ocr_system_v3 = fastdeploy::application::ocrsystem::PPOCRSystemv3(&det_model, &cls_model, &rec_model);
|
||||
// The classification model is optional, so the PP-OCR can also be connected in series as follows
|
||||
// auto ppocr_v3 = fastdeploy::pipeline::PPOCRv3(&det_model, &rec_model);
|
||||
auto ppocr_v3 = fastdeploy::pipeline::PPOCRv3(&det_model, &cls_model, &rec_model);
|
||||
|
||||
if(!ocr_system_v3.Initialized()){
|
||||
std::cerr << "Failed to initialize OCR system." << std::endl;
|
||||
if(!ppocr_v3.Initialized()){
|
||||
std::cerr << "Failed to initialize PP-OCR." << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -50,14 +50,14 @@ void InitAndInfer(const std::string& det_model_dir, const std::string& cls_model
|
||||
auto im_bak = im.clone();
|
||||
|
||||
fastdeploy::vision::OCRResult result;
|
||||
if (!ocr_system_v3.Predict(&im, &result)) {
|
||||
if (!ppocr_v3.Predict(&im, &result)) {
|
||||
std::cerr << "Failed to predict." << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
std::cout << result.Str() << std::endl;
|
||||
|
||||
auto vis_im = fastdeploy::vision::Visualize::VisOcr(im_bak, result);
|
||||
auto vis_im = fastdeploy::vision::VisOcr(im_bak, result);
|
||||
cv::imwrite("vis_result.jpg", vis_im);
|
||||
std::cout << "Visualized result saved in ./vis_result.jpg" << std::endl;
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
# PPOCRSystemv3 Python部署示例
|
||||
# PPOCRv3 Python部署示例
|
||||
|
||||
在部署前,需确认以下两个步骤
|
||||
|
||||
- 1. 软硬件环境满足要求,参考[FastDeploy环境要求](../../../../../docs/cn/build_and_install/download_prebuilt_libraries.md)
|
||||
- 2. FastDeploy Python whl包安装,参考[FastDeploy Python安装](../../../../../docs/cn/build_and_install/download_prebuilt_libraries.md)
|
||||
|
||||
本目录下提供`infer.py`快速完成PPOCRSystemv3在CPU/GPU,以及GPU上通过TensorRT加速部署的示例。执行如下脚本即可完成
|
||||
本目录下提供`infer.py`快速完成PPOCRv3在CPU/GPU,以及GPU上通过TensorRT加速部署的示例。执行如下脚本即可完成
|
||||
|
||||
```
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
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://bj.bcebos.com/paddlehub/fastdeploy/ch_ppocr_mobile_v2.0_cls_infer.tar.gz
|
||||
tar -xvf ch_ppocr_mobile_v2.0_cls_infer.tar.gz
|
||||
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
|
||||
@@ -38,12 +38,12 @@ python infer.py --det_model ch_PP-OCRv3_det_infer --cls_model ch_ppocr_mobile_v2
|
||||
运行完成可视化结果如下图所示
|
||||
<img width="640" src="https://user-images.githubusercontent.com/109218879/185826024-f7593a0c-1bd2-4a60-b76c-15588484fa08.jpg">
|
||||
|
||||
## PPOCRSystemv3 Python接口
|
||||
## PPOCRv3 Python接口
|
||||
|
||||
```
|
||||
fd.vision.ocr.PPOCRSystemv3(det_model=det_model, cls_model=cls_model, rec_model=rec_model)
|
||||
fd.vision.ocr.PPOCRv3(det_model=det_model, cls_model=cls_model, rec_model=rec_model)
|
||||
```
|
||||
PPOCRSystemv3的初始化,输入的参数是检测模型,分类模型和识别模型,其中cls_model可选,如无需求,可设置为None
|
||||
PPOCRv3的初始化,输入的参数是检测模型,分类模型和识别模型,其中cls_model可选,如无需求,可设置为None
|
||||
|
||||
**参数**
|
||||
|
||||
@@ -54,7 +54,7 @@ PPOCRSystemv3的初始化,输入的参数是检测模型,分类模型和识别
|
||||
### predict函数
|
||||
|
||||
> ```
|
||||
> result = ocr_system.predict(im)
|
||||
> result = ppocr_v3.predict(im)
|
||||
> ```
|
||||
>
|
||||
> 模型预测接口,输入是一张图片
|
||||
|
||||
@@ -110,15 +110,15 @@ rec_model = fd.vision.ocr.Recognizer(
|
||||
rec_label_file,
|
||||
runtime_option=runtime_option)
|
||||
|
||||
# 创建OCR系统,串联3个模型,其中cls_model可选,如无需求,可设置为None
|
||||
ocr_system = fd.vision.ocr.PPOCRSystemv3(
|
||||
# 创建PP-OCR,串联3个模型,其中cls_model可选,如无需求,可设置为None
|
||||
ppocr_v3 = fd.vision.ocr.PPOCRv3(
|
||||
det_model=det_model, cls_model=cls_model, rec_model=rec_model)
|
||||
|
||||
# 预测图片准备
|
||||
im = cv2.imread(args.image)
|
||||
|
||||
#预测并打印结果
|
||||
result = ocr_system.predict(im)
|
||||
result = ppocr_v3.predict(im)
|
||||
|
||||
print(result)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user