From 3fd98087935c4a5b4d3de96f3103ffa576959c01 Mon Sep 17 00:00:00 2001 From: gaotingquan Date: Tue, 1 Nov 2022 11:57:06 +0000 Subject: [PATCH] docs: update --- docs/en/models/PP-LCNet_en.md | 501 ++++++++++++++++++++++++++-------- 1 file changed, 386 insertions(+), 115 deletions(-) diff --git a/docs/en/models/PP-LCNet_en.md b/docs/en/models/PP-LCNet_en.md index 12d43c9e..652af892 100644 --- a/docs/en/models/PP-LCNet_en.md +++ b/docs/en/models/PP-LCNet_en.md @@ -1,95 +1,57 @@ # PP-LCNet Series ---- - - -## Catalogue - -- [1. Abstract](#1) -- [2. Introduction](#2) -- [3. Method](#3) - - [3.1 Better Activation Function](#3.1) - - [3.2 SE Modules at Appropriate Positions](#3.2) - - [3.3 Larger Convolution Kernels](#3.3) - - [3.4 Larger Dimensional 1 × 1 Conv Layer after GAP](#3.4) -- [4. Experiments](#4) - - [4.1 Image Classification](#4.1) - - [4.2 Object Detection](#4.2) - - [4.3 Semantic Segmentation](#4.3) -- [5. Inference speed based on V100 GPU](#5) -- [6. Inference speed based on SD855](#6) -- [7. Conclusion](#7) -- [8. Reference](#8) - - -## 1. Abstract - -In the field of computer vision, the quality of backbone network determines the outcome of the whole vision task. In previous studies, researchers generally focus on the optimization of FLOPs or Params, but inference speed actually serves as an importance indicator of model quality in real-world scenarios. Nevertheless, it is difficult to balance inference speed and accuracy. In view of various CPU-based applications in industry, we are now working to raise the adaptability of the backbone network to Intel CPU, so as to obtain a faster and more accurate lightweight backbone network. At the same time, the performance of downstream vision tasks such as object detection and semantic segmentation are also improved. - - -## 2. Introduction -Recent years witnessed the emergence of many lightweight backbone networks. In past two years, in particular, there were abundant networks searched by NAS that either enjoy advantages on FLOPs or Params, or have an edge in terms of inference speed on ARM devices. However, few of them dedicated to specified optimization of Intel CPU, resulting their imperfect inference speed on the intel CPU side. Based on this, we specially design the backbone network PP-LCNet for Intel CPU devices with its acceleration library MKLDNN. Compared with other lightweight SOTA models, this backbone network can further improve the performance of the model without increasing the inference time, significantly outperforming the existing SOTA models. A comparison chart with other models is shown below. -![](../../images/PP-LCNet/PP-LCNet-Acc.png) +--- - -## 3. Method +- [1. Introduction](#1) + - [1.1 Model Introduction](#1.1) + - [1.2 Model Details](#1.2) + - [1.3 Result](#1.3) +- [2. Quick Start](#2) + - [2.1 PaddlePaddle Installation](#2.1) + - [2.2 PaddleClas Installation](#2.2) + - [2.3 Prediction](#2.3) +- [3. Training, Evaluation and Inference](#3) + - [3.1 Installation](#3.1) + - [3.2 Dataset](#3.2) + - [3.3 Training](#3.3) + - [3.3.1 Train ImageNet](#3.3.1) + - [3.3.2 Fine-tuning based on ImageNet weights](#3.3.2) + - [3.4 Evaluation](#3.4) + - [3.5 Inference](#3.5) +- [4. Inference Deployment](#4) + - [4.1 Getting Paddle Inference Model](#4.1) + - [4.1.1 Exporting Paddle Inference Model](#4.1.1) + - [4.1.2 Downloading Inference Model](#4.1.2) + - [4.2 Prediction with Python](#4.2) + - [4.2.1 Image Prediction](#4.2.1) + - [4.2.2 Images Prediction](#4.2.2) + - [4.3 Deployment with C++](#4.3) + - [4.4 Deployment as Service](#4.4) + - [4.5 Deployment on Mobile](#4.5) + - [4.6 Converting To ONNX and Deployment](#4.6) +- [4. Reference](#5) + + + +## 1. Introduction + +Recent years witnessed the emergence of many lightweight backbone networks. In past two years, in particular, there were abundant networks searched by NAS that either enjoy advantages on FLOPs or Params, or have an edge in terms of inference speed on ARM devices. However, few of them dedicated to specified optimization of Intel CPU, resulting their imperfect inference speed on the intel CPU side. Based on this, we specially design the backbone network PP-LCNet for Intel CPU devices with its acceleration library MKLDNN. Compared with other lightweight SOTA models, this backbone network can further improve the performance of the model without increasing the inference time, significantly outperforming the existing SOTA models. + + + +### 1.2 Model Details + +Build on extensive experiments, we found that many seemingly less time-consuming operations will increase the latency on Intel CPU-based devices, especially when the MKLDNN acceleration library is enabled. Finally, we summarized some strategies that can improve the accuracy of the model without increasing the latency and combined these four strategies to form PP-LCNet. The overall structure of the network is shown in the figure below. ![](../../images/PP-LCNet/PP-LCNet.png) -Build on extensive experiments, we found that many seemingly less time-consuming operations will increase the latency on Intel CPU-based devices, especially when the MKLDNN acceleration library is enabled. Therefore, we finally chose a block with the leanest possible structure and the fastest possible speed to form our BaseNet (similar to MobileNetV1). Based on BaseNet, we summarized four strategies that can improve the accuracy of the model without increasing the latency, and we combined these four strategies to form PP-LCNet. Each of these four strategies is introduced as below: - - -### 3.1 Better Activation Function - -Since the adoption of ReLU activation function by convolutional neural network, the network performance has been improved substantially, and variants of the ReLU activation function have appeared in recent years, such as Leaky-ReLU, P-ReLU, ELU, etc. In 2017, Google Brain searched to obtain the swish activation function, which performs well on lightweight networks. In 2019, the authors of MobileNetV3 further optimized this activation function to H-Swish, which removes the exponential operation, leading to faster speed and an almost unaffected network accuracy. After many experiments, we also recognized its excellent performance on lightweight networks. Therefore, this activation function is adopted in PP-LCNet. - - -### 3.2 SE Modules at Appropriate Positions - -The SE module is a channel attention mechanism proposed by SENet, which can effectively improve the accuracy of the model. However, on the Intel CPU side, the module also presents a large latency, leaving us the task of balancing accuracy and speed. The search of the location of the SE module in NAS search-based networks such as MobileNetV3 brings no general conclusions, but we found through our experiments that the closer the SE module is to the tail of the network the greater the improvement in model accuracy. The following table also shows some of our experimental results: + -| SE Location | Top-1 Acc(\%) | Latency(ms) | -|-------------------|---------------|-------------| -| 1100000000000 | 61.73 | 2.06 | -| 0000001100000 | 62.17 | 2.03 | -| 0000000000011 | 63.14 | 2.05 | -| 1111111111111 | 64.27 | 3.80 | +### 1.3 Result -The option in the third row of the table was chosen for the location of the SE module in PP-LCNet. - - -### 3.3 Larger Convolution Kernels - -In the paper of MixNet, the author analyzes the effect of convolutional kernel size on model performance and concludes that larger convolutional kernels within a certain range can improve the performance of the model, but beyond this range will be detrimental to the model’s performance. So the author forms MixConv with split-concat paradigm combined, which can improve the performance of the model but is not conducive to inference. We experimentally summarize the role of some larger convolutional kernels at different positions that are similar to those of the SE module, and find that larger convolutional kernels display more prominent roles in the middle and tail of the network. The following table shows the effect of the position of the 5x5 convolutional kernels on the accuracy: - -| Larger Convolution Location | Top-1 Acc(\%) | Latency(ms) | -|----------------------------|---------------|-------------| -| 1111111111111 | 63.22 | 2.08 | -| 1111111000000 | 62.70 | 2.07 | -| 0000001111111 | 63.14 | 2.05 | - - -Experiments show that a larger convolutional kernel placed at the middle and tail of the network can achieve the same accuracy as placed at all positions, coupled with faster inference. The option in the third row of the table was the final choice of PP-LCNet. - - -### 3.4 Larger Dimensional 1 × 1 Conv Layer after GAP - -Since the introduction of GoogLeNet, GAP (Global-Average-Pooling) is often directly followed by a classification layer, which fails to result in further integration and processing of features extracted after GAP in the lightweight network. If a larger 1x1 convolutional layer (equivalent to the FC layer) is used after GAP, the extracted features, instead of directly passing through the classification layer, will first be integrated, and then classified. This can greatly improve the accuracy rate without affecting the inference speed of the model. The above four improvements were made to BaseNet to obtain PP-LCNet. The following table further illustrates the impact of each scheme on the results: - -| Activation | SE-block | Large-kernal | last-1x1-conv | Top-1 Acc(\%) | Latency(ms) | -|------------|----------|--------------|---------------|---------------|-------------| -| 0 | 1 | 1 | 1 | 61.93 | 1.94 | -| 1 | 0 | 1 | 1 | 62.51 | 1.87 | -| 1 | 1 | 0 | 1 | 62.44 | 2.01 | -| 1 | 1 | 1 | 0 | 59.91 | 1.85 | -| 1 | 1 | 1 | 1 | 63.14 | 2.05 | - - -## 4. Experiments - - -### 4.1 Image Classification + +### 1.3.1 Image Classification For image classification, ImageNet dataset is adopted. Compared with the current mainstream lightweight network, PP-LCNet can obtain faster inference speed with the same accuracy. When using Baidu’s self-developed SSLD distillation strategy, the accuracy is further improved, with the Top-1 Acc of ImageNet exceeding 80% at an inference speed of about 5ms on the Intel CPU side. @@ -126,8 +88,36 @@ Performance comparison with other lightweight networks: | MobileNetV3_small_x1_25 | 3.6 | 100 | 70.67 | 89.51 | 3.95 | | PPLCNet_x1_0 | 3.0 | 161 | 71.32 | 90.03 | 2.46 | - -### 4.2 Object Detection +We also test the inference speed of PPLCNet on other devices: + +* Inference speed based on V100 GPU + +| Models | Crop Size | Resize Short Size | FP32
Batch Size=1
(ms) | FP32
Batch Size=1\4
(ms) | FP32
Batch Size=8
(ms) | +| ------------- | --------- | ----------------- | ---------------------------- | -------------------------------- | ------------------------------ | +| PPLCNet_x0_25 | 224 | 256 | 0.72 | 1.17 | 1.71 | +| PPLCNet_x0_35 | 224 | 256 | 0.69 | 1.21 | 1.82 | +| PPLCNet_x0_5 | 224 | 256 | 0.70 | 1.32 | 1.94 | +| PPLCNet_x0_75 | 224 | 256 | 0.71 | 1.49 | 2.19 | +| PPLCNet_x1_0 | 224 | 256 | 0.73 | 1.64 | 2.53 | +| PPLCNet_x1_5 | 224 | 256 | 0.82 | 2.06 | 3.12 | +| PPLCNet_x2_0 | 224 | 256 | 0.94 | 2.58 | 4.08 | + +* Inference speed based on SD855 + +| Models | SD855 time(ms)
bs=1, thread=1 | SD855 time(ms)
bs=1, thread=2 | SD855 time(ms)
bs=1, thread=4 | +| ------------- | -------------------------------- | --------------------------------- | --------------------------------- | +| PPLCNet_x0_25 | 2.30 | 1.62 | 1.32 | +| PPLCNet_x0_35 | 3.15 | 2.11 | 1.64 | +| PPLCNet_x0_5 | 4.27 | 2.73 | 1.92 | +| PPLCNet_x0_75 | 7.38 | 4.51 | 2.91 | +| PPLCNet_x1_0 | 10.78 | 6.49 | 3.98 | +| PPLCNet_x1_5 | 20.55 | 12.26 | 7.54 | +| PPLCNet_x2_0 | 33.79 | 20.17 | 12.10 | +| PPLCNet_x2_5 | 49.89 | 29.60 | 17.82 | + + + +### 1.3.2 Object Detection For object detection, we adopt Baidu’s self-developed PicoDet, which focuses on lightweight object detection scenarios. The following table shows the comparison between the results of PP-LCNet and MobileNetV3 on the COCO dataset. PP-LCNet has an obvious advantage in both accuracy and speed. @@ -138,8 +128,9 @@ MobileNetV3_large_x0_35 | 19.2 | 8.1 | MobileNetV3_large_x0_75 | 25.8 | 11.1 | PPLCNet_x1_0 | 26.9 | 7.9 | - -### 4.3 Semantic Segmentation + + +### 1.3.3 Semantic Segmentation For semantic segmentation, DeeplabV3+ is adopted. The following table presents the comparison between PP-LCNet and MobileNetV3 on the Cityscapes dataset, and PP-LCNet also stands out in terms of accuracy and speed. @@ -150,42 +141,322 @@ MobileNetV3_large_x0_5 | 55.42 | 135 | MobileNetV3_large_x0_75 | 64.53 | 151 | PPLCNet_x1_0 | 66.03 | 96 | - -## 5. Inference speed based on V100 GPU -| Models | Crop Size | Resize Short Size | FP32
Batch Size=1
(ms) | FP32
Batch Size=1\4
(ms) | FP32
Batch Size=8
(ms) | -| ------------- | --------- | ----------------- | ---------------------------- | -------------------------------- | ------------------------------ | -| PPLCNet_x0_25 | 224 | 256 | 0.72 | 1.17 | 1.71 | -| PPLCNet_x0_35 | 224 | 256 | 0.69 | 1.21 | 1.82 | -| PPLCNet_x0_5 | 224 | 256 | 0.70 | 1.32 | 1.94 | -| PPLCNet_x0_75 | 224 | 256 | 0.71 | 1.49 | 2.19 | -| PPLCNet_x1_0 | 224 | 256 | 0.73 | 1.64 | 2.53 | -| PPLCNet_x1_5 | 224 | 256 | 0.82 | 2.06 | 3.12 | -| PPLCNet_x2_0 | 224 | 256 | 0.94 | 2.58 | 4.08 | + - +## 2. Quick Start -## 6. Inference speed based on SD855 + -| Models | SD855 time(ms)
bs=1, thread=1 | SD855 time(ms)
bs=1, thread=2 | SD855 time(ms)
bs=1, thread=4 | -| ------------- | -------------------------------- | --------------------------------- | --------------------------------- | -| PPLCNet_x0_25 | 2.30 | 1.62 | 1.32 | -| PPLCNet_x0_35 | 3.15 | 2.11 | 1.64 | -| PPLCNet_x0_5 | 4.27 | 2.73 | 1.92 | -| PPLCNet_x0_75 | 7.38 | 4.51 | 2.91 | -| PPLCNet_x1_0 | 10.78 | 6.49 | 3.98 | -| PPLCNet_x1_5 | 20.55 | 12.26 | 7.54 | -| PPLCNet_x2_0 | 33.79 | 20.17 | 12.10 | -| PPLCNet_x2_5 | 49.89 | 29.60 | 17.82 | +### 2.1 PaddlePaddle Installation + +- Run the following command to install if CUDA9 or CUDA10 is available. + +```bash +python3 -m pip install paddlepaddle-gpu -i https://mirror.baidu.com/pypi/simple +``` + +- Run the following command to install if GPU device is unavailable. + +```bash +python3 -m pip install paddlepaddle -i https://mirror.baidu.com/pypi/simple +``` + +Please refer to [PaddlePaddle Installation](https://www.paddlepaddle.org.cn/en/install/quick?docurl=/documentation/docs/en/install/pip/macos-pip_en.html) for more information about installation, for examples other versions. + + + +### 2.2 PaddleClas wheel Installation + +The command of PaddleClas installation as bellow: + +``` +pip3 install paddleclas +``` + + + +### 2.3 Prediction + +* Prediction with CLI + +```bash +paddleclas --model_name=PPLCNet_x1_0 --infer_imgs="docs/images/inference_deployment/whl_demo.jpg" +``` + +Results: +``` +>>> result +class_ids: [8, 7, 86, 81, 85], scores: [0.91347, 0.03779, 0.0036, 0.00117, 0.00112], label_names: ['hen', 'cock', 'partridge', 'ptarmigan', 'quail'], filename: docs/images/inference_deployment/whl_demo.jpg +Predict complete! +``` + +**Note**: When replacing other scale models of PPLCNet, just replace `model_name`. For example, when changing the model at this time to `PPLCNet_x0_25`, you only need to change `--model_name=PPLCNet_x1_0` to `--model_name=PPLCNet_x0_25`. + + +* Prediction in Python +```python +from paddleclas import PaddleClas +clas = PaddleClas(model_name='PPLCNet_x1_0') +infer_imgs = 'docs/images/deployment/whl_demo.jpg' +result = clas.predict(infer_imgs) +print(next(result)) +``` + +**Note**: The result returned by model.predict() is a `generator`, so you need to use the `next()` function to call it or `for loop` to loop it. And it will predict with batch_size size batch and return the prediction results when called. The default batch_size is 1, and you also specify the batch_size when instantiating, such as `model = paddleclas.PaddleClas(model_name="PPLCNet_x1_0", batch_size=2)`. + + + +## 3. Training, Evaluation and Inference + + + +### 3.1 Installation + +Please refer to [Installation](../installation/install_paddleclas_en.md) to get the description about installation. + + + +### 3.2 Dataset + +Please prepare ImageNet-1k data at [ImageNet official website](https://www.image-net.org/). + +Enter the `PaddleClas/` directory: +``` +cd path_to_PaddleClas +``` + +Enter the `dataset/` directory, name the downloaded data `ILSVRC2012` , and the `ILSVRC2012` directory has the following data: + +``` +├── train +│   ├── n01440764 +│   │   ├── n01440764_10026.JPEG +│   │   ├── n01440764_10027.JPEG +├── train_list.txt +... +├── val +│   ├── ILSVRC2012_val_00000001.JPEG +│   ├── ILSVRC2012_val_00000002.JPEG +├── val_list.txt +``` + +where `train/` and `val/` are the training set and validation set, respectively. `train_list.txt` and `val_list.txt` are the label files for the training set and validation set, respectively. + +**Note:** +* About the contents format of `train_list.txt` and `val_list.txt`, please refer to [Description about Classification Dataset in PaddleClas](../data_preparation/classification_dataset_en.md). + + + + +### 3.3 Training + + + +#### 3.3.1 Train ImageNet + +The PPLCNet_x1_0 training configuration is provided in `ppcls/configs/ImageNet/PPLCNet/PPLCNet_x1_0.yaml`, which can be started with the following script: + +```shell +export CUDA_VISIBLE_DEVICES=0,1,2,3 +python3 -m paddle.distributed.launch \ + --gpus="0,1,2,3" \ + tools/train.py \ + -c ppcls/configs/ImageNet/PPLCNet/PPLCNet_x1_0.yaml +``` + + +**Note:** + +* The current model with the best accuracy will be saved in `output/PPLCNet_x1_0/best_model.pdparams` + + + +#### 3.3.2 Fine-tuning based on ImageNet weights + +If you are not training an ImageNet task, you need to change the configuration file and training method, such as reducing the learning rate, reducing the number of epochs, etc. + + + +### 3.4 Evaluation + +After training, you can use the following commands to evaluate the model. + +```bash +python3 tools/eval.py \ + -c ppcls/configs/ImageNet/PPLCNet/PPLCNet_x1_0.yaml \ + -o Global.pretrained_model=output/PPLCNet_x1_0/best_model +``` +Among the above command, the argument `-o Global.pretrained_model="output/PPLCNet_x1_0/best_model"` specify the path of the best model weight file. You can specify other path if needed. - -## 7. Conclusion + + +### 3.5 Inference + +After the model training is completed, the pre-trained model obtained from the training can be loaded for model prediction. A complete example is provided in the `tools/infer.py` of the model library, and the model prediction can be done by simply executing the following command: + +```python +python3 tools/infer.py \ + -c ppcls/configs/ImageNet/PPLCNet/PPLCNet_x1_0.yaml \ + -o Global.pretrained_model=output/PPLCNet_x1_0/best_model +``` + +The results: +``` +[{'class_ids': [8, 7, 86, 81, 85], 'scores': [0.91347, 0.03779, 0.0036, 0.00117, 0.00112], 'file_name': 'docs/images/inference_deployment/whl_demo.jpg', 'label_names': ['hen', 'cock', 'partridge', 'ptarmigan', 'quail']}] +``` + +**Note**: + +* Among the above command, argument `-o Global.pretrained_model="output/PPLCNet_x1_0/best_model"` specify the path of the best model weight file. You can specify other path if needed. + + +* The default test image is `docs/images/inference_deployment/whl_demo.jpg` ,And you can test other image, only need to specify the argument `-o Infer.infer_imgs=path_to_test_image`. + +* The default output is the value of Top-5. If you want to output the value of Top-k, you can specify `-o Infer.PostProcess.topk=k`, where `k` is the value you specify. + +* The default label mapping is based on the ImageNet dataset. If you change the dataset, you need to re-specify `Infer.PostProcess.class_id_map_file`. For the method of making the mapping file, please refer to `ppcls/utils/imagenet1k_label_list.txt` + + + + +## 4. Inference Deployment + + + +### 4.1 Getting Paddle Inference Model + +Paddle Inference is the original Inference Library of the PaddlePaddle, provides high-performance inference for server deployment. And compared with directly based on the pretrained model, Paddle Inference can use tools to accelerate prediction, so as to achieve better inference performance. Please refer to [Paddle Inference](https://www.paddlepaddle.org.cn/documentation/docs/zh/guides/infer/inference/inference_cn.html) for more information. + +Paddle Inference need Paddle Inference Model to predict. Two process provided to get Paddle Inference Model. If want to use the provided by PaddleClas, you can download directly, click [Downloading Inference Model](#4.1.2). + + + + +### 4.1.1 Exporting Paddle Inference Model + +The command about exporting Paddle Inference Model is as follow: + +```bash +python3 tools/export_model.py \ + -c ppcls/configs/ImageNet/PPLCNet/PPLCNet_x1_0.yaml \ + -o Global.pretrained_model=output/PPLCNet_x1_0/best_model \ + -o Global.save_inference_dir=deploy/models/PPLCNet_x1_0_infer +``` -Rather than holding on to perfect FLOPs and Params as academics do, PP-LCNet focuses on analyzing how to add Intel CPU-friendly modules to improve the performance of the model, which can better balance accuracy and inference time. The experimental conclusions therein are available to other researchers in network structure design, while providing NAS search researchers with a smaller search space and general conclusions. The finished PP-LCNet can also be better accepted and applied in industry. +After running above command, the inference model files would be saved in `deploy/models/PPLCNet_x1_0_infer`, as shown below: - -## 8. Reference +``` +├── PPLCNet_x1_0_infer +│ ├── inference.pdiparams +│ ├── inference.pdiparams.info +│ └── inference.pdmodel +``` + + + + +### 4.1.2 Downloading Inference Model + +You can also download directly. + +``` +cd deploy/models +# download the inference model and decompression +wget https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/inference/PPLCNet_x1_0_infer.tar && tar -xf PPLCNet_x1_0_infer.tar +``` + +After decompression, the directory `models` should be shown below. +``` +├── PPLCNet_x1_0_infer +│ ├── inference.pdiparams +│ ├── inference.pdiparams.info +│ └── inference.pdmodel +``` + + + +### 4.2 Prediction with Python + + + + +#### 4.2.1 Image Prediction + +Return the directory `deploy`: + +``` +cd ../ +``` + +Run the following command to classify whether there are humans in the image `./images/ImageNet/ILSVRC2012_val_00000010.jpeg`. + +```shell +# Use the following command to predict with GPU. +python3 python/predict_cls.py -c configs/inference_cls.yaml -o Global.inference_model_dir=models/PPLCNet_x1_0_infer +# Use the following command to predict with CPU. +python3 python/predict_cls.py -c configs/inference_cls.yaml -o Global.inference_model_dir=models/PPLCNet_x1_0_infer -o Global.use_gpu=False +``` + +The prediction results: + +``` +ILSVRC2012_val_00000010.jpeg: class id(s): [153, 265, 204, 283, 229], score(s): [0.61, 0.11, 0.05, 0.03, 0.02], label_name(s): ['Maltese dog, Maltese terrier, Maltese', 'toy poodle', 'Lhasa, Lhasa apso', 'Persian cat', 'Old English sheepdog, bobtail'] +``` + + + +#### 4.2.2 Images Prediction + +If you want to predict images in directory, please specify the argument `Global.infer_imgs` as directory path by `-o Global.infer_imgs`. The command is as follow. + +```shell +# Use the following command to predict with GPU. If want to replace with CPU, you can add argument -o Global.use_gpu=False +python3 python/predict_cls.py -c configs/inference_cls.yaml -o Global.inference_model_dir=models/PPLCNet_x1_0_infer -o Global.infer_imgs=images/ImageNet/ +``` + +终端中会输出该文件夹内所有图像的分类结果,如下所示。 + +``` +ILSVRC2012_val_00000010.jpeg: class id(s): [153, 265, 204, 283, 229], score(s): [0.61, 0.11, 0.05, 0.03, 0.02], label_name(s): ['Maltese dog, Maltese terrier, Maltese', 'toy poodle', 'Lhasa, Lhasa apso', 'Persian cat', 'Old English sheepdog, bobtail'] +ILSVRC2012_val_00010010.jpeg: class id(s): [695, 551, 507, 531, 419], score(s): [0.11, 0.06, 0.03, 0.03, 0.03], label_name(s): ['padlock', 'face powder', 'combination lock', 'digital watch', 'Band Aid'] +ILSVRC2012_val_00020010.jpeg: class id(s): [178, 211, 209, 210, 236], score(s): [0.87, 0.03, 0.01, 0.00, 0.00], label_name(s): ['Weimaraner', 'vizsla, Hungarian pointer', 'Chesapeake Bay retriever', 'German short-haired pointer', 'Doberman, Doberman pinscher'] +ILSVRC2012_val_00030010.jpeg: class id(s): [80, 23, 93, 81, 99], score(s): [0.87, 0.01, 0.01, 0.01, 0.00], label_name(s): ['black grouse', 'vulture', 'hornbill', 'ptarmigan', 'goose'] +``` + + + +### 4.3 Deployment with C++ + +PaddleClas provides an example about how to deploy with C++. Please refer to [Deployment with C++](../inference_deployment/cpp_deploy_en.md). + + + +### 4.4 Deployment as Service + +Paddle Serving is a flexible, high-performance carrier for machine learning models, and supports different protocol, such as RESTful, gRPC, bRPC and so on, which provides different deployment solutions for a variety of heterogeneous hardware and operating system environments. Please refer [Paddle Serving](https://github.com/PaddlePaddle/Serving) for more information. + +PaddleClas provides an example about how to deploy as service by Paddle Serving. Please refer to [Paddle Serving Deployment](../inference_deployment/paddle_serving_deploy_en.md). + + + +### 4.5 Deployment on Mobile + +Paddle-Lite is an open source deep learning framework that designed to make easy to perform inference on mobile, embeded, and IoT devices. Please refer to [Paddle-Lite](https://github.com/PaddlePaddle/Paddle-Lite) for more information. + +PaddleClas provides an example of how to deploy on mobile by Paddle-Lite. Please refer to [Paddle-Lite deployment](../inference_deployment/paddle_lite_deploy_en.md). + + + +### 4.6 Converting To ONNX and Deployment + +Paddle2ONNX support convert Paddle Inference model to ONNX model. And you can deploy with ONNX model on different inference engine, such as TensorRT, OpenVINO, MNN/TNN, NCNN and so on. About Paddle2ONNX details, please refer to [Paddle2ONNX](https://github.com/PaddlePaddle/Paddle2ONNX). + +PaddleClas provides an example of how to convert Paddle Inference model to ONNX model by paddle2onnx toolkit and predict by ONNX model. You can refer to [paddle2onnx](../../../deploy/paddle2onnx/readme_en.md) for deployment details. + + +## 5. Reference Reference to cite when you use PP-LCNet in a paper: ``` -- GitLab