diff --git a/README.md b/README.md index 44885f554afdc7e00188fae2987e7fbbb4278fcc..13c4f964bb9063f28d6e08dfb8c6b828a81d2536 120000 --- a/README.md +++ b/README.md @@ -1 +1 @@ -README_ch.md \ No newline at end of file +README_en.md \ No newline at end of file diff --git a/README_en.md b/README_en.md index 462b20855e8fe21d8cd2800765848394c9811606..4bf960e57f2e56972f889c4bcf6a6d715b903477 100644 --- a/README_en.md +++ b/README_en.md @@ -21,7 +21,7 @@ PP-ShiTu demo images **Recent updates** -- 2022.6.15 Release [**P**ractical **U**ltra **L**ight-weight image **C**lassification solutions](./docs/en/PULC/PULC_quickstart_en.md). PULC models inference within 3ms on CPU devices, with accuracy comparable with SwinTransformer. We also release 9 practical models covering pedestrian, vehicle and OCR. +- 2022.6.15 Release [**P**ractical **U**ltra **L**ight-weight image **C**lassification solutions](./docs/en/PULC/PULC_quickstart_en.md). PULC models inference within 3ms on CPU devices, with accuracy on par with SwinTransformer. We also release 9 practical classification models covering pedestrian, vehicle and OCR scenario. - 2022.4.21 Added the related [code](https://github.com/PaddlePaddle/PaddleClas/pull/1820/files) of the CVPR2022 oral paper [MixFormer](https://arxiv.org/pdf/2204.02557.pdf). - 2021.09.17 Add PP-LCNet series model developed by PaddleClas, these models show strong competitiveness on Intel CPUs. @@ -58,19 +58,18 @@ Quick experience of **P**ractical **U**ltra **L**ight-weight image **C**lassific - [Install Paddle](./docs/en/installation/install_paddle_en.md) - [Install PaddleClas Environment](./docs/en/installation/install_paddleclas_en.md) -- [Practical Ultra Light-weight image Classification solutions](./docs/en/PULC/PULC_quickstart_en.md) +- [Practical Ultra Light-weight image Classification solutions](./docs/en/PULC/PULC_train_en.md) - [PULC Quick Start](docs/en/PULC/PULC_quickstart_en.md) - [PULC Model Zoo](docs/en/PULC/PULC_model_list_en.md) - [PULC Classification Model of Someone or Nobody](docs/en/PULC/PULC_person_exists_en.md) - [PULC Recognition Model of Person Attribute](docs/en/PULC/PULC_person_attribute_en.md) - [PULC Classification Model of Wearing or Unwearing Safety Helmet](docs/en/PULC/PULC_safety_helmet_en.md) - - [PULC Classification Model of Traffic Sing](docs/en/PULC/PULC_traffic_sign_en.md) + - [PULC Classification Model of Traffic Sign](docs/en/PULC/PULC_traffic_sign_en.md) - [PULC Recognition Model of Vehicle Attribute](docs/en/PULC/PULC_vehicle_attribute_en.md) - [PULC Classification Model of Containing or Uncontaining Car](docs/en/PULC/PULC_car_exists_en.md) - [PULC Classification Model of Text Image Orientation](docs/en/PULC/PULC_text_image_orientation_en.md) - [PULC Classification Model of Textline Orientation](docs/en/PULC/PULC_textline_orientation_en.md) - [PULC Classification Model of Language](docs/en/PULC/PULC_language_classification_en.md) -- [Quick Start of Recognition](./docs/en/tutorials/quick_start_recognition_en.md) - [Quick Start of Recognition](./docs/en/quick_start/quick_start_recognition_en.md) - [Introduction to Image Recognition Systems](#Introduction_to_Image_Recognition_Systems) - [Image Recognition Demo images](#Rec_Demo_images) diff --git a/deploy/paddle2onnx/readme.md b/deploy/paddle2onnx/readme.md index d1307ea84e3d7a1465c7c464d3b41dfa7613a046..bacc202806bf1a60e85790969edcb70f1489f7df 100644 --- a/deploy/paddle2onnx/readme.md +++ b/deploy/paddle2onnx/readme.md @@ -1,53 +1,59 @@ # paddle2onnx 模型转化与预测 -本章节介绍 ResNet50_vd 模型如何转化为 ONNX 模型,并基于 ONNX 引擎预测。 +## 目录 + +- [paddle2onnx 模型转化与预测](#paddle2onnx-模型转化与预测) + - [1. 环境准备](#1-环境准备) + - [2. 模型转换](#2-模型转换) + - [3. onnx 预测](#3-onnx-预测) ## 1. 环境准备 需要准备 Paddle2ONNX 模型转化环境,和 ONNX 模型预测环境。 -Paddle2ONNX 支持将 PaddlePaddle 模型格式转化到 ONNX 模型格式,算子目前稳定支持导出 ONNX Opset 9~11,部分Paddle算子支持更低的ONNX Opset转换。 -更多细节可参考 [Paddle2ONNX](https://github.com/PaddlePaddle/Paddle2ONNX/blob/develop/README_zh.md) +Paddle2ONNX 支持将 PaddlePaddle inference 模型格式转化到 ONNX 模型格式,算子目前稳定支持导出 ONNX Opset 9~11。 +更多细节可参考 [Paddle2ONNX](https://github.com/PaddlePaddle/Paddle2ONNX#paddle2onnx) - 安装 Paddle2ONNX -``` -python3.7 -m pip install paddle2onnx -``` + ```shell + python3.7 -m pip install paddle2onnx + ``` -- 安装 ONNX 运行时 -``` -python3.7 -m pip install onnxruntime -``` +- 安装 ONNX 推理引擎 + ```shell + python3.7 -m pip install onnxruntime + ``` +下面以 ResNet50_vd 为例,介绍如何将 PaddlePaddle inference 模型转换为 ONNX 模型,并基于 ONNX 引擎预测。 ## 2. 模型转换 - ResNet50_vd inference模型下载 -``` -cd deploy -mkdir models && cd models -wget -nc https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ResNet50_vd_infer.tar && tar xf ResNet50_vd_infer.tar -cd .. -``` + ```shell + cd deploy + mkdir models && cd models + wget -nc https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/ResNet50_vd_infer.tar && tar xf ResNet50_vd_infer.tar + cd .. + ``` - 模型转换 -使用 Paddle2ONNX 将 Paddle 静态图模型转换为 ONNX 模型格式: -``` -paddle2onnx --model_dir=./models/ResNet50_vd_infer/ \ ---model_filename=inference.pdmodel \ ---params_filename=inference.pdiparams \ ---save_file=./models/ResNet50_vd_infer/inference.onnx \ ---opset_version=10 \ ---enable_onnx_checker=True -``` + 使用 Paddle2ONNX 将 Paddle 静态图模型转换为 ONNX 模型格式: + ```shell + paddle2onnx --model_dir=./models/ResNet50_vd_infer/ \ + --model_filename=inference.pdmodel \ + --params_filename=inference.pdiparams \ + --save_file=./models/ResNet50_vd_infer/inference.onnx \ + --opset_version=10 \ + --enable_onnx_checker=True + ``` -执行完毕后,ONNX 模型 `inference.onnx` 会被保存在 `./models/ResNet50_vd_infer/` 路径下 +转换完毕后,生成的ONNX 模型 `inference.onnx` 会被保存在 `./models/ResNet50_vd_infer/` 路径下 ## 3. onnx 预测 执行如下命令: -``` +```shell python3.7 python/predict_cls.py \ -c configs/inference_cls.yaml \ -o Global.use_onnx=True \ diff --git a/deploy/slim/quant_post_static.py b/deploy/slim/quant_post_static.py index 5c8469794ad29e18dad15f985b611e423fd4b474..4e53b24119a1411be9ac93aecd3a48995d948346 100644 --- a/deploy/slim/quant_post_static.py +++ b/deploy/slim/quant_post_static.py @@ -41,8 +41,11 @@ def main(): 'inference.pdmodel')) and os.path.exists( os.path.join(config["Global"]["save_inference_dir"], 'inference.pdiparams')) + if "Query" in config["DataLoader"]["Eval"]: + config["DataLoader"]["Eval"] = config["DataLoader"]["Eval"]["Query"] config["DataLoader"]["Eval"]["sampler"]["batch_size"] = 1 config["DataLoader"]["Eval"]["loader"]["num_workers"] = 0 + init_logger() device = paddle.set_device("cpu") train_dataloader = build_dataloader(config["DataLoader"], "Eval", device, @@ -67,6 +70,7 @@ def main(): quantize_model_path=os.path.join( config["Global"]["save_inference_dir"], "quant_post_static_model"), sample_generator=sample_generator(train_dataloader), + batch_size=config["DataLoader"]["Eval"]["sampler"]["batch_size"], batch_nums=10) diff --git a/docs/en/PULC/PULC_car_exists_en.md b/docs/en/PULC/PULC_car_exists_en.md index 3ec2e9d147881a3e9874718478a5eb4fd5228552..33c0932e6f118d7f9e31650e7d1e9754af19ec17 100644 --- a/docs/en/PULC/PULC_car_exists_en.md +++ b/docs/en/PULC/PULC_car_exists_en.md @@ -38,18 +38,18 @@ ## 1. Introduction -This case provides a way for users to quickly build a lightweight, high-precision and practical classification model of car exists using PaddleClas PULC (Practical Ultra Lightweight Classification). The model can be widely used in monitoring scenarios, massive data filtering scenarios, etc. +This case provides a way for users to quickly build a lightweight, high-precision and practical classification model of car exists using PaddleClas PULC (Practical Ultra Lightweight image Classification). The model can be widely used in monitoring scenarios, massive data filtering scenarios, etc. The following table lists the relevant indicators of the model. The first two lines means that using SwinTransformer_tiny and MobileNetV3_small_x0_35 as the backbone to training. The third to sixth lines means that the backbone is replaced by PPLCNet, additional use of EDA strategy and additional use of EDA strategy and SKL-UGI knowledge distillation strategy. | Backbone | Tpr(%) | Latency(ms) | Size(M)| Training Strategy | |-------|----------------|----------|---------------|---------------| -| SwinTranformer_tiny | 97.71 | 95.30 | 107 | using ImageNet pretrained model | -| MobileNetV3_small_x0_35 | 81.23 | 2.85 | 1.6 | using ImageNet pretrained model | -| PPLCNet_x1_0 | 94.72 | 2.12 | 6.5 | using ImageNet pretrained model | -| PPLCNet_x1_0 | 95.48 | 2.12 | 6.5 | using SSLD pretrained model | -| PPLCNet_x1_0 | 95.48 | 2.12 | 6.5 | using SSLD pretrained model + EDA strategy | -| PPLCNet_x1_0 | 95.92 | 2.12 | 6.5 | using SSLD pretrained model + EDA strategy + SKL-UGI knowledge distillation strategy| +| SwinTranformer_tiny | 97.71 | 95.30 | 111 | using ImageNet pretrained model | +| MobileNetV3_small_x0_35 | 81.23 | 2.85 | 2.7 | using ImageNet pretrained model | +| PPLCNet_x1_0 | 94.72 | 2.12 | 7.1 | using ImageNet pretrained model | +| PPLCNet_x1_0 | 95.48 | 2.12 | 7.1 | using SSLD pretrained model | +| PPLCNet_x1_0 | 95.48 | 2.12 | 7.1 | using SSLD pretrained model + EDA strategy | +| PPLCNet_x1_0 | 95.92 | 2.12 | 7.1 | using SSLD pretrained model + EDA strategy + SKL-UGI knowledge distillation strategy| It can be seen that high Tpr can be getted when backbone is SwinTranformer_tiny, but the speed is slow. Replacing backbone with the lightweight model MobileNetV3_small_x0_35, the speed can be greatly improved, but the Tpr will be greatly reduced. Replacing backbone with faster backbone PPLCNet_x1_0, the Tpr is higher more 13 percentage points than MobileNetv3_small_x0_35. At the same time, the speed can be more than 20% faster. After additional using the SSLD pretrained model, the Tpr can be improved by about 0.7 percentage points without affecting the inference speed. Finally, after additional using the SKL-UGI knowledge distillation, the Tpr can be further improved by 0.44 percentage points. At this point, the Tpr is close to that of SwinTranformer_tiny, but the speed is more than 40 times faster. The training method and deployment instructions of PULC will be introduced in detail below. diff --git a/docs/en/PULC/PULC_language_classification_en.md b/docs/en/PULC/PULC_language_classification_en.md index 48362b316179686bf85e2e54f21339970dac8a43..c7cd5f5db9c01f01c4fbb2299086bc1adcfc98d1 100644 --- a/docs/en/PULC/PULC_language_classification_en.md +++ b/docs/en/PULC/PULC_language_classification_en.md @@ -38,18 +38,18 @@ ## 1. Introduction -This case provides a way for users to quickly build a lightweight, high-precision and practical classification model of language in the image using PaddleClas PULC (Practical Ultra Lightweight Classification). The model can be widely used in various scenarios involving multilingual OCR processing, such as finance and government affairs. +This case provides a way for users to quickly build a lightweight, high-precision and practical classification model of language in the image using PaddleClas PULC (Practical Ultra Lightweight image Classification). The model can be widely used in various scenarios involving multilingual OCR processing, such as finance and government affairs. The following table lists the relevant indicators of the model. The first two lines means that using SwinTransformer_tiny and MobileNetV3_small_x0_35 as the backbone to training. The third to sixth lines means that the backbone is replaced by PPLCNet, additional use of EDA strategy and additional use of EDA strategy and SKL-UGI knowledge distillation strategy. When replacing the backbone with PPLCNet_x1_0, the input shape of model is changed to [192, 48], and the stride of the network is changed to [2, [2, 1], [2, 1], [2, 1]]. | Backbone | Top1-Acc(%) | Latency(ms) | Size(M)| Training Strategy | | ----------------------- | --------- | -------- | ------- | ---------------------------------------------- | -| SwinTranformer_tiny | 98.12 | 89.09 | 107 | using ImageNet pretrained model | -| MobileNetV3_small_x0_35 | 95.92 | 2.98 | 17 | using ImageNet pretrained model | -| PPLCNet_x1_0 | 98.35 | 2.58 | 6.5 | using ImageNet pretrained model | -| PPLCNet_x1_0 | 98.7 | 2.58 | 6.5 | using SSLD pretrained model | -| PPLCNet_x1_0 | 99.12 | 2.58 | 6.5 | using SSLD pretrained model + EDA strategy | -| **PPLCNet_x1_0** | **99.26** | **2.58** | **6.5** | using SSLD pretrained model + EDA strategy + SKL-UGI knowledge distillation strategy| +| SwinTranformer_tiny | 98.12 | 89.09 | 111 | using ImageNet pretrained model | +| MobileNetV3_small_x0_35 | 95.92 | 2.98 | 3.7 | using ImageNet pretrained model | +| PPLCNet_x1_0 | 98.35 | 2.58 | 7.1 | using ImageNet pretrained model | +| PPLCNet_x1_0 | 98.7 | 2.58 | 7.1 | using SSLD pretrained model | +| PPLCNet_x1_0 | 99.12 | 2.58 | 7.1 | using SSLD pretrained model + EDA strategy | +| **PPLCNet_x1_0** | **99.26** | **2.58** | **7.1** | using SSLD pretrained model + EDA strategy + SKL-UGI knowledge distillation strategy| It can be seen that high accuracy can be getted when backbone is SwinTranformer_tiny, but the speed is slow. Replacing backbone with the lightweight model MobileNetV3_small_x0_35, the speed can be greatly improved, but the accuracy will be greatly reduced. Replacing backbone with faster backbone PPLCNet_x1_0 and changing the input shape and stride of network, the accuracy is higher more 2.43 percentage points than MobileNetv3_small_x0_35. At the same time, the speed can be more than 20% faster. After additional using the SSLD pretrained model, the accuracy can be improved by about 0.35 percentage points without affecting the inference speed. Further, additional using the EDA strategy, the accuracy can be increased by 0.42 percentage points. Finally, after additional using the SKL-UGI knowledge distillation, the accuracy can be further improved by 0.14 percentage points. At this point, the accuracy is higher than that of SwinTranformer_tiny, but the speed is more faster. The training method and deployment instructions of PULC will be introduced in detail below. diff --git a/docs/en/PULC/PULC_model_list_en.md b/docs/en/PULC/PULC_model_list_en.md index 6b287b523ba28dcd329e82e37556e7502733a584..a7de0ce2c996132e6c882a10f5fcecd22398cc22 100644 --- a/docs/en/PULC/PULC_model_list_en.md +++ b/docs/en/PULC/PULC_model_list_en.md @@ -7,15 +7,15 @@ The PULC model zoo is provided here, mainly providing indicators, model storage |Model name| Model Description | Metrics |Storage Size| Latency| Download Address| | --- | --- | --- | --- | --- | --- | -| person_exists |[Human Exists Classification](PULC_person_exists_en.md)| 95.60 |6.5M|2.58ms|[inference model](https://paddleclas.bj.bcebos.com/models/PULC/inference/person_exists_infer.tar) / [pretrained model](https://paddleclas.bj.bcebos.com/models/PULC/pretrained/person_exists_pretrained.pdparams)| -| person_attribute |[Pedestrian Attribute Classification](PULC_person_attribute_en.md)| 78.59 |6.6M|2.01ms|[inference model](https://paddleclas.bj.bcebos.com/models/PULC/inference/person_attribute_infer.tar) / [pretrained model](https://paddleclas.bj.bcebos.com/models/PULC/pretrained/person_attribute_pretrained.pdparams)| -| safety_helmet |[Classification of Wheather Wearing Safety Helmet](PULC_safety_helmet_en.md)| 99.38 |6.5M|2.03ms|[inference model](https://paddleclas.bj.bcebos.com/models/PULC/inference/safety_helmet_infer.tar) / [pretrained model](https://paddleclas.bj.bcebos.com/models/PULC/pretrained/safety_helmet_pretrained.pdparams)| +| person_exists |[Human Exists Classification](PULC_person_exists_en.md)| 96.23 |7.0M|2.58ms|[inference model](https://paddleclas.bj.bcebos.com/models/PULC/inference/person_exists_infer.tar) / [pretrained model](https://paddleclas.bj.bcebos.com/models/PULC/pretrained/person_exists_pretrained.pdparams)| +| person_attribute |[Pedestrian Attribute Classification](PULC_person_attribute_en.md)| 78.59 |7.2M|2.01ms|[inference model](https://paddleclas.bj.bcebos.com/models/PULC/inference/person_attribute_infer.tar) / [pretrained model](https://paddleclas.bj.bcebos.com/models/PULC/pretrained/person_attribute_pretrained.pdparams)| +| safety_helmet |[Classification of Wheather Wearing Safety Helmet](PULC_safety_helmet_en.md)| 99.38 |7.1M|2.03ms|[inference model](https://paddleclas.bj.bcebos.com/models/PULC/inference/safety_helmet_infer.tar) / [pretrained model](https://paddleclas.bj.bcebos.com/models/PULC/pretrained/safety_helmet_pretrained.pdparams)| | traffic_sign |[Traffic Sign Classification](PULC_traffic_sign_en.md)| 98.35 |8.2M|2.10ms|[inference model](https://paddleclas.bj.bcebos.com/models/PULC/inference/traffic_sign_infer.tar) / [pretrained model](https://paddleclas.bj.bcebos.com/models/PULC/pretrained/traffic_sign_pretrained.pdparams)| | vehicle_attribute |[Vehicle Attribute Classification](PULC_vehicle_attribute_en.md)| 90.81 |7.2M|2.36ms|[inference model](https://paddleclas.bj.bcebos.com/models/PULC/inference/vehicle_attribute_infer.tar) / [pretrained model](https://paddleclas.bj.bcebos.com/models/PULC/pretrained/vehicle_attribute_pretrained.pdparams)| -| car_exists |[Car Exists Classification](PULC_car_exists_en.md) | 95.92 | 6.6M | 2.38ms |[inference model](https://paddleclas.bj.bcebos.com/models/PULC/inference/car_exists_infer.tar) / [pretrained model](https://paddleclas.bj.bcebos.com/models/PULC/pretrained/car_exists_pretrained.pdparams)| -| text_image_orientation |[Text Image Orientation Classification](PULC_text_image_orientation_en.md)| 99.06 | 6.5M | 2.16ms |[inference model](https://paddleclas.bj.bcebos.com/models/PULC/inference/text_image_orientation_infer.tar) / [pretrained model](https://paddleclas.bj.bcebos.com/models/PULC/pretrained/text_image_orientation_pretrained.pdparams)| -| textline_orientation |[Text-line Orientation Classification](PULC_textline_orientation_en.md)| 96.01 |6.5M|2.72ms|[inference model](https://paddleclas.bj.bcebos.com/models/PULC/inference/textline_orientation_infer.tar) / [pretrained model](https://paddleclas.bj.bcebos.com/models/PULC/pretrained/textline_orientation_pretrained.pdparams)| -| language_classification |[Language Classification](PULC_language_classification_en.md)| 99.26 |6.5M|2.58ms|[inference model](https://paddleclas.bj.bcebos.com/models/PULC/inference/language_classification_infer.tar) / [pretrained model](https://paddleclas.bj.bcebos.com/models/PULC/pretrained/language_classification_pretrained.pdparams)| +| car_exists |[Car Exists Classification](PULC_car_exists_en.md) | 95.92 | 7.1M | 2.38ms |[inference model](https://paddleclas.bj.bcebos.com/models/PULC/inference/car_exists_infer.tar) / [pretrained model](https://paddleclas.bj.bcebos.com/models/PULC/pretrained/car_exists_pretrained.pdparams)| +| text_image_orientation |[Text Image Orientation Classification](PULC_text_image_orientation_en.md)| 99.06 | 7.1M | 2.16ms |[inference model](https://paddleclas.bj.bcebos.com/models/PULC/inference/text_image_orientation_infer.tar) / [pretrained model](https://paddleclas.bj.bcebos.com/models/PULC/pretrained/text_image_orientation_pretrained.pdparams)| +| textline_orientation |[Text-line Orientation Classification](PULC_textline_orientation_en.md)| 96.01 |7.0M|2.72ms|[inference model](https://paddleclas.bj.bcebos.com/models/PULC/inference/textline_orientation_infer.tar) / [pretrained model](https://paddleclas.bj.bcebos.com/models/PULC/pretrained/textline_orientation_pretrained.pdparams)| +| language_classification |[Language Classification](PULC_language_classification_en.md)| 99.26 |7.1M|2.58ms|[inference model](https://paddleclas.bj.bcebos.com/models/PULC/inference/language_classification_infer.tar) / [pretrained model](https://paddleclas.bj.bcebos.com/models/PULC/pretrained/language_classification_pretrained.pdparams)| **Note:** diff --git a/docs/en/PULC/PULC_person_attribute_en.md b/docs/en/PULC/PULC_person_attribute_en.md index d79da893bf2ad4f045f7d9a078613932430445ce..173313aad1a684289f3a6825cdf73ea01493847d 100644 --- a/docs/en/PULC/PULC_person_attribute_en.md +++ b/docs/en/PULC/PULC_person_attribute_en.md @@ -38,21 +38,21 @@ ## 1. Introduction -This case provides a way for users to quickly build a lightweight, high-precision and practical classification model of person attribute using PaddleClas PULC (Practical Ultra Lightweight image Classification). The model can be widely used in +This case provides a way for users to quickly build a lightweight, high-precision and practical classification model of person attribute using PaddleClas PULC (Practical Ultra Lightweight image Classification). The model can be widely used in Pedestrian analysis scenarios, pedestrian tracking scenarios, etc. The following table lists the relevant indicators of the model. The first three lines means that using Res2Net200_vd_26w_4s, SwinTransformer_tiny and MobileNetV3_small_x0_35 as the backbone to training. The fourth to seventh lines means that the backbone is replaced by PPLCNet, additional use of EDA strategy and additional use of EDA strategy and SKL-UGI knowledge distillation strategy. - - + + | Backbone | ma(%) | Latency(ms) | Size(M) | Training Strategy | |-------|-----------|----------|---------------|---------------| | Res2Net200_vd_26w_4s | 81.25 | 77.51 | 293 | using ImageNet pretrained | -| SwinTransformer_tiny | 80.17 | 89.51 | 107 | using ImageNet pretrained | +| SwinTransformer_tiny | 80.17 | 89.51 | 111 | using ImageNet pretrained | | MobileNetV3_small_x0_35 | 70.79 | 2.90 | 1.7 | using ImageNet pretrained | -| PPLCNet_x1_0 | 76.31 | 2.01 | 6.6 | using ImageNet pretrained | -| PPLCNet_x1_0 | 77.31 | 2.01 | 6.6 | using SSLD pretrained | -| PPLCNet_x1_0 | 77.71 | 2.01 | 6.6 | using SSLD pretrained + EDA strategy| -| PPLCNet_x1_0 | 78.59 | 2.01 | 6.6 | using SSLD pretrained + EDA strategy + SKL-UGI knowledge distillation strategy| +| PPLCNet_x1_0 | 76.31 | 2.01 | 7.1 | using ImageNet pretrained | +| PPLCNet_x1_0 | 77.31 | 2.01 | 7.1 | using SSLD pretrained | +| PPLCNet_x1_0 | 77.71 | 2.01 | 7.1 | using SSLD pretrained + EDA strategy| +| PPLCNet_x1_0 | 78.59 | 2.01 | 7.1 | using SSLD pretrained + EDA strategy + SKL-UGI knowledge distillation strategy| It can be seen that high ma metric can be getted when backbone are Res2Net200_vd_26w_4s and SwinTranformer_tiny, but the speed is slow. Replacing backbone with the lightweight model MobileNetV3_small_x0_35, the speed can be greatly improved, but the ma metric will be greatly reduced. Replacing backbone with faster backbone PPLCNet_x1_0, the ma metric is higher more 5.5 percentage points higher than MobileNetv3_small_x0_35. At the same time, the speed can be more than 20% faster. After additional using the SSLD pretrained model, the ma metric can be improved by about 1 percentage points without affecting the inference speed. Further, additional using the EDA strategy, the ma metric can be increased by 0.4 percentage points. Finally, after additional using the SKL-UGI knowledge distillation, the ma matric can be further improved by 0.88 percentage points. At this time, the ma metric of PPLCNet_x1_0 is only 1.58% different from SwinTransformer_tiny, but the speed is more than 44 times faster. The training method and deployment instructions of PULC will be introduced in detail below. diff --git a/docs/en/PULC/PULC_person_exists_en.md b/docs/en/PULC/PULC_person_exists_en.md index 21829e5544d8bdfdf2ecc01616f8b8912a48a08d..baf5ce3e4c295a57d928853f5a0b3da1d3c7b366 100644 --- a/docs/en/PULC/PULC_person_exists_en.md +++ b/docs/en/PULC/PULC_person_exists_en.md @@ -38,20 +38,20 @@ ## 1. Introduction -This case provides a way for users to quickly build a lightweight, high-precision and practical classification model of human exists using PaddleClas PULC (Practical Ultra Lightweight Classification). The model can be widely used in monitoring scenarios, personnel access control scenarios, massive data filtering scenarios, etc. +This case provides a way for users to quickly build a lightweight, high-precision and practical classification model of human exists using PaddleClas PULC (Practical Ultra Lightweight image Classification). The model can be widely used in monitoring scenarios, personnel access control scenarios, massive data filtering scenarios, etc. The following table lists the relevant indicators of the model. The first two lines means that using SwinTransformer_tiny and MobileNetV3_small_x0_35 as the backbone to training. The third to sixth lines means that the backbone is replaced by PPLCNet, additional use of EDA strategy and additional use of EDA strategy and SKL-UGI knowledge distillation strategy. | Backbone | Tpr(%) | Latency(ms) | Size(M)| Training Strategy | |-------|-----------|----------|---------------|---------------| -| SwinTranformer_tiny | 95.69 | 95.30 | 107 | using ImageNet pretrained model | -| MobileNetV3_small_x0_35 | 68.25 | 2.85 | 1.6 | using ImageNet pretrained model | -| PPLCNet_x1_0 | 89.57 | 2.12 | 6.5 | using ImageNet pretrained model | -| PPLCNet_x1_0 | 92.10 | 2.12 | 6.5 | using SSLD pretrained model | -| PPLCNet_x1_0 | 93.43 | 2.12 | 6.5 | using SSLD pretrained model + EDA strategy | -| PPLCNet_x1_0 | 95.60 | 2.12 | 6.5 | using SSLD pretrained model + EDA strategy + SKL-UGI knowledge distillation strategy| - -It can be seen that high Tpr can be getted when backbone is SwinTranformer_tiny, but the speed is slow. Replacing backbone with the lightweight model MobileNetV3_small_x0_35, the speed can be greatly improved, but the Tpr will be greatly reduced. Replacing backbone with faster backbone PPLCNet_x1_0, the Tpr is higher more 20 percentage points than MobileNetv3_small_x0_35. At the same time, the speed can be more than 20% faster. After additional using the SSLD pretrained model, the Tpr can be improved by about 2.6 percentage points without affecting the inference speed. Further, additional using the EDA strategy, the Tpr can be increased by 1.3 percentage points. Finally, after additional using the SKL-UGI knowledge distillation, the Tpr can be further improved by 2.2 percentage points. At this point, the Tpr is close to that of SwinTranformer_tiny, but the speed is more than 40 times faster. The training method and deployment instructions of PULC will be introduced in detail below. +| SwinTranformer_tiny | 95.69 | 95.30 | 111 | using ImageNet pretrained model | +| MobileNetV3_small_x0_35 | 68.25 | 2.85 | 2.6 | using ImageNet pretrained model | +| PPLCNet_x1_0 | 89.57 | 2.12 | 7.0 | using ImageNet pretrained model | +| PPLCNet_x1_0 | 92.10 | 2.12 | 7.0 | using SSLD pretrained model | +| PPLCNet_x1_0 | 93.43 | 2.12 | 7.0 | using SSLD pretrained model + EDA strategy | +| PPLCNet_x1_0 | 96.23 | 2.12 | 7.0 | using SSLD pretrained model + EDA strategy + SKL-UGI knowledge distillation strategy| + +It can be seen that high Tpr can be getted when backbone is SwinTranformer_tiny, but the speed is slow. Replacing backbone with the lightweight model MobileNetV3_small_x0_35, the speed can be greatly improved, but the Tpr will be greatly reduced. Replacing backbone with faster backbone PPLCNet_x1_0, the Tpr is higher more 20 percentage points than MobileNetv3_small_x0_35. At the same time, the speed can be more than 20% faster. After additional using the SSLD pretrained model, the Tpr can be improved by about 2.6 percentage points without affecting the inference speed. Further, additional using the EDA strategy, the Tpr can be increased by 1.3 percentage points. Finally, after additional using the SKL-UGI knowledge distillation, the Tpr can be further improved by 2.8 percentage points. At this point, the Tpr is close to that of SwinTranformer_tiny, but the speed is more than 40 times faster. The training method and deployment instructions of PULC will be introduced in detail below. **Note**: diff --git a/docs/en/PULC/PULC_safety_helmet_en.md b/docs/en/PULC/PULC_safety_helmet_en.md index 91f8b76f68c8788dff1787b68fd72b14de33ccc6..d2e5cb32931cdc98b0776f4692e6162e907aa6fa 100644 --- a/docs/en/PULC/PULC_safety_helmet_en.md +++ b/docs/en/PULC/PULC_safety_helmet_en.md @@ -38,19 +38,19 @@ ## 1. Introduction -This case provides a way for users to quickly build a lightweight, high-precision and practical classification model of wheather wearing safety helmet using PaddleClas PULC (Practical Ultra Lightweight Classification). The model can be widely used in construction scenes, factory workshop scenes, traffic scenes and so on. +This case provides a way for users to quickly build a lightweight, high-precision and practical classification model of wheather wearing safety helmet using PaddleClas PULC (Practical Ultra Lightweight image Classification). The model can be widely used in construction scenes, factory workshop scenes, traffic scenes and so on. -The following table lists the relevant indicators of the model. The first two lines means that using SwinTransformer_tiny and MobileNetV3_small_x0_35 as the backbone to training. The third to seventh lines means that the backbone is replaced by PPLCNet, additional use of EDA strategy and additional use of EDA strategy and SKL-UGI knowledge distillation strategy. +The following table lists the relevant indicators of the model. The first three lines means that using SwinTransformer_tiny, Res2Net200_vd_26w_4s and MobileNetV3_small_x0_35 as the backbone to training. The fourth to seventh lines means that the backbone is replaced by PPLCNet, additional use of EDA strategy and additional use of EDA strategy and SKL-UGI knowledge distillation strategy. | Backbone | Tpr(%) | Latency(ms) | Size(M)| Training Strategy | |-------|-----------|----------|---------------|---------------| -| SwinTranformer_tiny | 93.57 | 91.32 | 107 | using ImageNet pretrained model | +| SwinTranformer_tiny | 93.57 | 91.32 | 111 | using ImageNet pretrained model | | Res2Net200_vd_26w_4s | 98.92 | 80.99 | 284 | using ImageNet pretrained model | -| MobileNetV3_small_x0_35 | 84.83 | 2.85 | 1.6 | using ImageNet pretrained model | -| PPLCNet_x1_0 | 93.27 | 2.03 | 6.5 | using ImageNet pretrained model | -| PPLCNet_x1_0 | 98.16 | 2.03 | 6.5 | using SSLD pretrained model | -| PPLCNet_x1_0 | 99.30 | 2.03 | 6.5 | using SSLD pretrained model + EDA strategy | -| PPLCNet_x1_0 | 99.38 | 2.03 | 6.5 | using SSLD pretrained model + EDA strategy + SKL-UGI knowledge distillation strategy| +| MobileNetV3_small_x0_35 | 84.83 | 2.85 | 2.6 | using ImageNet pretrained model | +| PPLCNet_x1_0 | 93.27 | 2.03 | 7.1 | using ImageNet pretrained model | +| PPLCNet_x1_0 | 98.16 | 2.03 | 7.1 | using SSLD pretrained model | +| PPLCNet_x1_0 | 99.30 | 2.03 | 7.1 | using SSLD pretrained model + EDA strategy | +| PPLCNet_x1_0 | 99.38 | 2.03 | 7.1 | using SSLD pretrained model + EDA strategy + SKL-UGI knowledge distillation strategy| It can be seen that high Tpr can be getted when backbone is Res2Net200_vd_26w_4s, but the speed is slow. Replacing backbone with the lightweight model MobileNetV3_small_x0_35, the speed can be greatly improved, but the Tpr will be greatly reduced. Replacing backbone with faster backbone PPLCNet_x1_0, the Tpr is higher more 8.5 percentage points than MobileNetv3_small_x0_35. At the same time, the speed can be more than 20% faster. After additional using the SSLD pretrained model, the Tpr can be improved by about 4.9 percentage points without affecting the inference speed. Further, additional using the EDA strategy, the Tpr can be increased by 1.1 percentage points. Finally, after additional using the UDML knowledge distillation, the Tpr can be further improved by 2.2 percentage points. At this point, the Tpr is higher than that of Res2Net200_vd_26w_4s, but the speed is more than 70 times faster. The training method and deployment instructions of PULC will be introduced in detail below. diff --git a/docs/en/PULC/PULC_text_image_orientation_en.md b/docs/en/PULC/PULC_text_image_orientation_en.md index 2cddf79fa785e8afab93626cd5a502545e55a8ba..1d3cc41f992adff90f396463205cd060147023c1 100644 --- a/docs/en/PULC/PULC_text_image_orientation_en.md +++ b/docs/en/PULC/PULC_text_image_orientation_en.md @@ -36,17 +36,17 @@ ## 1. Introduction -In the process of document scanning, license shooting and so on, sometimes in order to shoot more clearly, the camera device will be rotated, resulting in photo in different directions. At this time, the standard OCR process cannot cope with these issues well. Using the text image orientation classification technology, the direction of the text image can be predicted and adjusted, so as to improve the accuracy of OCR processing. This case provides a way for users to use PaddleClas PULC (Practical Ultra Lightweight Classification) to quickly build a lightweight, high-precision, practical classification model of text image orientation. This model can be widely used in OCR processing scenarios of rotating pictures in financial, government and other industries. +In the process of document scanning, license shooting and so on, sometimes in order to shoot more clearly, the camera device will be rotated, resulting in photo in different directions. At this time, the standard OCR process cannot cope with these issues well. Using the text image orientation classification technology, the direction of the text image can be predicted and adjusted, so as to improve the accuracy of OCR processing. This case provides a way for users to use PaddleClas PULC (Practical Ultra Lightweight image Classification) to quickly build a lightweight, high-precision, practical classification model of text image orientation. This model can be widely used in OCR processing scenarios of rotating pictures in financial, government and other industries. The following table lists the relevant indicators of the model. The first two lines means that using SwinTransformer_tiny and MobileNetV3_small_x0_35 as the backbone to training. The third to fifth lines means that the backbone is replaced by PPLCNet, additional use of SSLD pretrained model and additional use of hyperparameters searching strategy. | Backbone | Top1-Acc(%) | Latency(ms) | Size(M)| Training Strategy | | ----------------------- | --------- | ---------- | --------- | ------------------------------------- | -| SwinTranformer_tiny | 99.12 | 89.65 | 107 | using ImageNet pretrained model | -| MobileNetV3_small_x0_35 | 83.61 | 2.95 | 17 | using ImageNet pretrained model | -| PPLCNet_x1_0 | 97.85 | 2.16 | 6.5 | using ImageNet pretrained model | -| PPLCNet_x1_0 | 98.02 | 2.16 | 6.5 | using SSLD pretrained model | -| **PPLCNet_x1_0** | **99.06** | **2.16** | **6.5** | using SSLD pretrained model + hyperparameters searching strategy | +| SwinTranformer_tiny | 99.12 | 89.65 | 111 | using ImageNet pretrained model | +| MobileNetV3_small_x0_35 | 83.61 | 2.95 | 2.6 | using ImageNet pretrained model | +| PPLCNet_x1_0 | 97.85 | 2.16 | 7.1 | using ImageNet pretrained model | +| PPLCNet_x1_0 | 98.02 | 2.16 | 7.1 | using SSLD pretrained model | +| **PPLCNet_x1_0** | **99.06** | **2.16** | **7.1** | using SSLD pretrained model + hyperparameters searching strategy | It can be seen that high accuracy can be getted when backbone is SwinTranformer_tiny, but the speed is slow. Replacing backbone with the lightweight model MobileNetV3_small_x0_35, the speed can be greatly improved, but the accuracy will be greatly reduced. Replacing backbone with faster backbone PPLCNet_x1_0, the accuracy is higher more 14 percentage points than MobileNetv3_small_x0_35. At the same time, the speed can be more faster. After additional using the SSLD pretrained model, the accuracy can be improved by about 0.17 percentage points without affecting the inference speed. Finally, after additional using the hyperparameters searching strategy, the accuracy can be further improved by 1.04 percentage points. At this point, the accuracy is close to that of SwinTranformer_tiny, but the speed is more faster. The training method and deployment instructions of PULC will be introduced in detail below. diff --git a/docs/en/PULC/PULC_textline_orientation_en.md b/docs/en/PULC/PULC_textline_orientation_en.md index 71ea3407b952296bf7b6dad5768fd8f38ee6d563..d11307d0b5aafe056c1f1e53a85882d2449ac277 100644 --- a/docs/en/PULC/PULC_textline_orientation_en.md +++ b/docs/en/PULC/PULC_textline_orientation_en.md @@ -38,19 +38,19 @@ ## 1. Introduction -This case provides a way for users to quickly build a lightweight, high-precision and practical classification model of textline orientation using PaddleClas PULC (Practical Ultra Lightweight Classification). The model can be widely used in character correction, character recognition, etc. +This case provides a way for users to quickly build a lightweight, high-precision and practical classification model of textline orientation using PaddleClas PULC (Practical Ultra Lightweight image Classification). The model can be widely used in character correction, character recognition, etc. The following table lists the relevant indicators of the model. The first two lines means that using SwinTransformer_tiny and MobileNetV3_small_x0_35 as the backbone to training. The third to seventh lines means that the backbone is replaced by PPLCNet, additional use of EDA strategy and additional use of EDA strategy and SKL-UGI knowledge distillation strategy. | Backbone | Top-1 Acc(%) | Latency(ms) | Size(M)| Training Strategy | |-------|-----------|----------|---------------|---------------| -| SwinTranformer_tiny | 93.61 | 89.64 | 107 | using ImageNet pretrained model | -| MobileNetV3_small_x0_35 | 81.40 | 2.96 | 17 | using ImageNet pretrained model | -| PPLCNet_x1_0 | 89.99 | 2.11 | 6.5 | using ImageNet pretrained model | -| PPLCNet_x1_0* | 94.06 | 2.68 | 6.5 | using ImageNet pretrained model | -| PPLCNet_x1_0* | 94.11 | 2.68 | 6.5 | using SSLD pretrained model | -| PPLCNet_x1_0** | 96.01 | 2.72 | 6.5 | using SSLD pretrained model + EDA strategy | -| PPLCNet_x1_0** | 95.86 | 2.72 | 6.5 | using SSLD pretrained model + EDA strategy + SKL-UGI knowledge distillation strategy| +| SwinTranformer_tiny | 93.61 | 89.64 | 111 | using ImageNet pretrained model | +| MobileNetV3_small_x0_35 | 81.40 | 2.96 | 2.6 | using ImageNet pretrained model | +| PPLCNet_x1_0 | 89.99 | 2.11 | 7.0 | using ImageNet pretrained model | +| PPLCNet_x1_0* | 94.06 | 2.68 | 7.0 | using ImageNet pretrained model | +| PPLCNet_x1_0* | 94.11 | 2.68 | 7.0 | using SSLD pretrained model | +| PPLCNet_x1_0** | 96.01 | 2.72 | 7.0 | using SSLD pretrained model + EDA strategy | +| PPLCNet_x1_0** | 95.86 | 2.72 | 7.0 | using SSLD pretrained model + EDA strategy + SKL-UGI knowledge distillation strategy| It can be seen that high accuracy can be getted when backbone is SwinTranformer_tiny, but the speed is slow. Replacing backbone with the lightweight model MobileNetV3_small_x0_35, the speed can be greatly improved, but the accuracy will be greatly reduced. Replacing backbone with faster backbone PPLCNet_x1_0, the accuracy is higher more 8.6 percentage points than MobileNetv3_small_x0_35. At the same time, the speed can be more than 10% faster. On this basis, by changing the resolution and stripe (refer to [PaddleOCR](https://github.com/PaddlePaddle/PaddleOCR)), the speed becomes 27% slower, but the accuracy can be improved by 4.5 percentage points. After additional using the SSLD pretrained model, the accuracy can be improved by about 0.05 percentage points without affecting the inference speed. Finally, additional using the EDA strategy, the accuracy can be increased by 1.9 percentage points. The training method and deployment instructions of PULC will be introduced in detail below. diff --git a/docs/en/PULC/PULC_traffic_sign_en.md b/docs/en/PULC/PULC_traffic_sign_en.md index 21abd45438b906755662497c2527c88b3009c326..baa0faf4828a6c7acc16f8c12587a2af58c04f99 100644 --- a/docs/en/PULC/PULC_traffic_sign_en.md +++ b/docs/en/PULC/PULC_traffic_sign_en.md @@ -38,7 +38,7 @@ ## 1. Introduction -This case provides a way for users to quickly build a lightweight, high-precision and practical classification model of traffic sign using PaddleClas PULC (Practical Ultra Lightweight Classification). The model can be widely used in automatic driving, road monitoring, etc. +This case provides a way for users to quickly build a lightweight, high-precision and practical classification model of traffic sign using PaddleClas PULC (Practical Ultra Lightweight image Classification). The model can be widely used in automatic driving, road monitoring, etc. The following table lists the relevant indicators of the model. The first two lines means that using SwinTransformer_tiny and MobileNetV3_small_x0_35 as the backbone to training. The third to sixth lines means that the backbone is replaced by PPLCNet, additional use of EDA strategy and additional use of EDA strategy and SKL-UGI knowledge distillation strategy. diff --git a/docs/en/PULC/PULC_vehicle_attribute_en.md b/docs/en/PULC/PULC_vehicle_attribute_en.md index 822e966ee06258adc5a824657bee89a824088d8d..47d7c963e9de6e4bde9fd3338830611e59b60695 100644 --- a/docs/en/PULC/PULC_vehicle_attribute_en.md +++ b/docs/en/PULC/PULC_vehicle_attribute_en.md @@ -38,13 +38,12 @@ ## 1. Introduction -This case provides a way for users to quickly build a lightweight, high-precision and practical classification model of vehicle attribute using PaddleClas PULC (Practical Ultra Lightweight image Classification). The model can be widely used in -Vehicle identification, road monitoring and other scenarios. +This case provides a way for users to quickly build a lightweight, high-precision and practical classification model of vehicle attribute using PaddleClas PULC (Practical Ultra Lightweight image Classification). The model can be widely used in Vehicle identification, road monitoring and other scenarios. The following table lists the relevant indicators of the model. The first three lines means that using Res2Net200_vd_26w_4s, ResNet50 and MobileNetV3_small_x0_35 as the backbone to training. The fourth to seventh lines means that the backbone is replaced by PPLCNet, additional use of EDA strategy and additional use of EDA strategy and SKL-UGI knowledge distillation strategy. - - -| Backbone | ma(%) | Latency(ms) | Size(M) | Training Strategy | + + +| Backbone | mA(%) | Latency(ms) | Size(M) | Training Strategy | |-------|-----------|----------|---------------|---------------| | Res2Net200_vd_26w_4s | 91.36 | 79.46 | 293 | using ImageNet pretrained | | ResNet50 | 89.98 | 12.83 | 92 | using ImageNet pretrained | @@ -52,11 +51,11 @@ The following table lists the relevant indicators of the model. The first three | PPLCNet_x1_0 | 89.57 | 2.36 | 7.2 | using ImageNet pretrained | | PPLCNet_x1_0 | 90.07 | 2.36 | 7.2 | using SSLD pretrained | | PPLCNet_x1_0 | 90.59 | 2.36 | 7.2 | using SSLD pretrained + EDA strategy| -| PPLCNet_x1_0 | 90.81 | 2.36 | 8.2 | using SSLD pretrained + EDA strategy + SKL-UGI knowledge distillation strategy| - +| PPLCNet_x1_0 | 90.81 | 2.36 | 7.2 | using SSLD pretrained + EDA strategy + SKL-UGI knowledge distillation strategy| + It can be seen from the table that the ma metric is higher when the backbone is Res2Net200_vd_26w_4s, but the inference speed is slower. After replacing the backbone with the lightweight model MobileNetV3_small_x0_35, the speed can be greatly improved, but the ma metric drops significantly. When the backbone is replaced by PPLCNet_x1_0, the ma metric is increased by 2 percentage points, and the speed is also increased by about 23%. On this basis, after using the SSLD pre-training model, the ma metric can be improved by about 0.5 percentage points without changing the inference speed. Further, when the EDA strategy is integrated, the ma metric can be improved by another 0.52 percentage points. Finally, using After SKL-UGI knowledge distillation, the ma metric can continue to improve by 0.23 percentage points. At this time, the ma metric of PPLCNet_x1_0 is only 0.55 percentage points away from Res2Net200_vd_26w_4s, but it is 32 times faster. The training method and deployment instructions of PULC will be introduced in detail below. - + **Note**: @@ -163,16 +162,16 @@ Part of the data visualization is shown below.
- + First, apply for and download data from [VeRi dataset official website](https://www.v7labs.com/open-datasets/veri-dataset), put it in the `dataset` directory of PaddleClas, the dataset directory name is `VeRi `, use the following command to enter the folder. - + ```shell cd PaddleClas/dataset/VeRi/ ``` - + Then use the following code to convert the label (you can execute the following command in the python terminal, or you can write it to a file and run the file using `python3 convert.py`). - + ```python import os from xml.dom.minidom import parse @@ -209,10 +208,10 @@ def convert_annotation(input_fp, output_fp): convert_annotation('train_label.xml', 'train_list.txt') #imagename vehiclenum colorid typeid convert_annotation('test_label.xml', 'test_list.txt') ``` - - + + After executing the above command, the `VeRi` directory has the following data: - + ``` VeRi ├── image_train @@ -231,7 +230,7 @@ VeRi ├── train_label.xml ├── test_label.xml ``` - + where `train/` and `test/` are the training set and validation set, respectively. `train_list.txt` and `test_list.txt` are the converted label files for training and validation sets, respectively. @@ -427,7 +426,7 @@ python3.7 python/predict_cls.py -c configs/PULC/vehicle_attribute/inference_vehi The prediction results: ``` -0002_c002_00030670_0.jpg: {'attributes': 'Color: (yellow, prob: 0.9893478155136108), Type: (hatchback, prob: 0.9734099507331848)', 'output': [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0]} +0002_c002_00030670_0.jpg: {'attributes': 'Color: (yellow, prob: 0.9893478155136108), Type: (hatchback, prob: 0.9734099507331848)', 'output': [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0]} ``` @@ -445,8 +444,8 @@ python3.7 python/predict_cls.py -c configs/PULC/vehicle_attribute/inference_vehi All prediction results will be printed, as shown below. ``` -0002_c002_00030670_0.jpg: {'attributes': 'Color: (yellow, prob: 0.9893476963043213), Type: (hatchback, prob: 0.9734097719192505)', 'output': [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0]} -0014_c012_00040750_0.jpg: {'attributes': 'Color: (red, prob: 0.999872088432312), Type: (sedan, prob: 0.999976634979248)', 'output': [0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0]} +0002_c002_00030670_0.jpg: {'attributes': 'Color: (yellow, prob: 0.9893476963043213), Type: (hatchback, prob: 0.9734097719192505)', 'output': [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0]} +0014_c012_00040750_0.jpg: {'attributes': 'Color: (red, prob: 0.999872088432312), Type: (sedan, prob: 0.999976634979248)', 'output': [0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0]} ``` Among the prediction results above, `someone` means that there is a human in the image, `nobody` means that there is no human in the image. diff --git a/docs/images/PP-HGNet/PP-HGNet-block.png b/docs/images/PP-HGNet/PP-HGNet-block.png index 56b6d6121739ade55c8f365d574c4de1180b8207..615aa383bb70d9d6a8d3d3e2860bfce3595515a6 100644 Binary files a/docs/images/PP-HGNet/PP-HGNet-block.png and b/docs/images/PP-HGNet/PP-HGNet-block.png differ diff --git a/docs/zh_CN/PULC/PULC_car_exists.md b/docs/zh_CN/PULC/PULC_car_exists.md index 86cc565c800ed29f1d126e258cb2c5ccf5d3c397..4107363534f9c76508d660ffb7d69dc705076a1a 100644 --- a/docs/zh_CN/PULC/PULC_car_exists.md +++ b/docs/zh_CN/PULC/PULC_car_exists.md @@ -40,19 +40,19 @@ ## 1. 模型和应用场景介绍 -该案例提供了用户使用 PaddleClas 的超轻量图像分类方案(PULC,Practical Ultra Lightweight Classification)快速构建轻量级、高精度、可落地的有车/无车的分类模型。该模型可以广泛应用于如监控场景、海量数据过滤场景等。 +该案例提供了用户使用 PaddleClas 的超轻量图像分类方案(PULC,Practical Ultra Lightweight image Classification)快速构建轻量级、高精度、可落地的有车/无车的分类模型。该模型可以广泛应用于如监控场景、海量数据过滤场景等。 下表列出了判断图片中是否有车的二分类模型的相关指标,前两行展现了使用 SwinTranformer_tiny 和 MobileNetV3_small_x0_35 作为 backbone 训练得到的模型的相关指标,第三行至第六行依次展现了替换 backbone 为 PPLCNet_x1_0、使用 SSLD 预训练模型、使用 SSLD 预训练模型 + EDA 策略、使用 SSLD 预训练模型 + EDA 策略 + SKL-UGI 知识蒸馏策略训练得到的模型的相关指标。 | 模型 | Tpr(%)@Fpr0.01 | 延时(ms) | 存储(M) | 策略 | |-------|----------------|----------|---------------|---------------| -| SwinTranformer_tiny | 97.71 | 95.30 | 107 | 使用 ImageNet 预训练模型 | -| MobileNetV3_small_x0_35 | 81.23 | 2.85 | 1.6 | 使用 ImageNet 预训练模型 | -| PPLCNet_x1_0 | 94.72 | 2.12 | 6.5 | 使用 ImageNet 预训练模型 | -| PPLCNet_x1_0 | 95.48 | 2.12 | 6.5 | 使用 SSLD 预训练模型 | -| PPLCNet_x1_0 | 95.48 | 2.12 | 6.5 | 使用 SSLD 预训练模型+EDA 策略| -| PPLCNet_x1_0 | 95.92 | 2.12 | 6.5 | 使用 SSLD 预训练模型+EDA 策略+SKL-UGI 知识蒸馏策略| +| SwinTranformer_tiny | 97.71 | 95.30 | 111 | 使用 ImageNet 预训练模型 | +| MobileNetV3_small_x0_35 | 81.23 | 2.85 | 2.7 | 使用 ImageNet 预训练模型 | +| PPLCNet_x1_0 | 94.72 | 2.12 | 7.1 | 使用 ImageNet 预训练模型 | +| PPLCNet_x1_0 | 95.48 | 2.12 | 7.1 | 使用 SSLD 预训练模型 | +| PPLCNet_x1_0 | 95.48 | 2.12 | 7.1 | 使用 SSLD 预训练模型+EDA 策略| +| PPLCNet_x1_0 | 95.92 | 2.12 | 7.1 | 使用 SSLD 预训练模型+EDA 策略+SKL-UGI 知识蒸馏策略| 从表中可以看出,backbone 为 SwinTranformer_tiny 时精度较高,但是推理速度较慢。将 backbone 替换为轻量级模型 MobileNetV3_small_x0_35 后,速度可以大幅提升,但是会导致精度大幅下降。将 backbone 替换为速度更快的 PPLCNet_x1_0 时,精度较 MobileNetV3_small_x0_35 高 13 个百分点,与此同时速度依旧可以快 20% 以上。在此基础上,使用 SSLD 预训练模型后,在不改变推理速度的前提下,精度可以提升约 0.7 个百分点,进一步地,在使用 SKL-UGI 知识蒸馏后,精度可以继续提升 0.44 个百分点。此时,PPLCNet_x1_0 达到了接近 SwinTranformer_tiny 模型的精度,但是速度快 40 多倍。关于 PULC 的训练方法和推理部署方法将在下面详细介绍。 diff --git a/docs/zh_CN/PULC/PULC_language_classification.md b/docs/zh_CN/PULC/PULC_language_classification.md index c11aafe6e9c017be60e55d8d03fefee4e5e5725e..309f3e9cc8a0c3c519722baeb13e5b90a8312e51 100644 --- a/docs/zh_CN/PULC/PULC_language_classification.md +++ b/docs/zh_CN/PULC/PULC_language_classification.md @@ -36,18 +36,18 @@ ## 1. 模型和应用场景介绍 -该案例提供了用户使用 PaddleClas 的超轻量图像分类方案(PULC,Practical Ultra Lightweight Classification)快速构建轻量级、高精度、可落地的语种分类模型。使用该方法训练得到的模型可以快速判断图片中的文字语种,该模型可以广泛应用于金融、政务等各种涉及多语种OCR处理的场景中。 +该案例提供了用户使用 PaddleClas 的超轻量图像分类方案(PULC,Practical Ultra Lightweight image Classification)快速构建轻量级、高精度、可落地的语种分类模型。使用该方法训练得到的模型可以快速判断图片中的文字语种,该模型可以广泛应用于金融、政务等各种涉及多语种OCR处理的场景中。 下表列出了语种分类模型的相关指标,前两行展现了使用 SwinTranformer_tiny 和 MobileNetV3_small_x0_35 作为 backbone 训练得到的模型的相关指标,第三行至第六行依次展现了替换 backbone 为 PPLCNet_x1_0、使用 SSLD 预训练模型、使用 SSLD 预训练模型 + EDA 策略、使用 SSLD 预训练模型 + EDA 策略 + SKL-UGI 知识蒸馏策略训练得到的模型的相关指标。其中替换 backbone 为 PPLCNet_x1_0时,将数据预处理时的输入尺寸变为[192,48],且网络的下采样stride调整为[2, [2, 1], [2, 1], [2, 1], [2, 1]]。 | 模型 | 精度 | 延时 | 存储 | 策略 | | ----------------------- | --------- | -------- | ------- | ---------------------------------------------- | -| SwinTranformer_tiny | 98.12 | 89.09 | 107 | 使用ImageNet预训练模型 | -| MobileNetV3_small_x0_35 | 95.92 | 2.98 | 17 | 使用ImageNet预训练模型 | -| PPLCNet_x1_0 | 98.35 | 2.58 | 6.5 | 使用ImageNet预训练模型 | -| PPLCNet_x1_0 | 98.7 | 2.58 | 6.5 | 使用SSLD预训练模型 | -| PPLCNet_x1_0 | 99.12 | 2.58 | 6.5 | 使用SSLD预训练模型+EDA策略 | -| **PPLCNet_x1_0** | **99.26** | **2.58** | **6.5** | 使用SSLD预训练模型+EDA策略+SKL-UGI知识蒸馏策略 | +| SwinTranformer_tiny | 98.12 | 89.09 | 111 | 使用ImageNet预训练模型 | +| MobileNetV3_small_x0_35 | 95.92 | 2.98 | 3.7 | 使用ImageNet预训练模型 | +| PPLCNet_x1_0 | 98.35 | 2.58 | 7.1 | 使用ImageNet预训练模型 | +| PPLCNet_x1_0 | 98.7 | 2.58 | 7.1 | 使用SSLD预训练模型 | +| PPLCNet_x1_0 | 99.12 | 2.58 | 7.1 | 使用SSLD预训练模型+EDA策略 | +| **PPLCNet_x1_0** | **99.26** | **2.58** | **7.1** | 使用SSLD预训练模型+EDA策略+SKL-UGI知识蒸馏策略 | 从表中可以看出,backbone 为 SwinTranformer_tiny 时精度比较高,但是推理速度较慢。将 backbone 替换为轻量级模型 MobileNetV3_small_x0_35 后,速度提升明显,但精度有了大幅下降。将 backbone 替换为 PPLCNet_x1_0 且调整预处理输入尺寸和网络的下采样stride时,速度略为提升,同时精度较 MobileNetV3_large_x1_0 高2.43个百分点。在此基础上,使用 SSLD 预训练模型后,在不改变推理速度的前提下,精度可以提升 0.35 个百分点,进一步地,当融合EDA策略后,精度可以再提升 0.42 个百分点,最后,在使用 SKL-UGI 知识蒸馏后,精度可以继续提升 0.14 个百分点。此时,PPLCNet_x1_0 超过了 SwinTranformer_tiny 模型的精度,并且速度有了明显提升。关于 PULC 的训练方法和推理部署方法将在下面详细介绍。 diff --git a/docs/zh_CN/PULC/PULC_model_list.md b/docs/zh_CN/PULC/PULC_model_list.md index 76d5a968626572d0307415476b0d308d73cfd568..4b2d7a8774d7d64a634a1bebc96481fc2ad076eb 100644 --- a/docs/zh_CN/PULC/PULC_model_list.md +++ b/docs/zh_CN/PULC/PULC_model_list.md @@ -7,15 +7,15 @@ |模型名称|模型简介|模型精度 |模型大小|推理耗时|下载地址| | --- | --- | --- | --- | --- | --- | -| person_exists |[PULC有人/无人分类模型](PULC_person_exists.md)| 95.60 |6.5M|2.58ms|[推理模型](https://paddleclas.bj.bcebos.com/models/PULC/inference/person_exists_infer.tar) / [预训练模型](https://paddleclas.bj.bcebos.com/models/PULC/pretrained/person_exists_pretrained.pdparams)| -| person_attribute |[PULC人体属性识别模型](PULC_person_attribute.md)| 78.59 |6.6M|2.01ms|[推理模型](https://paddleclas.bj.bcebos.com/models/PULC/inference/person_attribute_infer.tar) / [预训练模型](https://paddleclas.bj.bcebos.com/models/PULC/pretrained/person_attribute_pretrained.pdparams)| -| safety_helmet |[PULC佩戴安全帽分类模型](PULC_safety_helmet.md)| 99.38 |6.5M|2.03ms|[推理模型](https://paddleclas.bj.bcebos.com/models/PULC/inference/safety_helmet_infer.tar) / [预训练模型](https://paddleclas.bj.bcebos.com/models/PULC/pretrained/safety_helmet_pretrained.pdparams)| +| person_exists |[PULC有人/无人分类模型](PULC_person_exists.md)| 96.23 |7.0M|2.58ms|[推理模型](https://paddleclas.bj.bcebos.com/models/PULC/inference/person_exists_infer.tar) / [预训练模型](https://paddleclas.bj.bcebos.com/models/PULC/pretrained/person_exists_pretrained.pdparams)| +| person_attribute |[PULC人体属性识别模型](PULC_person_attribute.md)| 78.59 |7.2M|2.01ms|[推理模型](https://paddleclas.bj.bcebos.com/models/PULC/inference/person_attribute_infer.tar) / [预训练模型](https://paddleclas.bj.bcebos.com/models/PULC/pretrained/person_attribute_pretrained.pdparams)| +| safety_helmet |[PULC佩戴安全帽分类模型](PULC_safety_helmet.md)| 99.38 |7.1M|2.03ms|[推理模型](https://paddleclas.bj.bcebos.com/models/PULC/inference/safety_helmet_infer.tar) / [预训练模型](https://paddleclas.bj.bcebos.com/models/PULC/pretrained/safety_helmet_pretrained.pdparams)| | traffic_sign |[PULC交通标志分类模型](PULC_traffic_sign.md)| 98.35 |8.2M|2.10ms|[推理模型](https://paddleclas.bj.bcebos.com/models/PULC/inference/traffic_sign_infer.tar) / [预训练模型](https://paddleclas.bj.bcebos.com/models/PULC/pretrained/traffic_sign_pretrained.pdparams)| | vehicle_attribute |[PULC车辆属性识别模型](PULC_vehicle_attribute.md)| 90.81 |7.2M|2.36ms|[推理模型](https://paddleclas.bj.bcebos.com/models/PULC/inference/vehicle_attribute_infer.tar) / [预训练模型](https://paddleclas.bj.bcebos.com/models/PULC/pretrained/vehicle_attribute_pretrained.pdparams)| -| car_exists |[PULC有车/无车分类模型](PULC_car_exists.md) | 95.92 | 6.6M | 2.38ms |[推理模型](https://paddleclas.bj.bcebos.com/models/PULC/inference/car_exists_infer.tar) / [预训练模型](https://paddleclas.bj.bcebos.com/models/PULC/pretrained/car_exists_pretrained.pdparams)| -| text_image_orientation |[PULC含文字图像方向分类模型](PULC_text_image_orientation.md)| 99.06 | 6.5M | 2.16ms |[推理模型](https://paddleclas.bj.bcebos.com/models/PULC/inference/text_image_orientation_infer.tar) / [预训练模型](https://paddleclas.bj.bcebos.com/models/PULC/pretrained/text_image_orientation_pretrained.pdparams)| -| textline_orientation |[PULC文本行方向分类模型](PULC_textline_orientation.md)| 96.01 |6.5M|2.72ms|[推理模型](https://paddleclas.bj.bcebos.com/models/PULC/inference/textline_orientation_infer.tar) / [预训练模型](https://paddleclas.bj.bcebos.com/models/PULC/pretrained/textline_orientation_pretrained.pdparams)| -| language_classification |[PULC语种分类模型](PULC_language_classification.md)| 99.26 |6.5M|2.58ms|[推理模型](https://paddleclas.bj.bcebos.com/models/PULC/inference/language_classification_infer.tar) / [预训练模型](https://paddleclas.bj.bcebos.com/models/PULC/pretrained/language_classification_pretrained.pdparams)| +| car_exists |[PULC有车/无车分类模型](PULC_car_exists.md) | 95.92 | 7.1M | 2.38ms |[推理模型](https://paddleclas.bj.bcebos.com/models/PULC/inference/car_exists_infer.tar) / [预训练模型](https://paddleclas.bj.bcebos.com/models/PULC/pretrained/car_exists_pretrained.pdparams)| +| text_image_orientation |[PULC含文字图像方向分类模型](PULC_text_image_orientation.md)| 99.06 | 7.1M | 2.16ms |[推理模型](https://paddleclas.bj.bcebos.com/models/PULC/inference/text_image_orientation_infer.tar) / [预训练模型](https://paddleclas.bj.bcebos.com/models/PULC/pretrained/text_image_orientation_pretrained.pdparams)| +| textline_orientation |[PULC文本行方向分类模型](PULC_textline_orientation.md)| 96.01 |7.0M|2.72ms|[推理模型](https://paddleclas.bj.bcebos.com/models/PULC/inference/textline_orientation_infer.tar) / [预训练模型](https://paddleclas.bj.bcebos.com/models/PULC/pretrained/textline_orientation_pretrained.pdparams)| +| language_classification |[PULC语种分类模型](PULC_language_classification.md)| 99.26 |7.1M|2.58ms|[推理模型](https://paddleclas.bj.bcebos.com/models/PULC/inference/language_classification_infer.tar) / [预训练模型](https://paddleclas.bj.bcebos.com/models/PULC/pretrained/language_classification_pretrained.pdparams)| **备注:** diff --git a/docs/zh_CN/PULC/PULC_person_attribute.md b/docs/zh_CN/PULC/PULC_person_attribute.md index 731d89e2ef593115fef8ba5ea0e2eeccac302b44..a144aed80b1e3b3ccca6a530c3f8392a057e3190 100644 --- a/docs/zh_CN/PULC/PULC_person_attribute.md +++ b/docs/zh_CN/PULC/PULC_person_attribute.md @@ -42,18 +42,18 @@ 该案例提供了用户使用 PaddleClas 的超轻量图像分类方案(PULC,Practical Ultra Lightweight image Classification)快速构建轻量级、高精度、可落地的人体属性识别模型。该模型可以广泛应用于行人分析、行人跟踪等场景。 -下表列出了不同人体属性识别模型的相关指标,前两行展现了使用 SwinTransformer_tiny、Res2Net200_vd_26w_4s 和 MobileNetV3_small_x0_35 作为 backbone 训练得到的模型的相关指标,第三行至第六行依次展现了替换 backbone 为 PPLCNet_x1_0、使用 SSLD 预训练模型、使用 SSLD 预训练模型 + EDA 策略、使用 SSLD 预训练模型 + EDA 策略 + SKL-UGI 知识蒸馏策略训练得到的模型的相关指标。 +下表列出了不同人体属性识别模型的相关指标,前三行展现了使用 SwinTransformer_tiny、Res2Net200_vd_26w_4s 和 MobileNetV3_small_x0_35 作为 backbone 训练得到的模型的相关指标,第四行至第七行依次展现了替换 backbone 为 PPLCNet_x1_0、使用 SSLD 预训练模型、使用 SSLD 预训练模型 + EDA 策略、使用 SSLD 预训练模型 + EDA 策略 + SKL-UGI 知识蒸馏策略训练得到的模型的相关指标。 -| 模型 | ma(%) | 延时(ms) | 存储(M) | 策略 | +| 模型 | mA(%) | 延时(ms) | 存储(M) | 策略 | |-------|-----------|----------|---------------|---------------| | Res2Net200_vd_26w_4s | 81.25 | 77.51 | 293 | 使用ImageNet预训练模型 | -| SwinTransformer_tiny | 80.17 | 89.51 | 107 | 使用ImageNet预训练模型 | +| SwinTransformer_tiny | 80.17 | 89.51 | 111 | 使用ImageNet预训练模型 | | MobileNetV3_small_x0_35 | 70.79 | 2.90 | 1.7 | 使用ImageNet预训练模型 | -| PPLCNet_x1_0 | 76.31 | 2.01 | 6.6 | 使用ImageNet预训练模型 | -| PPLCNet_x1_0 | 77.31 | 2.01 | 6.6 | 使用SSLD预训练模型 | -| PPLCNet_x1_0 | 77.71 | 2.01 | 6.6 | 使用SSLD预训练模型+EDA策略| -| PPLCNet_x1_0 | 78.59 | 2.01 | 6.6 | 使用SSLD预训练模型+EDA策略+SKL-UGI知识蒸馏策略| +| PPLCNet_x1_0 | 76.31 | 2.01 | 7.1 | 使用ImageNet预训练模型 | +| PPLCNet_x1_0 | 77.31 | 2.01 | 7.1 | 使用SSLD预训练模型 | +| PPLCNet_x1_0 | 77.71 | 2.01 | 7.1 | 使用SSLD预训练模型+EDA策略| +| PPLCNet_x1_0 | 78.59 | 2.01 | 7.1 | 使用SSLD预训练模型+EDA策略+SKL-UGI知识蒸馏策略| 从表中可以看出,backbone 为 Res2Net200_vd_26w_4s 和 SwinTransformer_tiny 时精度较高,但是推理速度较慢。将 backbone 替换为轻量级模型 MobileNetV3_small_x0_35 后,速度可以大幅提升,但是精度也大幅下降。将 backbone 替换为 PPLCNet_x1_0 时,精度较 MobileNetV3_small_x0_35 高 5.5%,于此同时,速度更快。在此基础上,使用 SSLD 预训练模型后,在不改变推理速度的前提下,精度可以提升 1%,进一步地,当融合EDA策略后,精度可以再提升 0.4%,最后,在使用 SKL-UGI 知识蒸馏后,精度可以继续提升 0.88%。此时,PPLCNet_x1_0 的精度与 SwinTransformer_tiny 仅相差1.58%,但是速度快 44 倍。关于 PULC 的训练方法和推理部署方法将在下面详细介绍。 diff --git a/docs/zh_CN/PULC/PULC_person_exists.md b/docs/zh_CN/PULC/PULC_person_exists.md index 037ac714f7f1fb52ba5c9d2feefca708f3f02390..b3b830a893a4648645beab3a447ec8d894a5da4c 100644 --- a/docs/zh_CN/PULC/PULC_person_exists.md +++ b/docs/zh_CN/PULC/PULC_person_exists.md @@ -40,21 +40,21 @@ ## 1. 模型和应用场景介绍 -该案例提供了用户使用 PaddleClas 的超轻量图像分类方案(PULC,Practical Ultra Lightweight Classification)快速构建轻量级、高精度、可落地的有人/无人的分类模型。该模型可以广泛应用于如监控场景、人员进出管控场景、海量数据过滤场景等。 +该案例提供了用户使用 PaddleClas 的超轻量图像分类方案(PULC,Practical Ultra Lightweight image Classification)快速构建轻量级、高精度、可落地的有人/无人的分类模型。该模型可以广泛应用于如监控场景、人员进出管控场景、海量数据过滤场景等。 下表列出了判断图片中是否有人的二分类模型的相关指标,前两行展现了使用 SwinTranformer_tiny 和 MobileNetV3_small_x0_35 作为 backbone 训练得到的模型的相关指标,第三行至第六行依次展现了替换 backbone 为 PPLCNet_x1_0、使用 SSLD 预训练模型、使用 SSLD 预训练模型 + EDA 策略、使用 SSLD 预训练模型 + EDA 策略 + SKL-UGI 知识蒸馏策略训练得到的模型的相关指标。 | 模型 | Tpr(%) | 延时(ms) | 存储(M) | 策略 | |-------|-----------|----------|---------------|---------------| -| SwinTranformer_tiny | 95.69 | 95.30 | 107 | 使用 ImageNet 预训练模型 | -| MobileNetV3_small_x0_35 | 68.25 | 2.85 | 1.6 | 使用 ImageNet 预训练模型 | -| PPLCNet_x1_0 | 89.57 | 2.12 | 6.5 | 使用 ImageNet 预训练模型 | -| PPLCNet_x1_0 | 92.10 | 2.12 | 6.5 | 使用 SSLD 预训练模型 | -| PPLCNet_x1_0 | 93.43 | 2.12 | 6.5 | 使用 SSLD 预训练模型+EDA 策略| -| PPLCNet_x1_0 | 95.60 | 2.12 | 6.5 | 使用 SSLD 预训练模型+EDA 策略+SKL-UGI 知识蒸馏策略| - -从表中可以看出,backbone 为 SwinTranformer_tiny 时精度较高,但是推理速度较慢。将 backbone 替换为轻量级模型 MobileNetV3_small_x0_35 后,速度可以大幅提升,但是会导致精度大幅下降。将 backbone 替换为速度更快的 PPLCNet_x1_0 时,精度较 MobileNetV3_small_x0_35 高 20 多个百分点,与此同时速度依旧可以快 20% 以上。在此基础上,使用 SSLD 预训练模型后,在不改变推理速度的前提下,精度可以提升约 2.6 个百分点,进一步地,当融合EDA策略后,精度可以再提升 1.3 个百分点,最后,在使用 SKL-UGI 知识蒸馏后,精度可以继续提升 2.2 个百分点。此时,PPLCNet_x1_0 达到了 SwinTranformer_tiny 模型的精度,但是速度快 40 多倍。关于 PULC 的训练方法和推理部署方法将在下面详细介绍。 +| SwinTranformer_tiny | 95.69 | 95.30 | 111 | 使用 ImageNet 预训练模型 | +| MobileNetV3_small_x0_35 | 68.25 | 2.85 | 2.6 | 使用 ImageNet 预训练模型 | +| PPLCNet_x1_0 | 89.57 | 2.12 | 7.0 | 使用 ImageNet 预训练模型 | +| PPLCNet_x1_0 | 92.10 | 2.12 | 7.0 | 使用 SSLD 预训练模型 | +| PPLCNet_x1_0 | 93.43 | 2.12 | 7.0 | 使用 SSLD 预训练模型+EDA 策略| +| PPLCNet_x1_0 | 96.23 | 2.12 | 7.0 | 使用 SSLD 预训练模型+EDA 策略+SKL-UGI 知识蒸馏策略| + +从表中可以看出,backbone 为 SwinTranformer_tiny 时精度较高,但是推理速度较慢。将 backbone 替换为轻量级模型 MobileNetV3_small_x0_35 后,速度可以大幅提升,但是会导致精度大幅下降。将 backbone 替换为速度更快的 PPLCNet_x1_0 时,精度较 MobileNetV3_small_x0_35 高 20 多个百分点,与此同时速度依旧可以快 20% 以上。在此基础上,使用 SSLD 预训练模型后,在不改变推理速度的前提下,精度可以提升约 2.6 个百分点,进一步地,当融合EDA策略后,精度可以再提升 1.3 个百分点,最后,在使用 SKL-UGI 知识蒸馏后,精度可以继续提升 2.8 个百分点。此时,PPLCNet_x1_0 达到了 SwinTranformer_tiny 模型的精度,但是速度快 40 多倍。关于 PULC 的训练方法和推理部署方法将在下面详细介绍。 **备注:** diff --git a/docs/zh_CN/PULC/PULC_safety_helmet.md b/docs/zh_CN/PULC/PULC_safety_helmet.md index 515d4b938290ad2f1d592ebfee14fac0bcddee04..0467b61b12c629ebc7a6e2a2268b4c82fe512abe 100644 --- a/docs/zh_CN/PULC/PULC_safety_helmet.md +++ b/docs/zh_CN/PULC/PULC_safety_helmet.md @@ -39,19 +39,19 @@ ## 1. 模型和应用场景介绍 -该案例提供了用户使用 PaddleClas 的超轻量图像分类方案(PULC,Practical Ultra Lightweight Classification)快速构建轻量级、高精度、可落地的“是否佩戴安全帽”的二分类模型。该模型可以广泛应用于如建筑施工场景、工厂车间场景、交通场景等。 +该案例提供了用户使用 PaddleClas 的超轻量图像分类方案(PULC,Practical Ultra Lightweight image Classification)快速构建轻量级、高精度、可落地的“是否佩戴安全帽”的二分类模型。该模型可以广泛应用于如建筑施工场景、工厂车间场景、交通场景等。 -下表列出了判断图片中是否佩戴安全帽的二分类模型的相关指标,展现了使用 Res2Net200_vd_26w_4s,SwinTranformer_tiny 和 MobileNetV3_large_x1_0 作为 backbone 训练得到的模型的相关指标,第三行至第六行依次展现了替换 backbone 为 PPLCNet_x1_0、使用 SSLD 预训练模型、使用 SSLD 预训练模型 + EDA 策略、使用 SSLD 预训练模型 + EDA 策略 + UDML 知识蒸馏策略训练得到的模型的相关指标。 +下表列出了判断图片中是否佩戴安全帽的二分类模型的相关指标,前三行展现了使用 Res2Net200_vd_26w_4s,SwinTranformer_tiny 和 MobileNetV3_small_x0_35 作为 backbone 训练得到的模型的相关指标,第四行至第七行依次展现了替换 backbone 为 PPLCNet_x1_0、使用 SSLD 预训练模型、使用 SSLD 预训练模型 + EDA 策略、使用 SSLD 预训练模型 + EDA 策略 + UDML 知识蒸馏策略训练得到的模型的相关指标。 | 模型 | Tpr(%) | 延时(ms) | 存储(M) | 策略 | |-------|-----------|----------|---------------|---------------| -| SwinTranformer_tiny | 93.57 | 91.32 | 107 | 使用ImageNet预训练模型 | +| SwinTranformer_tiny | 93.57 | 91.32 | 111 | 使用ImageNet预训练模型 | | Res2Net200_vd_26w_4s | 98.92 | 80.99 | 284 | 使用ImageNet预训练模型 | -| MobileNetV3_small_x0_35 | 84.83 | 2.85 | 1.6 | 使用ImageNet预训练模型 | -| PPLCNet_x1_0 | 93.27 | 2.03 | 6.5 | 使用ImageNet预训练模型 | -| PPLCNet_x1_0 | 98.16 | 2.03 | 6.5 | 使用SSLD预训练模型 | -| PPLCNet_x1_0 | 99.30 | 2.03 | 6.5 | 使用SSLD预训练模型+EDA策略| -| PPLCNet_x1_0 | 99.38 | 2.03 | 6.5 | 使用SSLD预训练模型+EDA策略+UDML知识蒸馏策略| +| MobileNetV3_small_x0_35 | 84.83 | 2.85 | 2.6 | 使用ImageNet预训练模型 | +| PPLCNet_x1_0 | 93.27 | 2.03 | 7.1 | 使用ImageNet预训练模型 | +| PPLCNet_x1_0 | 98.16 | 2.03 | 7.1 | 使用SSLD预训练模型 | +| PPLCNet_x1_0 | 99.30 | 2.03 | 7.1 | 使用SSLD预训练模型+EDA策略| +| PPLCNet_x1_0 | 99.38 | 2.03 | 7.1 | 使用SSLD预训练模型+EDA策略+UDML知识蒸馏策略| 从表中可以看出,在使用服务器端大模型作为 backbone 时,SwinTranformer_tiny 精度较低,Res2Net200_vd_26w_4s 精度较高,但服务器端大模型推理速度普遍较慢。将 backbone 替换为轻量级模型 MobileNetV3_small_x0_35 后,速度可以大幅提升,但是精度显著降低。在将 backbone 替换为 PPLCNet_x1_0 后,精度较 MobileNetV3_small_x0_35 提高约 8.5 个百分点,与此同时速度快 20% 以上。在此基础上,将 PPLCNet_x1_0 的预训练模型替换为 SSLD 预训练模型后,在对推理速度无影响的前提下,精度提升约 4.9 个百分点,进一步地使用 EDA 策略后,精度可以再提升 1.1 个百分点。此时,PPLCNet_x1_0 已经超过 Res2Net200_vd_26w_4s 模型的精度,但是速度快 70+ 倍。最后,在使用 UDML 知识蒸馏后,精度可以再提升 0.08 个百分点。下面详细介绍关于 PULC 安全帽模型的训练方法和推理部署方法。 @@ -374,7 +374,7 @@ cd ../ ```shell # 使用下面的命令使用 GPU 进行预测 -c +python3.7 python/predict_cls.py -c configs/PULC/safety_helmet/inference_safety_helmet.yaml # 使用下面的命令使用 CPU 进行预测 python3.7 python/predict_cls.py -c configs/PULC/safety_helmet/inference_safety_helmet.yaml -o Global.use_gpu=False ``` diff --git a/docs/zh_CN/PULC/PULC_text_image_orientation.md b/docs/zh_CN/PULC/PULC_text_image_orientation.md index 1a7a0ff35f2da97059b5cdb205df45a622517f94..d89396f0a0c4a67dd0990bd4e19725684b894020 100644 --- a/docs/zh_CN/PULC/PULC_text_image_orientation.md +++ b/docs/zh_CN/PULC/PULC_text_image_orientation.md @@ -36,17 +36,17 @@ ## 1. 模型和应用场景介绍 -在诸如文档扫描、证照拍摄等过程中,有时为了拍摄更清晰,会将拍摄设备进行旋转,导致得到的图片也是不同方向的。此时,标准的OCR流程无法很好地应对这些数据。利用图像分类技术,可以预先判断含文字图像的方向,并将其进行方向调整,从而提高OCR处理的准确性。该案例提供了用户使用 PaddleClas 的超轻量图像分类方案(PULC,Practical Ultra Lightweight Classification)快速构建轻量级、高精度、可落地的含文字图像方向的分类模型。该模型可以广泛应用于金融、政务等行业的旋转图片的OCR处理场景中。 +在诸如文档扫描、证照拍摄等过程中,有时为了拍摄更清晰,会将拍摄设备进行旋转,导致得到的图片也是不同方向的。此时,标准的OCR流程无法很好地应对这些数据。利用图像分类技术,可以预先判断含文字图像的方向,并将其进行方向调整,从而提高OCR处理的准确性。该案例提供了用户使用 PaddleClas 的超轻量图像分类方案(PULC,Practical Ultra Lightweight image Classification)快速构建轻量级、高精度、可落地的含文字图像方向的分类模型。该模型可以广泛应用于金融、政务等行业的旋转图片的OCR处理场景中。 下表列出了判断含文字图像方向分类模型的相关指标,前两行展现了使用 SwinTranformer_tiny 和 MobileNetV3_small_x0_35 作为 backbone 训练得到的模型的相关指标,第三行至第五行依次展现了替换 backbone 为 PPLCNet_x1_0、使用 SSLD 预训练模型、使用EDA策略训练得到的模型的相关指标。 | 模型 | 精度(%) | 延时(ms) | 存储(M) | 策略 | | ----------------------- | --------- | ---------- | --------- | -------------------------- | -| SwinTranformer_tiny | 99.12 | 89.65 | 107 | 使用ImageNet预训练模型 | -| MobileNetV3_small_x0_35 | 83.61 | 2.95 | 17 | 使用ImageNet预训练模型 | -| PPLCNet_x1_0 | 97.85 | 2.16 | 6.5 | 使用ImageNet预训练模型 | -| PPLCNet_x1_0 | 99.02 | 2.16 | 6.5 | 使用SSLD预训练模型 | -| **PPLCNet_x1_0** | **99.06** | **2.16** | **6.5** | 使用SSLD预训练模型+EDA策略 | +| SwinTranformer_tiny | 99.12 | 89.65 | 111 | 使用ImageNet预训练模型 | +| MobileNetV3_small_x0_35 | 83.61 | 2.95 | 2.6 | 使用ImageNet预训练模型 | +| PPLCNet_x1_0 | 97.85 | 2.16 | 7.1 | 使用ImageNet预训练模型 | +| PPLCNet_x1_0 | 99.02 | 2.16 | 7.1 | 使用SSLD预训练模型 | +| **PPLCNet_x1_0** | **99.06** | **2.16** | **7.1** | 使用SSLD预训练模型+EDA策略 | 从表中可以看出,backbone 为 SwinTranformer_tiny 时精度比较高,但是推理速度较慢。将 backbone 替换为轻量级模型 MobileNetV3_small_x0_35 后,速度提升明显,但精度有了大幅下降。将 backbone 替换为 PPLCNet_x1_0 时,速度略为提升,同时精度较 MobileNetV3_small_x0_35 高了 14.24 个百分点。在此基础上,使用 SSLD 预训练模型后,在不改变推理速度的前提下,精度可以提升 1.17 个百分点,进一步地使用 EDA 策略后,精度可以再提升 0.04 个百分点。此时,PPLCNet_x1_0 与 SwinTranformer_tiny 的精度差别不大,但是速度明显变快。关于 PULC 的训练方法和推理部署方法将在下面详细介绍。 diff --git a/docs/zh_CN/PULC/PULC_textline_orientation.md b/docs/zh_CN/PULC/PULC_textline_orientation.md index d22d1a0cd41e89d762a70bb6f2f33fdf1d5aa9cb..eea10307532eb0a8a323a82108b0c5f9691a82f8 100644 --- a/docs/zh_CN/PULC/PULC_textline_orientation.md +++ b/docs/zh_CN/PULC/PULC_textline_orientation.md @@ -40,20 +40,20 @@ ## 1. 模型和应用场景介绍 -该案例提供了用户使用 PaddleClas 的超轻量图像分类方案(PULC,Practical Ultra Lightweight Classification)快速构建轻量级、高精度、可落地的文本行方向分类模型。该模型可以广泛应用于如文字矫正、文字识别等场景。 +该案例提供了用户使用 PaddleClas 的超轻量图像分类方案(PULC,Practical Ultra Lightweight image Classification)快速构建轻量级、高精度、可落地的文本行方向分类模型。该模型可以广泛应用于如文字矫正、文字识别等场景。 -下表列出了文本行方向分类模型的相关指标,前两行展现了使用 Res2Net200_vd 和 MobileNetV3_large_x1_0 作为 backbone 训练得到的模型的相关指标,第三行至第七行依次展现了替换 backbone 为 PPLCNet_x1_0、使用 SSLD 预训练模型、使用 SSLD 预训练模型 + EDA 策略、使用 SSLD 预训练模型 + EDA 策略 + SKL-UGI 知识蒸馏策略训练得到的模型的相关指标。 +下表列出了文本行方向分类模型的相关指标,前两行展现了使用 Res2Net200_vd 和 MobileNetV3_small_x0_35 作为 backbone 训练得到的模型的相关指标,第三行至第七行依次展现了替换 backbone 为 PPLCNet_x1_0、使用 SSLD 预训练模型、使用 SSLD 预训练模型 + EDA 策略、使用 SSLD 预训练模型 + EDA 策略 + SKL-UGI 知识蒸馏策略训练得到的模型的相关指标。 | 模型 | Top-1 Acc(%) | 延时(ms) | 存储(M) | 策略 | |-------|-----------|----------|---------------|---------------| -| SwinTranformer_tiny | 93.61 | 89.64 | 107 | 使用 ImageNet 预训练模型 | -| MobileNetV3_small_x0_35 | 81.40 | 2.96 | 17 | 使用 ImageNet 预训练模型 | -| PPLCNet_x1_0 | 89.99 | 2.11 | 6.5 | 使用 ImageNet 预训练模型 | -| PPLCNet_x1_0* | 94.06 | 2.68 | 6.5 | 使用 ImageNet 预训练模型 | -| PPLCNet_x1_0* | 94.11 | 2.68 | 6.5 | 使用 SSLD 预训练模型 | -| PPLCNet_x1_0** | 96.01 | 2.72 | 6.5 | 使用 SSLD 预训练模型+EDA 策略| -| PPLCNet_x1_0** | 95.86 | 2.72 | 6.5 | 使用 SSLD 预训练模型+EDA 策略+SKL-UGI 知识蒸馏策略| +| SwinTranformer_tiny | 93.61 | 89.64 | 111 | 使用 ImageNet 预训练模型 | +| MobileNetV3_small_x0_35 | 81.40 | 2.96 | 2.6 | 使用 ImageNet 预训练模型 | +| PPLCNet_x1_0 | 89.99 | 2.11 | 7.0 | 使用 ImageNet 预训练模型 | +| PPLCNet_x1_0* | 94.06 | 2.68 | 7.0 | 使用 ImageNet 预训练模型 | +| PPLCNet_x1_0* | 94.11 | 2.68 | 7.0 | 使用 SSLD 预训练模型 | +| PPLCNet_x1_0** | 96.01 | 2.72 | 7.0 | 使用 SSLD 预训练模型+EDA 策略| +| PPLCNet_x1_0** | 95.86 | 2.72 | 7.0 | 使用 SSLD 预训练模型+EDA 策略+SKL-UGI 知识蒸馏策略| 从表中可以看出,backbone 为 SwinTranformer_tiny 时精度较高,但是推理速度较慢。将 backbone 替换为轻量级模型 MobileNetV3_small_x0_35 后,速度可以大幅提升,精度下降也比较明显。将 backbone 替换为 PPLCNet_x1_0 时,精度较 MobileNetV3_small_x0_35 高 8.6 个百分点,速度快10%左右。在此基础上,更改分辨率和stride, 速度变慢 27%,但是精度可以提升 4.5 个百分点(采用[PaddleOCR](https://github.com/PaddlePaddle/PaddleOCR)的方案),使用 SSLD 预训练模型后,精度可以继续提升约 0.05 个百分点 ,进一步地,当融合EDA策略后,精度可以再提升 1.9 个百分点。最后,融合SKL-UGI 知识蒸馏策略后,在该场景无效。关于 PULC 的训练方法和推理部署方法将在下面详细介绍。 diff --git a/docs/zh_CN/PULC/PULC_traffic_sign.md b/docs/zh_CN/PULC/PULC_traffic_sign.md index b8eed290914edcc53ea51e831e29147a2d3c0113..700cbd58b89501ec8b7fe9add5bdceb373a36936 100644 --- a/docs/zh_CN/PULC/PULC_traffic_sign.md +++ b/docs/zh_CN/PULC/PULC_traffic_sign.md @@ -40,7 +40,7 @@ ## 1. 模型和应用场景介绍 -该案例提供了用户使用 PaddleClas 的超轻量图像分类方案(PULC,Practical Ultra Lightweight Classification)快速构建轻量级、高精度、可落地的交通标志分类模型。该模型可以广泛应用于自动驾驶、道路监控等场景。 +该案例提供了用户使用 PaddleClas 的超轻量图像分类方案(PULC,Practical Ultra Lightweight image Classification)快速构建轻量级、高精度、可落地的交通标志分类模型。该模型可以广泛应用于自动驾驶、道路监控等场景。 下表列出了不同交通标志分类模型的相关指标,前两行展现了使用 SwinTranformer_tiny 和 MobileNetV3_small_x0_35 作为 backbone 训练得到的模型的相关指标,第三行至第六行依次展现了替换 backbone 为 PPLCNet_x1_0、使用 SSLD 预训练模型、使用 SSLD 预训练模型 + EDA 策略、使用 SSLD 预训练模型 + EDA 策略 + SKL-UGI 知识蒸馏策略训练得到的模型的相关指标。 diff --git a/docs/zh_CN/PULC/PULC_vehicle_attribute.md b/docs/zh_CN/PULC/PULC_vehicle_attribute.md index 29d233f9844de87b3ffbff371efe0e56317d3138..03f67321fd04e1e33be0f7829da8bfce1c2be0a8 100644 --- a/docs/zh_CN/PULC/PULC_vehicle_attribute.md +++ b/docs/zh_CN/PULC/PULC_vehicle_attribute.md @@ -45,7 +45,7 @@ 下表列出了不同车辆属性识别模型的相关指标,前三行展现了使用 Res2Net200_vd_26w_4s、 ResNet50、MobileNetV3_small_x0_35 作为 backbone 训练得到的模型的相关指标,第四行至第七行依次展现了替换 backbone 为 PPLCNet_x1_0、使用 SSLD 预训练模型、使用 SSLD 预训练模型 + EDA 策略、使用 SSLD 预训练模型 + EDA 策略 + SKL-UGI 知识蒸馏策略训练得到的模型的相关指标。 -| 模型 | ma(%) | 延时(ms) | 存储(M) | 策略 | +| 模型 | mA(%) | 延时(ms) | 存储(M) | 策略 | |-------|-----------|----------|---------------|---------------| | Res2Net200_vd_26w_4s | 91.36 | 79.46 | 293 | 使用ImageNet预训练模型 | | ResNet50 | 89.98 | 12.83 | 92 | 使用ImageNet预训练模型 | @@ -53,12 +53,12 @@ | PPLCNet_x1_0 | 89.57 | 2.36 | 7.2 | 使用ImageNet预训练模型 | | PPLCNet_x1_0 | 90.07 | 2.36 | 7.2 | 使用SSLD预训练模型 | | PPLCNet_x1_0 | 90.59 | 2.36 | 7.2 | 使用SSLD预训练模型+EDA策略| -| PPLCNet_x1_0 | 90.81 | 2.36 | 8.2 | 使用SSLD预训练模型+EDA策略+SKL-UGI知识蒸馏策略| +| PPLCNet_x1_0 | 90.81 | 2.36 | 7.2 | 使用SSLD预训练模型+EDA策略+SKL-UGI知识蒸馏策略| 从表中可以看出,backbone 为 Res2Net200_vd_26w_4s 时精度较高,但是推理速度较慢。将 backbone 替换为轻量级模型 MobileNetV3_small_x0_35 后,速度可以大幅提升,但是精度下降明显。将 backbone 替换为 PPLCNet_x1_0 时,精度提升 2 个百分点,同时速度也提升 23% 左右。在此基础上,使用 SSLD 预训练模型后,在不改变推理速度的前提下,精度可以提升约 0.5 个百分点,进一步地,当融合EDA策略后,精度可以再提升 0.52 个百分点,最后,在使用 SKL-UGI 知识蒸馏后,精度可以继续提升 0.23 个百分点。此时,PPLCNet_x1_0 的精度与 Res2Net200_vd_26w_4s 仅相差 0.55 个百分点,但是速度快 32 倍。关于 PULC 的训练方法和推理部署方法将在下面详细介绍。 **备注:** - + * 延时是基于 Intel(R) Xeon(R) Gold 6148 CPU @ 2.40GHz 测试得到,开启 MKLDNN 加速策略,线程数为10。 * 关于PP-LCNet的介绍可以参考[PP-LCNet介绍](../models/PP-LCNet.md),相关论文可以查阅[PP-LCNet paper](https://arxiv.org/abs/2109.15099)。 @@ -178,7 +178,7 @@ from xml.dom.minidom import parse vehicleids = [] -def convert_annotation(input_fp, output_fp): +def convert_annotation(input_fp, output_fp, subdir): in_file = open(input_fp) list_file = open(output_fp, 'w') tree = parse(in_file) @@ -201,12 +201,12 @@ def convert_annotation(input_fp, output_fp): typeid = int (item.getAttribute("typeID")) label[typeid+9] = '1' label = ','.join(label) - list_file.write(os.path.join('image_train', name) + "\t" + label + "\n") + list_file.write(os.path.join(subdir, name) + "\t" + label + "\n") list_file.close() -convert_annotation('train_label.xml', 'train_list.txt') #imagename vehiclenum colorid typeid -convert_annotation('test_label.xml', 'test_list.txt') +convert_annotation('train_label.xml', 'train_list.txt', 'image_train') #imagename vehiclenum colorid typeid +convert_annotation('test_label.xml', 'test_list.txt', 'image_test') ``` 执行上述命令后,`VeRi`目录中具有以下数据: diff --git a/docs/zh_CN/models/PP-HGNet.md b/docs/zh_CN/models/PP-HGNet.md index 1150c87584319024767af1d3564f135d5391d83d..f89c11c84b20723a84f98754d090ea1119931e92 100644 --- a/docs/zh_CN/models/PP-HGNet.md +++ b/docs/zh_CN/models/PP-HGNet.md @@ -5,8 +5,9 @@ - [1.2 模型细节](#1.2) - [1.3 实验结果](#1.3) - [2. 模型快速体验](#2) - - [2.1 安装 paddleclas](#2.1) - - [2.2 预测](#2.2) + - [2.1 安装 paddlepaddle](#2.1) + - [2.2 安装 paddleclas](#2.2) + - [2.3 预测](#2.3) - [3. 模型训练、评估和预测](#3) - [3.1 环境配置](#3.1) - [3.2 数据准备](#3.2) @@ -88,24 +89,43 @@ PP-HGNet 与其他模型的比较如下,其中测试机器为 NVIDIA® Tesla® | ResNeXt101_32x48d_wsl | 85.37 | 97.69 | 55.07 | | SwinTransformer_base | 85.2 | 97.5 | 13.53 | | PPHGNet_base_ssld | 85.00| 97.35 | 5.97 | - - - + + + ## 2. 模型快速体验 - - -### 2.1 安装 paddleclas - -使用如下命令快速安装 paddlepaddle, paddleclas - -``` -pip3 install paddlepaddle paddleclas + + +### 2.1 安装 paddlepaddle + +- 您的机器安装的是 CUDA9 或 CUDA10,请运行以下命令安装 + +```bash +python3 -m pip install paddlepaddle-gpu -i https://mirror.baidu.com/pypi/simple +``` + +- 您的机器是CPU,请运行以下命令安装 + +```bash +python3 -m pip install paddlepaddle -i https://mirror.baidu.com/pypi/simple ``` - + +更多的版本需求,请参照[飞桨官网安装文档](https://www.paddlepaddle.org.cn/install/quick)中的说明进行操作。 + + + +### 2.2 安装 paddleclas + +使用如下命令快速安装 paddleclas + +``` +pip3 install paddleclas +``` + + -### 2.2 预测 +### 2.3 预测 * 在命令行中使用 PPHGNet_small 的权重快速预测 diff --git a/docs/zh_CN/models/PP-LCNet.md b/docs/zh_CN/models/PP-LCNet.md index 2c9627cfb195a7b384c262c0b4076bdf15bd3de3..2df3c3e297f3f20cb3ffca62c67397f61364de3f 100644 --- a/docs/zh_CN/models/PP-LCNet.md +++ b/docs/zh_CN/models/PP-LCNet.md @@ -16,8 +16,9 @@ - [1.4.2 基于 V100 GPU 的预测速度](#1.4.2) - [1.4.3 基于 SD855 的预测速度](#1.4.3) - [2. 模型快速体验](#2) - - [2.1 安装 paddleclas](#2.1) - - [2.2 预测](#2.2) + - [2.1 安装 paddlepaddle](#2.1) + - [2.2 安装 paddleclas](#2.2) + - [2.3 预测](#2.3) - [3. 模型训练、评估和预测](#3) - [3.1 环境配置](#3.1) - [3.2 数据准备](#3.2) @@ -240,16 +241,35 @@ MobileNetV3_large_x0_75 | 64.53 | 151 | -### 2.1 安装 paddleclas - -使用如下命令快速安装 paddlepaddle, paddleclas - -``` -pip3 install paddlepaddle paddleclas +### 2.1 安装 paddlepaddle + +- 您的机器安装的是 CUDA9 或 CUDA10,请运行以下命令安装 + +```bash +python3 -m pip install paddlepaddle-gpu -i https://mirror.baidu.com/pypi/simple +``` + +- 您的机器是CPU,请运行以下命令安装 + +```bash +python3 -m pip install paddlepaddle -i https://mirror.baidu.com/pypi/simple +``` + +更多的版本需求,请参照[飞桨官网安装文档](https://www.paddlepaddle.org.cn/install/quick)中的说明进行操作。 + + + +### 2.2 安装 paddleclas + +使用如下命令快速安装 paddleclas + +``` +pip3 install paddleclas ``` - -### 2.2 预测 + + +### 2.3 预测 * 在命令行中使用 PPLCNet_x1_0 的权重快速预测 diff --git a/docs/zh_CN/models/PP-LCNetV2.md b/docs/zh_CN/models/PP-LCNetV2.md index 23c01df129c6a1e81f7aba30e5d5c3cbe841634b..01498478c1ee39fa651c1f6c6bd53a0b768fc241 100644 --- a/docs/zh_CN/models/PP-LCNetV2.md +++ b/docs/zh_CN/models/PP-LCNetV2.md @@ -14,8 +14,9 @@ - [1.2.5 SE 模块](#1.2.5) - [1.3 实验结果](#1.3) - [2. 模型快速体验](#2) - - [2.1 安装 paddleclas](#2.1) - - [2.2 预测](#2.2) + - [2.1 安装 paddlepaddle](#2.1) + - [2.2 安装 paddleclas](#2.2) + - [2.3 预测](#2.3) - [3. 模型训练、评估和预测](#3) - [3.1 环境配置](#3.1) - [3.2 数据准备](#3.2) @@ -114,22 +115,41 @@ PPLCNetV2 目前提供的模型的精度、速度指标及预训练权重链接 | PPLCNetV2_base_ssld | 6.6 | 604 | 80.07 | 94.87 | 4.32 | - + ## 2. 模型快速体验 -### 2.1 安装 paddleclas - -使用如下命令快速安装 paddlepaddle, paddleclas - -``` -pip3 install paddlepaddle paddleclas +### 2.1 安装 paddlepaddle + +- 您的机器安装的是 CUDA9 或 CUDA10,请运行以下命令安装 + +```bash +python3 -m pip install paddlepaddle-gpu -i https://mirror.baidu.com/pypi/simple +``` + +- 您的机器是CPU,请运行以下命令安装 + +```bash +python3 -m pip install paddlepaddle -i https://mirror.baidu.com/pypi/simple +``` + +更多的版本需求,请参照[飞桨官网安装文档](https://www.paddlepaddle.org.cn/install/quick)中的说明进行操作。 + + + +### 2.2 安装 paddleclas + +使用如下命令快速安装 paddleclas + +``` +pip3 install paddleclas ``` - -### 2.2 预测 + + +### 2.3 预测 * 在命令行中使用 PPLCNetV2_base 的权重快速预测 diff --git a/docs/zh_CN/models/ResNet.md b/docs/zh_CN/models/ResNet.md index 31bf4ac961849182bc9406a42aa9b8221ed866f4..7a3f4f6335cab1fff2a4e46555af5e1461c41429 100644 --- a/docs/zh_CN/models/ResNet.md +++ b/docs/zh_CN/models/ResNet.md @@ -9,8 +9,9 @@ - [1.3.1 基于 V100 GPU 的预测速度](#1.3.1) - [1.3.2 基于 T4 GPU 的预测速度](#1.3.2) - [2. 模型快速体验](#2) - - [2.1 安装 paddleclas](#2.1) - - [2.2 预测](#2.2) + - [2.1 安装 paddlepaddle](#2.1) + - [2.2 安装 paddleclas](#2.2) + - [2.3 预测](#2.3) - [3. 模型训练、评估和预测](#3) - [3.1 环境配置](#3.1) - [3.2 数据准备](#3.2) @@ -131,16 +132,34 @@ PaddleClas 提供的 ResNet 系列的模型包括 ResNet50,ResNet50_vd,ResNe -### 2.1 安装 paddleclas - -使用如下命令快速安装 paddlepaddle, paddleclas - -``` -pip3 install paddlepaddle paddleclas +### 2.1 安装 paddlepaddle + +- 您的机器安装的是 CUDA9 或 CUDA10,请运行以下命令安装 + +```bash +python3 -m pip install paddlepaddle-gpu -i https://mirror.baidu.com/pypi/simple +``` + +- 您的机器是CPU,请运行以下命令安装 + +```bash +python3 -m pip install paddlepaddle -i https://mirror.baidu.com/pypi/simple +``` + +更多的版本需求,请参照[飞桨官网安装文档](https://www.paddlepaddle.org.cn/install/quick)中的说明进行操作。 + + + +### 2.2 安装 paddleclas + +使用如下命令快速安装 paddleclas + +``` +pip3 install paddleclas ``` - + -### 2.2 预测 +### 2.3 预测 * 在命令行中使用 ResNet50 的权重快速预测 diff --git a/paddleclas.py b/paddleclas.py index 91e7fcb84e2aa7013a084ab957e049659e13fe5b..3b45ca120aebad27ea268a0db3edae72c840d705 100644 --- a/paddleclas.py +++ b/paddleclas.py @@ -340,6 +340,7 @@ def print_info(): first_width = 30 second_width = total_width - first_width if total_width > 50 else 10 except OSError: + total_width = 100 second_width = 100 for series in IMN_MODEL_SERIES: names = textwrap.fill( @@ -452,7 +453,9 @@ class PaddleClas(object): """PaddleClas. """ - print_info() + if not os.environ.get('ppcls', False): + os.environ.setdefault('ppcls', 'True') + print_info() def __init__(self, model_name: str=None, diff --git a/ppcls/configs/PULC/language_classification/PPLCNet_x1_0.yaml b/ppcls/configs/PULC/language_classification/PPLCNet_x1_0.yaml index f704445e2bdfa00df89eec909fe20eb7dd918694..081d8d23f2be9598adf450cd048a2f6094d4477c 100644 --- a/ppcls/configs/PULC/language_classification/PPLCNet_x1_0.yaml +++ b/ppcls/configs/PULC/language_classification/PPLCNet_x1_0.yaml @@ -11,7 +11,7 @@ Global: print_batch_step: 10 use_visualdl: False # used for static mode and model export - image_shape: [3, 224, 224] + image_shape: [3, 80, 160] save_inference_dir: ./inference # model architecture diff --git a/ppcls/configs/PULC/language_classification/PPLCNet_x1_0_search.yaml b/ppcls/configs/PULC/language_classification/PPLCNet_x1_0_search.yaml index cf045050c3a6cdaf7aeafc8a22fbb20d2c56852e..49a5f17026e99441db8949b52e3b8d1942bc3139 100644 --- a/ppcls/configs/PULC/language_classification/PPLCNet_x1_0_search.yaml +++ b/ppcls/configs/PULC/language_classification/PPLCNet_x1_0_search.yaml @@ -11,7 +11,7 @@ Global: print_batch_step: 10 use_visualdl: False # used for static mode and model export - image_shape: [3, 224, 224] + image_shape: [3, 48, 192] save_inference_dir: ./inference start_eval_epoch: 20 diff --git a/ppcls/data/preprocess/ops/operators.py b/ppcls/data/preprocess/ops/operators.py index 344675fdb85d6102bb99f03af4a17c8b9c00927e..d87960e93fe7bc7e2e67f7c30d1b58d811153905 100644 --- a/ppcls/data/preprocess/ops/operators.py +++ b/ppcls/data/preprocess/ops/operators.py @@ -430,7 +430,7 @@ class RandCropImageV2(object): def __call__(self, img): if isinstance(img, np.ndarray): - img_h, img_w = img.shap[0], img.shap[1] + img_h, img_w = img.shape[0], img.shape[1] else: img_w, img_h = img.size tw, th = self.size diff --git a/ppcls/utils/logger.py b/ppcls/utils/logger.py index bc8de364091e9b56dafdcffa4475f7f225306e1b..5edca7a12a9dcff213d5663334e034ee42595d8f 100644 --- a/ppcls/utils/logger.py +++ b/ppcls/utils/logger.py @@ -12,11 +12,11 @@ # See the License for the specific language governing permissions and # limitations under the License. +import datetime +import logging import os import sys -import logging -import datetime import paddle.distributed as dist _logger = None @@ -39,8 +39,12 @@ def init_logger(name='ppcls', log_file=None, log_level=logging.INFO): logging.Logger: The expected logger. """ global _logger - assert _logger is None, "logger should not be initialized twice or more." - _logger = logging.getLogger(name) + + # solve mutiple init issue when using paddleclas.py and engin.engin + init_flag = False + if _logger is None: + _logger = logging.getLogger(name) + init_flag = True formatter = logging.Formatter( '[%(asctime)s] %(name)s %(levelname)s: %(message)s', @@ -48,13 +52,32 @@ def init_logger(name='ppcls', log_file=None, log_level=logging.INFO): stream_handler = logging.StreamHandler(stream=sys.stdout) stream_handler.setFormatter(formatter) - _logger.addHandler(stream_handler) + stream_handler._name = 'stream_handler' + + # add stream_handler when _logger dose not contain stream_handler + for i, h in enumerate(_logger.handlers): + if h.get_name() == stream_handler.get_name(): + break + if i == len(_logger.handlers) - 1: + _logger.addHandler(stream_handler) + if init_flag: + _logger.addHandler(stream_handler) + if log_file is not None and dist.get_rank() == 0: log_file_folder = os.path.split(log_file)[0] os.makedirs(log_file_folder, exist_ok=True) file_handler = logging.FileHandler(log_file, 'a') file_handler.setFormatter(formatter) - _logger.addHandler(file_handler) + file_handler._name = 'file_handler' + + # add file_handler when _logger dose not contain same file_handler + for i, h in enumerate(_logger.handlers): + if h.get_name() == file_handler.get_name() and \ + h.baseFilename == file_handler.baseFilename: + break + if i == len(_logger.handlers) - 1: + _logger.addHandler(file_handler) + if dist.get_rank() == 0: _logger.setLevel(log_level) else: diff --git a/test_tipc/config/MobileNetV3/MobileNetV3_large_x1_0_KL_linux_gpu_normal_normal_infer_cpp_linux_gpu_cpu.txt b/test_tipc/config/MobileNetV3/MobileNetV3_large_x1_0_KL_linux_gpu_normal_normal_infer_cpp_linux_gpu_cpu.txt new file mode 100644 index 0000000000000000000000000000000000000000..6393d49a2f4b6d0e7228e88f046e738230d0c542 --- /dev/null +++ b/test_tipc/config/MobileNetV3/MobileNetV3_large_x1_0_KL_linux_gpu_normal_normal_infer_cpp_linux_gpu_cpu.txt @@ -0,0 +1,18 @@ +===========================cpp_infer_params=========================== +model_name:MobileNetV3_large_x1_0_KL +cpp_infer_type:cls +cls_inference_model_dir:./MobileNetV3_large_x1_0_kl_quant_infer/ +det_inference_model_dir: +cls_inference_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/slim_model/MobileNetV3_large_x1_0_kl_quant_infer.tar +det_inference_url: +infer_quant:False +inference_cmd:./deploy/cpp/build/clas_system -c inference_cls.yaml +use_gpu:True|False +enable_mkldnn:False +cpu_threads:1 +batch_size:1 +use_tensorrt:False +precision:fp32 +image_dir:./dataset/ILSVRC2012/val/ILSVRC2012_val_00000001.JPEG +benchmark:False +generate_yaml_cmd:python3.7 test_tipc/generate_cpp_yaml.py diff --git a/test_tipc/config/MobileNetV3/MobileNetV3_large_x1_0_KL_linux_gpu_normal_normal_serving_cpp_linux_gpu_cpu.txt b/test_tipc/config/MobileNetV3/MobileNetV3_large_x1_0_KL_linux_gpu_normal_normal_serving_cpp_linux_gpu_cpu.txt new file mode 100644 index 0000000000000000000000000000000000000000..05efbacc76cbfd69279d658350abca9cfc607bd5 --- /dev/null +++ b/test_tipc/config/MobileNetV3/MobileNetV3_large_x1_0_KL_linux_gpu_normal_normal_serving_cpp_linux_gpu_cpu.txt @@ -0,0 +1,14 @@ +===========================serving_params=========================== +model_name:MobileNetV3_large_x1_0_KL +python:python3.7 +inference_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/slim_model/MobileNetV3_large_x1_0_kl_quant_infer.tar +trans_model:-m paddle_serving_client.convert +--dirname:./deploy/paddleserving/MobileNetV3_large_x1_0_kl_quant_infer/ +--model_filename:inference.pdmodel +--params_filename:inference.pdiparams +--serving_server:./deploy/paddleserving/MobileNetV3_large_x1_0_kl_quant_serving/ +--serving_client:./deploy/paddleserving/MobileNetV3_large_x1_0_kl_quant_client/ +serving_dir:./deploy/paddleserving +web_service:null +--use_gpu:0|null +pipline:test_cpp_serving_client.py diff --git a/test_tipc/config/MobileNetV3/MobileNetV3_large_x1_0_KL_linux_gpu_normal_normal_serving_python_linux_gpu_cpu.txt b/test_tipc/config/MobileNetV3/MobileNetV3_large_x1_0_KL_linux_gpu_normal_normal_serving_python_linux_gpu_cpu.txt new file mode 100644 index 0000000000000000000000000000000000000000..32b506afd594b486d6fe759ee2d1556f9b049a8c --- /dev/null +++ b/test_tipc/config/MobileNetV3/MobileNetV3_large_x1_0_KL_linux_gpu_normal_normal_serving_python_linux_gpu_cpu.txt @@ -0,0 +1,14 @@ +===========================serving_params=========================== +model_name:MobileNetV3_large_x1_0_KL +python:python3.7 +inference_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/slim_model/MobileNetV3_large_x1_0_kl_quant_infer.tar +trans_model:-m paddle_serving_client.convert +--dirname:./deploy/paddleserving/MobileNetV3_large_x1_0_kl_quant_infer/ +--model_filename:inference.pdmodel +--params_filename:inference.pdiparams +--serving_server:./deploy/paddleserving/MobileNetV3_large_x1_0_kl_quant_serving/ +--serving_client:./deploy/paddleserving/MobileNetV3_large_x1_0_kl_quant_client/ +serving_dir:./deploy/paddleserving +web_service:classification_web_service.py +--use_gpu:0|null +pipline:pipeline_http_client.py diff --git a/test_tipc/config/PP-ShiTu/PPShiTu_general_rec_KL_linux_gpu_normal_normal_infer_cpp_linux_gpu_cpu.txt b/test_tipc/config/PP-ShiTu/PPShiTu_general_rec_KL_linux_gpu_normal_normal_infer_cpp_linux_gpu_cpu.txt new file mode 100644 index 0000000000000000000000000000000000000000..3c6e7ae0db89cc78f8745f1e294ac1f93dedac60 --- /dev/null +++ b/test_tipc/config/PP-ShiTu/PPShiTu_general_rec_KL_linux_gpu_normal_normal_infer_cpp_linux_gpu_cpu.txt @@ -0,0 +1,18 @@ +===========================cpp_infer_params=========================== +model_name:GeneralRecognition_PPLCNet_x2_5_KL +cpp_infer_type:cls +cls_inference_model_dir:./general_PPLCNet_x2_5_lite_v1.0_kl_quant_infer/ +det_inference_model_dir: +cls_inference_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/slim_model/general_PPLCNet_x2_5_lite_v1.0_kl_quant_infer.tar +det_inference_url: +infer_quant:False +inference_cmd:./deploy/cpp/build/clas_system -c inference_cls.yaml +use_gpu:True|False +enable_mkldnn:False +cpu_threads:1 +batch_size:1 +use_tensorrt:False +precision:fp32 +image_dir:./dataset/ILSVRC2012/val/ILSVRC2012_val_00000001.JPEG +benchmark:False +generate_yaml_cmd:python3.7 test_tipc/generate_cpp_yaml.py diff --git a/test_tipc/config/PP-ShiTu/PPShiTu_general_rec_KL_linux_gpu_normal_normal_serving_cpp_linux_gpu_cpu.txt b/test_tipc/config/PP-ShiTu/PPShiTu_general_rec_KL_linux_gpu_normal_normal_serving_cpp_linux_gpu_cpu.txt new file mode 100644 index 0000000000000000000000000000000000000000..68a3e04510ced8a60bbfd4980673187e153873df --- /dev/null +++ b/test_tipc/config/PP-ShiTu/PPShiTu_general_rec_KL_linux_gpu_normal_normal_serving_cpp_linux_gpu_cpu.txt @@ -0,0 +1,14 @@ +===========================serving_params=========================== +model_name:GeneralRecognition_PPLCNet_x2_5_KL +python:python3.7 +inference_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/slim_model/general_PPLCNet_x2_5_lite_v1.0_kl_quant_infer.tar +trans_model:-m paddle_serving_client.convert +--dirname:./deploy/paddleserving/general_PPLCNet_x2_5_lite_v1.0_kl_quant_infer/ +--model_filename:inference.pdmodel +--params_filename:inference.pdiparams +--serving_server:./deploy/paddleserving/GeneralRecognition_PPLCNet_x2_5_kl_quant_serving/ +--serving_client:./deploy/paddleserving/GeneralRecognition_PPLCNet_x2_5_kl_quant_client/ +serving_dir:./deploy/paddleserving +web_service:null +--use_gpu:0|null +pipline:test_cpp_serving_client.py diff --git a/test_tipc/config/PP-ShiTu/PPShiTu_general_rec_KL_linux_gpu_normal_normal_serving_python_linux_gpu_cpu.txt b/test_tipc/config/PP-ShiTu/PPShiTu_general_rec_KL_linux_gpu_normal_normal_serving_python_linux_gpu_cpu.txt new file mode 100644 index 0000000000000000000000000000000000000000..a3c036ff8a5cf7ceb5c7e8d755afd4e65f1a9c40 --- /dev/null +++ b/test_tipc/config/PP-ShiTu/PPShiTu_general_rec_KL_linux_gpu_normal_normal_serving_python_linux_gpu_cpu.txt @@ -0,0 +1,14 @@ +===========================serving_params=========================== +model_name:GeneralRecognition_PPLCNet_x2_5_KL +python:python3.7 +inference_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/slim_model/general_PPLCNet_x2_5_lite_v1.0_kl_quant_infer.tar +trans_model:-m paddle_serving_client.convert +--dirname:./deploy/paddleserving/general_PPLCNet_x2_5_lite_v1.0_kl_quant_infer/ +--model_filename:inference.pdmodel +--params_filename:inference.pdiparams +--serving_server:./deploy/paddleserving/GeneralRecognition_PPLCNet_x2_5_kl_quant_serving/ +--serving_client:./deploy/paddleserving/GeneralRecognition_PPLCNet_x2_5_kl_quant_client/ +serving_dir:./deploy/paddleserving +web_service:classification_web_service.py +--use_gpu:0|null +pipline:pipeline_http_client.py diff --git a/test_tipc/config/PPHGNet/PPHGNet_small_KL_linux_gpu_normal_normal_infer_cpp_linux_gpu_cpu.txt b/test_tipc/config/PPHGNet/PPHGNet_small_KL_linux_gpu_normal_normal_infer_cpp_linux_gpu_cpu.txt new file mode 100644 index 0000000000000000000000000000000000000000..1c962c76190dfd89871e956390cce5bbb7d47937 --- /dev/null +++ b/test_tipc/config/PPHGNet/PPHGNet_small_KL_linux_gpu_normal_normal_infer_cpp_linux_gpu_cpu.txt @@ -0,0 +1,18 @@ +===========================cpp_infer_params=========================== +model_name:PPHGNet_small_KL +cpp_infer_type:cls +cls_inference_model_dir:./PPHGNet_small_kl_quant_infer/ +det_inference_model_dir: +cls_inference_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/slim_model/PPHGNet_small_kl_quant_infer.tar +det_inference_url: +infer_quant:False +inference_cmd:./deploy/cpp/build/clas_system -c inference_cls.yaml +use_gpu:True|False +enable_mkldnn:False +cpu_threads:1 +batch_size:1 +use_tensorrt:False +precision:fp32 +image_dir:./dataset/ILSVRC2012/val/ILSVRC2012_val_00000001.JPEG +benchmark:False +generate_yaml_cmd:python3.7 test_tipc/generate_cpp_yaml.py diff --git a/test_tipc/config/PPHGNet/PPHGNet_small_KL_linux_gpu_normal_normal_serving_cpp_linux_gpu_cpu.txt b/test_tipc/config/PPHGNet/PPHGNet_small_KL_linux_gpu_normal_normal_serving_cpp_linux_gpu_cpu.txt new file mode 100644 index 0000000000000000000000000000000000000000..6890b2fd9c33e8df199fc5b3c53f7c94a6144e45 --- /dev/null +++ b/test_tipc/config/PPHGNet/PPHGNet_small_KL_linux_gpu_normal_normal_serving_cpp_linux_gpu_cpu.txt @@ -0,0 +1,14 @@ +===========================serving_params=========================== +model_name:PPHGNet_small_KL +python:python3.7 +inference_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/slim_model/PPHGNet_small_kl_quant_infer.tar +trans_model:-m paddle_serving_client.convert +--dirname:./deploy/paddleserving/PPHGNet_small_kl_quant_infer/ +--model_filename:inference.pdmodel +--params_filename:inference.pdiparams +--serving_server:./deploy/paddleserving/PPHGNet_small_kl_quant_serving/ +--serving_client:./deploy/paddleserving/PPHGNet_small_kl_quant_client/ +serving_dir:./deploy/paddleserving +web_service:null +--use_gpu:0|null +pipline:test_cpp_serving_client.py diff --git a/test_tipc/config/PPHGNet/PPHGNet_small_KL_linux_gpu_normal_normal_serving_python_linux_gpu_cpu.txt b/test_tipc/config/PPHGNet/PPHGNet_small_KL_linux_gpu_normal_normal_serving_python_linux_gpu_cpu.txt new file mode 100644 index 0000000000000000000000000000000000000000..786fac936cb51c6d75abc70928a1d25b7c54b730 --- /dev/null +++ b/test_tipc/config/PPHGNet/PPHGNet_small_KL_linux_gpu_normal_normal_serving_python_linux_gpu_cpu.txt @@ -0,0 +1,14 @@ +===========================serving_params=========================== +model_name:PPHGNet_small_KL +python:python3.7 +inference_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/slim_model/PPHGNet_small_kl_quant_infer.tar +trans_model:-m paddle_serving_client.convert +--dirname:./deploy/paddleserving/PPHGNet_small_kl_quant_infer/ +--model_filename:inference.pdmodel +--params_filename:inference.pdiparams +--serving_server:./deploy/paddleserving/PPHGNet_small_kl_quant_serving/ +--serving_client:./deploy/paddleserving/PPHGNet_small_kl_quant_client/ +serving_dir:./deploy/paddleserving +web_service:classification_web_service.py +--use_gpu:0|null +pipline:pipeline_http_client.py diff --git a/test_tipc/config/PPLCNet/PPLCNet_x1_0_KL_linux_gpu_normal_normal_infer_cpp_linux_gpu_cpu.txt b/test_tipc/config/PPLCNet/PPLCNet_x1_0_KL_linux_gpu_normal_normal_infer_cpp_linux_gpu_cpu.txt new file mode 100644 index 0000000000000000000000000000000000000000..1489dff0bc7e5103f69df687083fc94e4c863ec1 --- /dev/null +++ b/test_tipc/config/PPLCNet/PPLCNet_x1_0_KL_linux_gpu_normal_normal_infer_cpp_linux_gpu_cpu.txt @@ -0,0 +1,18 @@ +===========================cpp_infer_params=========================== +model_name:PPLCNet_x1_0_KL +cpp_infer_type:cls +cls_inference_model_dir:./PPLCNet_x1_0_kl_quant_infer/ +det_inference_model_dir: +cls_inference_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/slim_model/PPLCNet_x1_0_kl_quant_infer.tar +det_inference_url: +infer_quant:False +inference_cmd:./deploy/cpp/build/clas_system -c inference_cls.yaml +use_gpu:True|False +enable_mkldnn:False +cpu_threads:1 +batch_size:1 +use_tensorrt:False +precision:fp32 +image_dir:./dataset/ILSVRC2012/val/ILSVRC2012_val_00000001.JPEG +benchmark:False +generate_yaml_cmd:python3.7 test_tipc/generate_cpp_yaml.py diff --git a/test_tipc/config/PPLCNet/PPLCNet_x1_0_KL_linux_gpu_normal_normal_serving_cpp_linux_gpu_cpu.txt b/test_tipc/config/PPLCNet/PPLCNet_x1_0_KL_linux_gpu_normal_normal_serving_cpp_linux_gpu_cpu.txt new file mode 100644 index 0000000000000000000000000000000000000000..d923f9b502268027661b176f84998c00fe9147c0 --- /dev/null +++ b/test_tipc/config/PPLCNet/PPLCNet_x1_0_KL_linux_gpu_normal_normal_serving_cpp_linux_gpu_cpu.txt @@ -0,0 +1,14 @@ +===========================serving_params=========================== +model_name:PPLCNet_x1_0_KL +python:python3.7 +inference_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/slim_model/PPLCNet_x1_0_kl_quant_infer.tar +trans_model:-m paddle_serving_client.convert +--dirname:./deploy/paddleserving/PPLCNet_x1_0_kl_quant_infer/ +--model_filename:inference.pdmodel +--params_filename:inference.pdiparams +--serving_server:./deploy/paddleserving/PPLCNet_x1_0_kl_quant_serving/ +--serving_client:./deploy/paddleserving/PPLCNet_x1_0_kl_quant_client/ +serving_dir:./deploy/paddleserving +web_service:null +--use_gpu:0|null +pipline:test_cpp_serving_client.py diff --git a/test_tipc/config/PPLCNet/PPLCNet_x1_0_KL_linux_gpu_normal_normal_serving_python_linux_gpu_cpu.txt b/test_tipc/config/PPLCNet/PPLCNet_x1_0_KL_linux_gpu_normal_normal_serving_python_linux_gpu_cpu.txt new file mode 100644 index 0000000000000000000000000000000000000000..8e18074aaa7c9ba665a2da5ae1d304a19abd551d --- /dev/null +++ b/test_tipc/config/PPLCNet/PPLCNet_x1_0_KL_linux_gpu_normal_normal_serving_python_linux_gpu_cpu.txt @@ -0,0 +1,14 @@ +===========================serving_params=========================== +model_name:PPLCNet_x1_0_KL +python:python3.7 +inference_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/slim_model/PPLCNet_x1_0_kl_quant_infer.tar +trans_model:-m paddle_serving_client.convert +--dirname:./deploy/paddleserving/PPLCNet_x1_0_kl_quant_infer/ +--model_filename:inference.pdmodel +--params_filename:inference.pdiparams +--serving_server:./deploy/paddleserving/PPLCNet_x1_0_kl_quant_serving/ +--serving_client:./deploy/paddleserving/PPLCNet_x1_0_kl_quant_client/ +serving_dir:./deploy/paddleserving +web_service:classification_web_service.py +--use_gpu:0|null +pipline:pipeline_http_client.py diff --git a/test_tipc/config/PPLCNetV2/PPLCNetV2_base_KL_linux_gpu_normal_normal_infer_cpp_linux_gpu_cpu.txt b/test_tipc/config/PPLCNetV2/PPLCNetV2_base_KL_linux_gpu_normal_normal_infer_cpp_linux_gpu_cpu.txt new file mode 100644 index 0000000000000000000000000000000000000000..1700fcd138a7d45f8fc9ee3f95bcf381620504c4 --- /dev/null +++ b/test_tipc/config/PPLCNetV2/PPLCNetV2_base_KL_linux_gpu_normal_normal_infer_cpp_linux_gpu_cpu.txt @@ -0,0 +1,18 @@ +===========================cpp_infer_params=========================== +model_name:PPLCNetV2_base_KL +cpp_infer_type:cls +cls_inference_model_dir:./PPLCNetV2_base_kl_quant_infer/ +det_inference_model_dir: +cls_inference_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/slim_model/PPLCNetV2_base_kl_quant_infer.tar +det_inference_url: +infer_quant:False +inference_cmd:./deploy/cpp/build/clas_system -c inference_cls.yaml +use_gpu:True|False +enable_mkldnn:False +cpu_threads:1 +batch_size:1 +use_tensorrt:False +precision:fp32 +image_dir:./dataset/ILSVRC2012/val/ILSVRC2012_val_00000001.JPEG +benchmark:False +generate_yaml_cmd:python3.7 test_tipc/generate_cpp_yaml.py diff --git a/test_tipc/config/PPLCNetV2/PPLCNetV2_base_KL_linux_gpu_normal_normal_serving_cpp_linux_gpu_cpu.txt b/test_tipc/config/PPLCNetV2/PPLCNetV2_base_KL_linux_gpu_normal_normal_serving_cpp_linux_gpu_cpu.txt new file mode 100644 index 0000000000000000000000000000000000000000..d444589b1808c687533e83849f3b3aae8ff74e8b --- /dev/null +++ b/test_tipc/config/PPLCNetV2/PPLCNetV2_base_KL_linux_gpu_normal_normal_serving_cpp_linux_gpu_cpu.txt @@ -0,0 +1,14 @@ +===========================serving_params=========================== +model_name:PPLCNetV2_base_KL +python:python3.7 +inference_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/slim_model/PPLCNetV2_base_kl_quant_infer.tar +trans_model:-m paddle_serving_client.convert +--dirname:./deploy/paddleserving/PPLCNetV2_base_kl_quant_infer/ +--model_filename:inference.pdmodel +--params_filename:inference.pdiparams +--serving_server:./deploy/paddleserving/PPLCNetV2_base_kl_quant_serving/ +--serving_client:./deploy/paddleserving/PPLCNetV2_base_kl_quant_client/ +serving_dir:./deploy/paddleserving +web_service:null +--use_gpu:0|null +pipline:test_cpp_serving_client.py diff --git a/test_tipc/config/PPLCNetV2/PPLCNetV2_base_KL_linux_gpu_normal_normal_serving_python_linux_gpu_cpu.txt b/test_tipc/config/PPLCNetV2/PPLCNetV2_base_KL_linux_gpu_normal_normal_serving_python_linux_gpu_cpu.txt new file mode 100644 index 0000000000000000000000000000000000000000..b909c073802ce92000ecaee8c044824ba2a7618b --- /dev/null +++ b/test_tipc/config/PPLCNetV2/PPLCNetV2_base_KL_linux_gpu_normal_normal_serving_python_linux_gpu_cpu.txt @@ -0,0 +1,14 @@ +===========================serving_params=========================== +model_name:PPLCNetV2_base_KL +python:python3.7 +inference_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/slim_model/PPLCNetV2_base_kl_quant_infer.tar +trans_model:-m paddle_serving_client.convert +--dirname:./deploy/paddleserving/PPLCNetV2_base_kl_quant_infer/ +--model_filename:inference.pdmodel +--params_filename:inference.pdiparams +--serving_server:./deploy/paddleserving/PPLCNetV2_base_kl_quant_serving/ +--serving_client:./deploy/paddleserving/PPLCNetV2_base_kl_quant_client/ +serving_dir:./deploy/paddleserving +web_service:classification_web_service.py +--use_gpu:0|null +pipline:pipeline_http_client.py diff --git a/test_tipc/config/ResNet/ResNet50_vd_KL_linux_gpu_normal_normal_infer_cpp_linux_gpu_cpu.txt b/test_tipc/config/ResNet/ResNet50_vd_KL_linux_gpu_normal_normal_infer_cpp_linux_gpu_cpu.txt new file mode 100644 index 0000000000000000000000000000000000000000..892b4859b1e3941c7b8ca235152f105d17d06729 --- /dev/null +++ b/test_tipc/config/ResNet/ResNet50_vd_KL_linux_gpu_normal_normal_infer_cpp_linux_gpu_cpu.txt @@ -0,0 +1,18 @@ +===========================cpp_infer_params=========================== +model_name:ResNet50_vd_KL +cpp_infer_type:cls +cls_inference_model_dir:./ResNet50_vd_kl_quant_infer/ +det_inference_model_dir: +cls_inference_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/slim_model/ResNet50_vd_kl_quant_infer.tar +det_inference_url: +infer_quant:False +inference_cmd:./deploy/cpp/build/clas_system -c inference_cls.yaml +use_gpu:True|False +enable_mkldnn:False +cpu_threads:1 +batch_size:1 +use_tensorrt:False +precision:fp32 +image_dir:./dataset/ILSVRC2012/val/ILSVRC2012_val_00000001.JPEG +benchmark:False +generate_yaml_cmd:python3.7 test_tipc/generate_cpp_yaml.py diff --git a/test_tipc/config/ResNet/ResNet50_vd_KL_linux_gpu_normal_normal_serving_cpp_linux_gpu_cpu.txt b/test_tipc/config/ResNet/ResNet50_vd_KL_linux_gpu_normal_normal_serving_cpp_linux_gpu_cpu.txt new file mode 100644 index 0000000000000000000000000000000000000000..3e4b19b752e3f0f15fdb552a29035e055633102d --- /dev/null +++ b/test_tipc/config/ResNet/ResNet50_vd_KL_linux_gpu_normal_normal_serving_cpp_linux_gpu_cpu.txt @@ -0,0 +1,14 @@ +===========================serving_params=========================== +model_name:ResNet50_vd_KL +python:python3.7 +inference_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/slim_model/ResNet50_vd_kl_quant_infer.tar +trans_model:-m paddle_serving_client.convert +--dirname:./deploy/paddleserving/ResNet50_vd_kl_quant_infer/ +--model_filename:inference.pdmodel +--params_filename:inference.pdiparams +--serving_server:./deploy/paddleserving/ResNet50_vd_kl_quant_serving/ +--serving_client:./deploy/paddleserving/ResNet50_vd_kl_quant_client/ +serving_dir:./deploy/paddleserving +web_service:null +--use_gpu:0|null +pipline:test_cpp_serving_client.py diff --git a/test_tipc/config/ResNet/ResNet50_vd_KL_linux_gpu_normal_normal_serving_python_linux_gpu_cpu.txt b/test_tipc/config/ResNet/ResNet50_vd_KL_linux_gpu_normal_normal_serving_python_linux_gpu_cpu.txt new file mode 100644 index 0000000000000000000000000000000000000000..236b57b03643d1e5cab743abb80dcf8cf03dc8c1 --- /dev/null +++ b/test_tipc/config/ResNet/ResNet50_vd_KL_linux_gpu_normal_normal_serving_python_linux_gpu_cpu.txt @@ -0,0 +1,14 @@ +===========================serving_params=========================== +model_name:ResNet50_vd_KL +python:python3.7 +inference_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/slim_model/ResNet50_vd_kl_quant_infer.tar +trans_model:-m paddle_serving_client.convert +--dirname:./deploy/paddleserving/ResNet50_vd_kl_quant_infer/ +--model_filename:inference.pdmodel +--params_filename:inference.pdiparams +--serving_server:./deploy/paddleserving/ResNet50_vd_kl_quant_serving/ +--serving_client:./deploy/paddleserving/ResNet50_vd_kl_quant_client/ +serving_dir:./deploy/paddleserving +web_service:classification_web_service.py +--use_gpu:0|null +pipline:pipeline_http_client.py diff --git a/test_tipc/config/SwinTransformer/SwinTransformer_tiny_patch4_window7_224_KL_linux_gpu_normal_normal_infer_cpp_linux_gpu_cpu.txt b/test_tipc/config/SwinTransformer/SwinTransformer_tiny_patch4_window7_224_KL_linux_gpu_normal_normal_infer_cpp_linux_gpu_cpu.txt new file mode 100644 index 0000000000000000000000000000000000000000..7282e64bd9b5cbf588c395fd5997a8702a5f078f --- /dev/null +++ b/test_tipc/config/SwinTransformer/SwinTransformer_tiny_patch4_window7_224_KL_linux_gpu_normal_normal_infer_cpp_linux_gpu_cpu.txt @@ -0,0 +1,18 @@ +===========================cpp_infer_params=========================== +model_name:SwinTransformer_tiny_patch4_window7_224_KL +cpp_infer_type:cls +cls_inference_model_dir:./SwinTransformer_tiny_patch4_window7_224_kl_quant_infer/ +det_inference_model_dir: +cls_inference_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/slim_model/SwinTransformer_tiny_patch4_window7_224_kl_quant_infer.tar +det_inference_url: +infer_quant:False +inference_cmd:./deploy/cpp/build/clas_system -c inference_cls.yaml +use_gpu:True|False +enable_mkldnn:False +cpu_threads:1 +batch_size:1 +use_tensorrt:False +precision:fp32 +image_dir:./dataset/ILSVRC2012/val/ILSVRC2012_val_00000001.JPEG +benchmark:False +generate_yaml_cmd:python3.7 test_tipc/generate_cpp_yaml.py diff --git a/test_tipc/config/SwinTransformer/SwinTransformer_tiny_patch4_window7_224_KL_linux_gpu_normal_normal_serving_cpp_linux_gpu_cpu.txt b/test_tipc/config/SwinTransformer/SwinTransformer_tiny_patch4_window7_224_KL_linux_gpu_normal_normal_serving_cpp_linux_gpu_cpu.txt new file mode 100644 index 0000000000000000000000000000000000000000..efa3cd2065cda78fddb0cea1f8dadadf2632fc50 --- /dev/null +++ b/test_tipc/config/SwinTransformer/SwinTransformer_tiny_patch4_window7_224_KL_linux_gpu_normal_normal_serving_cpp_linux_gpu_cpu.txt @@ -0,0 +1,14 @@ +===========================serving_params=========================== +model_name:SwinTransformer_tiny_patch4_window7_224_KL +python:python3.7 +inference_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/slim_model/SwinTransformer_tiny_patch4_window7_224_kl_quant_infer.tar +trans_model:-m paddle_serving_client.convert +--dirname:./deploy/paddleserving/SwinTransformer_tiny_patch4_window7_224_kl_quant_infer/ +--model_filename:inference.pdmodel +--params_filename:inference.pdiparams +--serving_server:./deploy/paddleserving/SwinTransformer_tiny_patch4_window7_224_kl_quant_serving/ +--serving_client:./deploy/paddleserving/SwinTransformer_tiny_patch4_window7_224_kl_quant_client/ +serving_dir:./deploy/paddleserving +web_service:null +--use_gpu:0|null +pipline:test_cpp_serving_client.py diff --git a/test_tipc/config/SwinTransformer/SwinTransformer_tiny_patch4_window7_224_KL_linux_gpu_normal_normal_serving_python_linux_gpu_cpu.txt b/test_tipc/config/SwinTransformer/SwinTransformer_tiny_patch4_window7_224_KL_linux_gpu_normal_normal_serving_python_linux_gpu_cpu.txt new file mode 100644 index 0000000000000000000000000000000000000000..45486c3f6f46f377d40e55db75a3a9bd10963de6 --- /dev/null +++ b/test_tipc/config/SwinTransformer/SwinTransformer_tiny_patch4_window7_224_KL_linux_gpu_normal_normal_serving_python_linux_gpu_cpu.txt @@ -0,0 +1,14 @@ +===========================serving_params=========================== +model_name:SwinTransformer_tiny_patch4_window7_224_KL +python:python3.7 +inference_model_url:https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/slim_model/SwinTransformer_tiny_patch4_window7_224_kl_quant_infer.tar +trans_model:-m paddle_serving_client.convert +--dirname:./deploy/paddleserving/SwinTransformer_tiny_patch4_window7_224_kl_quant_infer/ +--model_filename:inference.pdmodel +--params_filename:inference.pdiparams +--serving_server:./deploy/paddleserving/SwinTransformer_tiny_patch4_window7_224_kl_quant_serving/ +--serving_client:./deploy/paddleserving/SwinTransformer_tiny_patch4_window7_224_kl_quant_client/ +serving_dir:./deploy/paddleserving +web_service:classification_web_service.py +--use_gpu:0|null +pipline:pipeline_http_client.py diff --git a/test_tipc/docs/test_inference_cpp.md b/test_tipc/docs/test_inference_cpp.md index 213959de0669f34dbb8bd51ad8fb78bff6e8e26c..5432ea454fb55c4a8d121af3f7136090ac38f23f 100644 --- a/test_tipc/docs/test_inference_cpp.md +++ b/test_tipc/docs/test_inference_cpp.md @@ -6,25 +6,31 @@ Linux GPU/CPU C++ 推理功能测试的主程序为`test_inference_cpp.sh`,可 - 推理相关: -| 算法名称 | 模型名称 | device_CPU | device_GPU | -| :----: | :----: | :----: | :----: | -| MobileNetV3 | MobileNetV3_large_x1_0 | 支持 | 支持 | -| PP-ShiTu | PPShiTu_general_rec、PPShiTu_mainbody_det | 支持 | 支持 | -| PP-ShiTu | PPShiTu_mainbody_det | 支持 | 支持 | -| PPHGNet | PPHGNet_small | 支持 | 支持 | -| PPHGNet | PPHGNet_tiny | 支持 | 支持 | -| PPLCNet | PPLCNet_x0_25 | 支持 | 支持 | -| PPLCNet | PPLCNet_x0_35 | 支持 | 支持 | -| PPLCNet | PPLCNet_x0_5 | 支持 | 支持 | -| PPLCNet | PPLCNet_x0_75 | 支持 | 支持 | -| PPLCNet | PPLCNet_x1_0 | 支持 | 支持 | -| PPLCNet | PPLCNet_x1_5 | 支持 | 支持 | -| PPLCNet | PPLCNet_x2_0 | 支持 | 支持 | -| PPLCNet | PPLCNet_x2_5 | 支持 | 支持 | -| PPLCNetV2 | PPLCNetV2_base | 支持 | 支持 | -| ResNet | ResNet50 | 支持 | 支持 | -| ResNet | ResNet50_vd | 支持 | 支持 | -| SwinTransformer | SwinTransformer_tiny_patch4_window7_224 | 支持 | 支持 | +| 算法名称 | 模型名称 | device_CPU | device_GPU | +| :-------------: | :----------------------------------------: | :--------: | :--------: | +| MobileNetV3 | MobileNetV3_large_x1_0 | 支持 | 支持 | +| MobileNetV3 | MobileNetV3_large_x1_0_KL | 支持 | 支持 | +| PP-ShiTu | PPShiTu_general_rec、PPShiTu_mainbody_det | 支持 | 支持 | +| PP-ShiTu | GeneralRecognition_PPLCNet_x2_5_KL | 支持 | 支持 | +| PPHGNet | PPHGNet_small | 支持 | 支持 | +| PPHGNet | PPHGNet_small_KL | 支持 | 支持 | +| PPHGNet | PPHGNet_tiny | 支持 | 支持 | +| PPLCNet | PPLCNet_x0_25 | 支持 | 支持 | +| PPLCNet | PPLCNet_x0_35 | 支持 | 支持 | +| PPLCNet | PPLCNet_x0_5 | 支持 | 支持 | +| PPLCNet | PPLCNet_x0_75 | 支持 | 支持 | +| PPLCNet | PPLCNet_x1_0 | 支持 | 支持 | +| PPLCNet | PPLCNet_x1_0_KL | 支持 | 支持 | +| PPLCNet | PPLCNet_x1_5 | 支持 | 支持 | +| PPLCNet | PPLCNet_x2_0 | 支持 | 支持 | +| PPLCNet | PPLCNet_x2_5 | 支持 | 支持 | +| PPLCNetV2 | PPLCNetV2_base | 支持 | 支持 | +| PPLCNetV2 | PPLCNetV2_base_KL | 支持 | 支持 | +| ResNet | ResNet50 | 支持 | 支持 | +| ResNet | ResNet50_vd | 支持 | 支持 | +| ResNet | ResNet50_vd_KL | 支持 | 支持 | +| SwinTransformer | SwinTransformer_tiny_patch4_window7_224 | 支持 | 支持 | +| SwinTransformer | SwinTransformer_tiny_patch4_window7_224_KL | 支持 | 支持 | ## 2. 测试流程(以**ResNet50**为例) @@ -167,11 +173,11 @@ build/paddle_inference_install_dir/ * [Paddle预测库官网](https://paddleinference.paddlepaddle.org.cn/user_guides/download_lib.html)上提供了不同cuda版本的Linux预测库,可以在官网查看并选择合适的预测库版本。 - 以`manylinux_cuda11.1_cudnn8.1_avx_mkl_trt7_gcc8.2`版本为例,使用下述命令下载并解压: + 以`manylinux_cuda10.1_cudnn7.6_avx_mkl_trt6_gcc8.2`版本为例,使用下述命令下载并解压: ```shell -wget https://paddle-inference-lib.bj.bcebos.com/2.2.2/cxx_c/Linux/GPU/x86-64_gcc8.2_avx_mkl_cuda11.1_cudnn8.1.1_trt7.2.3.4/paddle_inference.tgz +wget https://paddle-inference-lib.bj.bcebos.com/2.2.2/cxx_c/Linux/GPU/x86-64_gcc8.2_avx_mkl_cuda10.1_cudnn7.6.5_trt6.0.1.5/paddle_inference.tgz tar -xvf paddle_inference.tgz ``` @@ -242,20 +248,20 @@ bash test_tipc/prepare.sh test_tipc/config/ResNet/ResNet50_linux_gpu_normal_norm 测试方法如下所示,希望测试不同的模型文件,只需更换为自己的参数配置文件,即可完成对应模型的测试。 ```shell -bash test_tipc/test_inference_cpp.sh ${your_params_file} +bash test_tipc/test_inference_cpp.sh ${your_params_file} cpp_infer ``` 以`ResNet50`的`Linux GPU/CPU C++推理测试`为例,命令如下所示。 ```shell -bash test_tipc/test_inference_cpp.sh test_tipc/config/ResNet/ResNet50_linux_gpu_normal_normal_infer_cpp_linux_gpu_cpu.txt +bash test_tipc/test_inference_cpp.sh test_tipc/config/ResNet/ResNet50_linux_gpu_normal_normal_infer_cpp_linux_gpu_cpu.txt cpp_infer ``` 输出结果如下,表示命令运行成功。 ```shell -Run successfully with command - ./deploy/cpp/build/clas_system -c inference_cls.yaml > ./test_tipc/output/ResNet50/cls_cpp_infer_gpu_usetrt_False_precision_fp32_batchsize_1.log 2>&1! -Run successfully with command - ./deploy/cpp/build/clas_system -c inference_cls.yaml > ./test_tipc/output/ResNet50/cls_cpp_infer_cpu_usemkldnn_False_threads_1_precision_fp32_batchsize_1.log 2>&1! +Run successfully with command - ResNet50 - ./deploy/cpp/build/clas_system -c inference_cls.yaml > ./test_tipc/output/ResNet50/cpp_infer/cpp_infer_gpu_usetrt_False_precision_fp32_batchsize_1.log 2>&1! +Run successfully with command - ResNet50 - ./deploy/cpp/build/clas_system -c inference_cls.yaml > ./test_tipc/output/ResNet50/cpp_infer/cpp_infer_cpu_usemkldnn_False_threads_1_precision_fp32_batchsize_1.log 2>&1! ``` 最终log中会打印出结果,如下所示 @@ -306,6 +312,6 @@ Current total inferen time cost: 5449.39 ms. Top5: class_id: 265, score: 0.0420, label: toy poodle ``` -详细log位于`./test_tipc/output/ResNet50/cls_cpp_infer_gpu_usetrt_False_precision_fp32_batchsize_1.log`和`./test_tipc/output/ResNet50/cls_cpp_infer_cpu_usemkldnn_False_threads_1_precision_fp32_batchsize_1.log`中。 +详细log位于`./test_tipc/output/ResNet50/cpp_infer/cpp_infer_gpu_usetrt_False_precision_fp32_batchsize_1.log`和`./test_tipc/output/ResNet50/cpp_infer_cpu_usemkldnn_False_threads_1_precision_fp32_batchsize_1.log`中。 如果运行失败,也会在终端中输出运行失败的日志信息以及对应的运行命令。可以基于该命令,分析运行失败的原因。 diff --git a/test_tipc/docs/test_serving_infer_cpp.md b/test_tipc/docs/test_serving_infer_cpp.md index df13c2b26272dc1fdd4262f09f2e7bcd4978a114..370f96a2076564df2e36d3b0110e7e73e70295eb 100644 --- a/test_tipc/docs/test_serving_infer_cpp.md +++ b/test_tipc/docs/test_serving_infer_cpp.md @@ -7,24 +7,31 @@ Linux GPU/CPU C++ 服务化部署测试的主程序为`test_serving_infer_cpp.sh - 推理相关: -| 算法名称 | 模型名称 | device_CPU | device_GPU | -| :-------------: | :---------------------------------------: | :--------: | :--------: | -| MobileNetV3 | MobileNetV3_large_x1_0 | 支持 | 支持 | -| PP-ShiTu | PPShiTu_general_rec、PPShiTu_mainbody_det | 支持 | 支持 | -| PPHGNet | PPHGNet_small | 支持 | 支持 | -| PPHGNet | PPHGNet_tiny | 支持 | 支持 | -| PPLCNet | PPLCNet_x0_25 | 支持 | 支持 | -| PPLCNet | PPLCNet_x0_35 | 支持 | 支持 | -| PPLCNet | PPLCNet_x0_5 | 支持 | 支持 | -| PPLCNet | PPLCNet_x0_75 | 支持 | 支持 | -| PPLCNet | PPLCNet_x1_0 | 支持 | 支持 | -| PPLCNet | PPLCNet_x1_5 | 支持 | 支持 | -| PPLCNet | PPLCNet_x2_0 | 支持 | 支持 | -| PPLCNet | PPLCNet_x2_5 | 支持 | 支持 | -| PPLCNetV2 | PPLCNetV2_base | 支持 | 支持 | -| ResNet | ResNet50 | 支持 | 支持 | -| ResNet | ResNet50_vd | 支持 | 支持 | -| SwinTransformer | SwinTransformer_tiny_patch4_window7_224 | 支持 | 支持 | +| 算法名称 | 模型名称 | device_CPU | device_GPU | +| :-------------: | :----------------------------------------: | :--------: | :--------: | +| MobileNetV3 | MobileNetV3_large_x1_0 | 支持 | 支持 | +| MobileNetV3 | MobileNetV3_large_x1_0_KL | 支持 | 支持 | +| PP-ShiTu | PPShiTu_general_rec、PPShiTu_mainbody_det | 支持 | 支持 | +| PP-ShiTu | GeneralRecognition_PPLCNet_x2_5_KL | 支持 | 支持 | +| PPHGNet | PPHGNet_small | 支持 | 支持 | +| PPHGNet | PPHGNet_small_KL | 支持 | 支持 | +| PPHGNet | PPHGNet_tiny | 支持 | 支持 | +| PPLCNet | PPLCNet_x0_25 | 支持 | 支持 | +| PPLCNet | PPLCNet_x0_35 | 支持 | 支持 | +| PPLCNet | PPLCNet_x0_5 | 支持 | 支持 | +| PPLCNet | PPLCNet_x0_75 | 支持 | 支持 | +| PPLCNet | PPLCNet_x1_0 | 支持 | 支持 | +| PPLCNet | PPLCNet_x1_0_KL | 支持 | 支持 | +| PPLCNet | PPLCNet_x1_5 | 支持 | 支持 | +| PPLCNet | PPLCNet_x2_0 | 支持 | 支持 | +| PPLCNet | PPLCNet_x2_5 | 支持 | 支持 | +| PPLCNetV2 | PPLCNetV2_base | 支持 | 支持 | +| PPLCNetV2 | PPLCNetV2_base_KL | 支持 | 支持 | +| ResNet | ResNet50 | 支持 | 支持 | +| ResNet | ResNet50_vd | 支持 | 支持 | +| ResNet | ResNet50_vd_KL | 支持 | 支持 | +| SwinTransformer | SwinTransformer_tiny_patch4_window7_224 | 支持 | 支持 | +| SwinTransformer | SwinTransformer_tiny_patch4_window7_224_KL | 支持 | 支持 | ## 2. 测试流程 diff --git a/test_tipc/docs/test_serving_infer_python.md b/test_tipc/docs/test_serving_infer_python.md index 1e802d3ff4fa11b70dedd603a8deea8fd7ab846d..3662563fe644920e6f0ed19970cac8723f5ddb6e 100644 --- a/test_tipc/docs/test_serving_infer_python.md +++ b/test_tipc/docs/test_serving_infer_python.md @@ -7,24 +7,31 @@ Linux GPU/CPU PYTHON 服务化部署测试的主程序为`test_serving_infer_pyt - 推理相关: -| 算法名称 | 模型名称 | device_CPU | device_GPU | -| :-------------: | :---------------------------------------: | :--------: | :--------: | -| MobileNetV3 | MobileNetV3_large_x1_0 | 支持 | 支持 | -| PP-ShiTu | PPShiTu_general_rec、PPShiTu_mainbody_det | 支持 | 支持 | -| PPHGNet | PPHGNet_small | 支持 | 支持 | -| PPHGNet | PPHGNet_tiny | 支持 | 支持 | -| PPLCNet | PPLCNet_x0_25 | 支持 | 支持 | -| PPLCNet | PPLCNet_x0_35 | 支持 | 支持 | -| PPLCNet | PPLCNet_x0_5 | 支持 | 支持 | -| PPLCNet | PPLCNet_x0_75 | 支持 | 支持 | -| PPLCNet | PPLCNet_x1_0 | 支持 | 支持 | -| PPLCNet | PPLCNet_x1_5 | 支持 | 支持 | -| PPLCNet | PPLCNet_x2_0 | 支持 | 支持 | -| PPLCNet | PPLCNet_x2_5 | 支持 | 支持 | -| PPLCNetV2 | PPLCNetV2_base | 支持 | 支持 | -| ResNet | ResNet50 | 支持 | 支持 | -| ResNet | ResNet50_vd | 支持 | 支持 | -| SwinTransformer | SwinTransformer_tiny_patch4_window7_224 | 支持 | 支持 | +| 算法名称 | 模型名称 | device_CPU | device_GPU | +| :-------------: | :----------------------------------------: | :--------: | :--------: | +| MobileNetV3 | MobileNetV3_large_x1_0 | 支持 | 支持 | +| MobileNetV3 | MobileNetV3_large_x1_0_KL | 支持 | 支持 | +| PP-ShiTu | PPShiTu_general_rec、PPShiTu_mainbody_det | 支持 | 支持 | +| PP-ShiTu | GeneralRecognition_PPLCNet_x2_5_KL | 支持 | 支持 | +| PPHGNet | PPHGNet_small | 支持 | 支持 | +| PPHGNet | PPHGNet_small_KL | 支持 | 支持 | +| PPHGNet | PPHGNet_tiny | 支持 | 支持 | +| PPLCNet | PPLCNet_x0_25 | 支持 | 支持 | +| PPLCNet | PPLCNet_x0_35 | 支持 | 支持 | +| PPLCNet | PPLCNet_x0_5 | 支持 | 支持 | +| PPLCNet | PPLCNet_x0_75 | 支持 | 支持 | +| PPLCNet | PPLCNet_x1_0 | 支持 | 支持 | +| PPLCNet | PPLCNet_x1_0_KL | 支持 | 支持 | +| PPLCNet | PPLCNet_x1_5 | 支持 | 支持 | +| PPLCNet | PPLCNet_x2_0 | 支持 | 支持 | +| PPLCNet | PPLCNet_x2_5 | 支持 | 支持 | +| PPLCNetV2 | PPLCNetV2_base | 支持 | 支持 | +| PPLCNetV2 | PPLCNetV2_base_KL | 支持 | 支持 | +| ResNet | ResNet50 | 支持 | 支持 | +| ResNet | ResNet50_vd | 支持 | 支持 | +| ResNet | ResNet50_vd_KL | 支持 | 支持 | +| SwinTransformer | SwinTransformer_tiny_patch4_window7_224 | 支持 | 支持 | +| SwinTransformer | SwinTransformer_tiny_patch4_window7_224_KL | 支持 | 支持 | ## 2. 测试流程 diff --git a/test_tipc/prepare.sh b/test_tipc/prepare.sh index e0908d76c5f41fd32d8c1d6a282e7fe01d675753..aa1d44fda2bb71ca06f0cdd27bb4be18909f6b8b 100644 --- a/test_tipc/prepare.sh +++ b/test_tipc/prepare.sh @@ -83,6 +83,17 @@ if [[ ${MODE} = "cpp_infer" ]]; then popd echo "################### build opencv finished ###################" fi + if [[ ! -d "./deploy/cpp/paddle_inference/" ]]; then + pushd ./deploy/cpp/ + PADDLEInfer=$3 + if [ "" = "$PADDLEInfer" ];then + wget -nc https://paddle-inference-lib.bj.bcebos.com/2.2.2/cxx_c/Linux/GPU/x86-64_gcc8.2_avx_mkl_cuda10.1_cudnn7.6.5_trt6.0.1.5/paddle_inference.tgz --no-check-certificate + else + wget -nc ${PADDLEInfer} --no-check-certificate + fi + tar xf paddle_inference.tgz + popd + fi if [[ $FILENAME == *infer_cpp_linux_gpu_cpu.txt ]]; then cpp_type=$(func_parser_value "${lines[2]}") cls_inference_model_dir=$(func_parser_value "${lines[3]}") @@ -92,7 +103,9 @@ if [[ ${MODE} = "cpp_infer" ]]; then if [[ $cpp_type == "cls" ]]; then eval "wget -nc $cls_inference_url" - tar xf "${model_name}_infer.tar" + tar_name=$(func_get_url_file_name "$cls_inference_url") + model_dir=${tar_name%.*} + eval "tar xf ${tar_name}" cd dataset rm -rf ILSVRC2012 @@ -200,7 +213,7 @@ fi if [[ ${MODE} = "serving_infer" ]]; then # prepare serving env python_name=$(func_parser_value "${lines[2]}") - if [[ ${model_name} =~ "ShiTu" ]]; then + if [[ ${model_name} = "PPShiTu" ]]; then cls_inference_model_url=$(func_parser_value "${lines[3]}") cls_tar_name=$(func_get_url_file_name "${cls_inference_model_url}") det_inference_model_url=$(func_parser_value "${lines[4]}") diff --git a/test_tipc/test_inference_cpp.sh b/test_tipc/test_inference_cpp.sh index abba66503f0ceede4cc17f0d3fb93811a4f50a11..255e0839a5d2541cd01018b4a09922af677edf80 100644 --- a/test_tipc/test_inference_cpp.sh +++ b/test_tipc/test_inference_cpp.sh @@ -2,10 +2,17 @@ source test_tipc/common_func.sh FILENAME=$1 -GPUID=$2 +MODE=$2 + +# set cuda device +GPUID=$3 if [[ ! $GPUID ]];then GPUID=0 fi +env="export CUDA_VISIBLE_DEVICES=${GPUID}" +set CUDA_VISIBLE_DEVICES +eval $env + dataline=$(awk 'NR==1, NR==19{print}' $FILENAME) # parser params @@ -30,7 +37,7 @@ cpp_benchmark_value=$(func_parser_value "${lines[16]}") generate_yaml_cmd=$(func_parser_value "${lines[17]}") transform_index_cmd=$(func_parser_value "${lines[18]}") -LOG_PATH="./test_tipc/output/${model_name}" +LOG_PATH="./test_tipc/output/${model_name}/${MODE}" mkdir -p ${LOG_PATH} status_log="${LOG_PATH}/results_cpp.log" # generate_yaml_cmd="python3 test_tipc/generate_cpp_yaml.py" @@ -56,7 +63,7 @@ function func_shitu_cpp_inference(){ if [ ${use_mkldnn} = "False" ] && [ ${_flag_quant} = "True" ]; then precison="int8" fi - _save_log_path="${_log_path}/shitu_cpp_infer_cpu_usemkldnn_${use_mkldnn}_threads_${threads}_precision_${precision}_batchsize_${batch_size}.log" + _save_log_path="${_log_path}/cpp_infer_cpu_usemkldnn_${use_mkldnn}_threads_${threads}_precision_${precision}_batchsize_${batch_size}.log" eval $transform_index_cmd command="${generate_yaml_cmd} --type shitu --batch_size ${batch_size} --mkldnn ${use_mkldnn} --gpu ${use_gpu} --cpu_thread ${threads} --tensorrt False --precision ${precision} --data_dir ${_img_dir} --benchmark True --cls_model_dir ${cpp_infer_model_dir} --det_model_dir ${cpp_det_infer_model_dir} --gpu_id ${GPUID}" eval $command @@ -80,7 +87,7 @@ function func_shitu_cpp_inference(){ continue fi for batch_size in ${cpp_batch_size_list[*]}; do - _save_log_path="${_log_path}/shitu_cpp_infer_gpu_usetrt_${use_trt}_precision_${precision}_batchsize_${batch_size}.log" + _save_log_path="${_log_path}/cpp_infer_gpu_usetrt_${use_trt}_precision_${precision}_batchsize_${batch_size}.log" eval $transform_index_cmd command="${generate_yaml_cmd} --type shitu --batch_size ${batch_size} --mkldnn False --gpu ${use_gpu} --cpu_thread 1 --tensorrt ${use_trt} --precision ${precision} --data_dir ${_img_dir} --benchmark True --cls_model_dir ${cpp_infer_model_dir} --det_model_dir ${cpp_det_infer_model_dir} --gpu_id ${GPUID}" eval $command @@ -118,7 +125,7 @@ function func_cls_cpp_inference(){ if [ ${use_mkldnn} = "False" ] && [ ${_flag_quant} = "True" ]; then precison="int8" fi - _save_log_path="${_log_path}/cls_cpp_infer_cpu_usemkldnn_${use_mkldnn}_threads_${threads}_precision_${precision}_batchsize_${batch_size}.log" + _save_log_path="${_log_path}/cpp_infer_cpu_usemkldnn_${use_mkldnn}_threads_${threads}_precision_${precision}_batchsize_${batch_size}.log" command="${generate_yaml_cmd} --type cls --batch_size ${batch_size} --mkldnn ${use_mkldnn} --gpu ${use_gpu} --cpu_thread ${threads} --tensorrt False --precision ${precision} --data_dir ${_img_dir} --benchmark True --cls_model_dir ${cpp_infer_model_dir} --gpu_id ${GPUID}" eval $command @@ -142,7 +149,7 @@ function func_cls_cpp_inference(){ continue fi for batch_size in ${cpp_batch_size_list[*]}; do - _save_log_path="${_log_path}/cls_cpp_infer_gpu_usetrt_${use_trt}_precision_${precision}_batchsize_${batch_size}.log" + _save_log_path="${_log_path}/cpp_infer_gpu_usetrt_${use_trt}_precision_${precision}_batchsize_${batch_size}.log" command="${generate_yaml_cmd} --type cls --batch_size ${batch_size} --mkldnn False --gpu ${use_gpu} --cpu_thread 1 --tensorrt ${use_trt} --precision ${precision} --data_dir ${_img_dir} --benchmark True --cls_model_dir ${cpp_infer_model_dir} --gpu_id ${GPUID}" eval $command command="${_script} > ${_save_log_path} 2>&1" @@ -235,18 +242,6 @@ cd ../../../ # cd ../../ echo "################### build PaddleClas demo finished ###################" - -# set cuda device -# GPUID=$2 -# if [ ${#GPUID} -le 0 ];then -# env="export CUDA_VISIBLE_DEVICES=0" -# else -# env="export CUDA_VISIBLE_DEVICES=${GPUID}" -# fi -# set CUDA_VISIBLE_DEVICES -# eval $env - - echo "################### run test ###################" export Count=0 IFS="|" diff --git a/test_tipc/test_serving_infer_python.sh b/test_tipc/test_serving_infer_python.sh index 6141e11086008215903a2f87ba8ca1d69fd518b3..356d03216ddbe90f5d30e90afb591cf476b84e2c 100644 --- a/test_tipc/test_serving_infer_python.sh +++ b/test_tipc/test_serving_infer_python.sh @@ -310,7 +310,7 @@ echo "################### run test ###################" export Count=0 IFS="|" -if [[ ${model_name} =~ "ShiTu" ]]; then +if [[ ${model_name} = "PPShiTu" ]]; then func_serving_rec else func_serving_cls