提交 e1800e00 编写于 作者: H HydrogenSulfate

add comment in preprocess.py and correct contents in docs

上级 8fb733ff
......@@ -176,8 +176,10 @@ class ResizeImage(object):
def __call__(self, img):
if isinstance(img, np.ndarray):
# numpy input
img_h, img_w = img.shape[:2]
else:
# PIL image input
img_w, img_h = img.size
if self.resize_short is not None:
......
......@@ -13,13 +13,13 @@ English | [简体中文](../../zh_CN/algorithm_introduction/reid.md)
- [2.1.4 Model training](#214-model-training)
- [3. Model evaluation and inference deployment](#3-model-evaluation-and-inference-deployment)
- [3.1 Model Evaluation](#31-model-evaluation)
- [3.1 Model Inference and Deployment](#31-model-inference-and-deployment)
- [3.1.1 Inference model preparation](#311-inference-model-preparation)
- [3.1.2 Inference based on Python prediction engine](#312-inference-based-on-python-prediction-engine)
- [3.1.3 Inference based on C++ prediction engine](#313-inference-based-on-c-prediction-engine)
- [3.2 Service Deployment](#32-service-deployment)
- [3.3 Device side deployment](#33-device-side-deployment)
- [3.4 Paddle2ONNX model conversion and prediction](#34-paddle2onnx-model-conversion-and-prediction)
- [3.2 Model Inference and Deployment](#32-model-inference-and-deployment)
- [3.2.1 Inference model preparation](#321-inference-model-preparation)
- [3.2.2 Inference based on Python prediction engine](#322-inference-based-on-python-prediction-engine)
- [3.2.3 Inference based on C++ prediction engine](#323-inference-based-on-c-prediction-engine)
- [3.3 Service Deployment](#33-service-deployment)
- [3.4 Lite deployment](#34-lite-deployment)
- [3.5 Paddle2ONNX model conversion and prediction](#35-paddle2onnx-model-conversion-and-prediction)
- [4. Summary](#4-summary)
- [4.1 Method summary and comparison](#41-method-summary-and-comparison)
- [4.2 Usage advice/FAQ](#42-usage-advicefaq)
......@@ -56,11 +56,11 @@ Based on the commonly used person re-identification model based on ResNet50, the
The following table summarizes the accuracy metrics of the 3 configurations of the recurring ReID strong-baseline on the Market1501 dataset,
| Configuration file | recall@1 | mAP | Refer to recall@1 | Refer to mAP | Pre-trained model download | Inference Model Download Address |
| -------------------------------- | -------- | ----- | ----------------- | ------------ | -------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
| baseline.yaml | 88.45 | 74.37 | 87.7 | 74.0 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/reid/pretrain/baseline_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/reid/inference/baseline_infer.tar) |
| softmax_triplet.yaml | 94.29 | 85.57 | 94.1 | 85.7 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/reid/pretrain/softmax_triplet_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/reid/inference/softmax_triplet_infer.tar) |
| softmax_triplet_with_center.yaml | 94.50 | 85.82 | 94.5 | 85.9 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/reid/pretrain/softmax_triplet_with_center_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/reid/inference/softmax_triplet_with_center_infer.tar) |
| Configuration file | recall@1(\%) | mAP(\%) | Refer to recall@1(\%) | Refer to mAP(\%) | Pre-trained model download | Inference Model Download Address |
| -------------------------------- | ------------ | ------- | --------------------- | ---------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------- |
| baseline.yaml | 88.45 | 74.37 | 87.7 | 74.0 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/reid/pretrain/baseline_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/reid/inference/baseline_infer.tar) |
| softmax_triplet.yaml | 94.29 | 85.57 | 94.1 | 85.7 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/reid/pretrain/softmax_triplet_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/reid/inference/softmax_triplet_infer.tar) |
| softmax_triplet_with_center.yaml | 94.50 | 85.82 | 94.5 | 85.9 | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/reid/pretrain/softmax_triplet_with_center_pretrained.pdparams) | [Download link](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/reid/inference/softmax_triplet_with_center_infer.tar) |
Note: The above reference indicators are obtained by using the author's open source code to train on our equipment for many times. Due to different system environments, torch versions, and CUDA versions, there may be slight differences with the indicators provided by the author.
......@@ -170,9 +170,9 @@ Prepare the `*.pdparams` model parameter file for evaluation. You can use the tr
```
The default evaluation log is saved in `PaddleClas/output/RecModel/eval.log`. You can see that the evaluation metrics of the `softmax_triplet_with_center_pretrained.pdparams` model we provided on the Market1501 dataset are recall@1=0.94507, recall@5 =0.98248, mAP=0.85827
#### 3.1 Model Inference and Deployment
#### 3.2 Model Inference and Deployment
##### 3.1.1 Inference model preparation
##### 3.2.1 Inference model preparation
You can convert the model file saved during training into an inference model and inference, or use the converted inference model we provide for direct inference
- Convert the model file saved during the training process to an inference model, also take `latest.pdparams` as an example, execute the following command to convert
......@@ -191,7 +191,7 @@ You can convert the model file saved during training into an inference model and
cd ../
```
##### 3.1.2 Inference based on Python prediction engine
##### 3.2.2 Inference based on Python prediction engine
1. Modify `PaddleClas/deploy/configs/inference_rec.yaml`. Change the field after `infer_imgs:` to any image path under the query folder in Market1501 (the configuration below uses the path of the `0294_c1s1_066631_00.jpg` image); change the field after `rec_inference_model_dir:` to extract it softmax_triplet_with_center_infer folder path; change the preprocessing configuration under the `transform_ops` field to the preprocessing configuration under `Eval.Query.dataset` in `softmax_triplet_with_center.yaml`. As follows
......@@ -242,23 +242,23 @@ You can convert the model file saved during training into an inference model and
4. For batch prediction, change the path after `infer_imgs:` in the configuration file to a folder, such as `../dataset/market1501/Market-1501-v15.09.15/query`, it will predict and output The feature vector of all images under query.
##### 3.1.3 Inference based on C++ prediction engine
##### 3.2.3 Inference based on C++ prediction engine
PaddleClas provides an example of inference based on C++ prediction engine, you can refer to [C++ prediction](../inference_deployment/cpp_deploy_en.md) to complete the corresponding inference deployment. If you are using the Windows platform, you can refer to the Visual Studio 2019 Community CMake Compilation Guide to complete the corresponding prediction library compilation and model prediction work.
##### 3.2 Service Deployment
#### 3.3 Service Deployment
Paddle Serving provides high-performance, flexible and easy-to-use industrial-grade online inference services. Paddle Serving supports RESTful, gRPC, bRPC and other protocols, and provides inference solutions in a variety of heterogeneous hardware and operating system environments. For more introduction to Paddle Serving, please refer to the Paddle Serving code repository.
PaddleClas provides an example of model serving deployment based on Paddle Serving. You can refer to [Model serving deployment](../inference_deployment/paddle_serving_deploy_en.md) to complete the corresponding deployment work.
##### 3.3 Lite deployment
#### 3.4 Lite deployment
Paddle Lite is a high-performance, lightweight, flexible and easily extensible deep learning inference framework, positioned to support mobileMultiple hardware platforms including client, embedded and server. For more introduction to Paddle Lite, please refer to the Paddle Lite code repository.
PaddleClas provides an example of deploying models based on Paddle Lite. You can refer to [Deployment](../inference_deployment/paddle_lite_deploy_en.md) to complete the corresponding deployment.
##### 3.4 Paddle2ONNX model conversion and prediction
#### 3.5 Paddle2ONNX model conversion and prediction
Paddle2ONNX supports converting PaddlePaddle model format to ONNX model format. The deployment of Paddle models to various inference engines can be completed through ONNX, including TensorRT/OpenVINO/MNN/TNN/NCNN, as well as other inference engines or hardware that support the ONNX open source format. For more information about Paddle2ONNX, please refer to the Paddle2ONNX code repository.
......
......@@ -13,13 +13,13 @@
- [2.1.4 模型训练](#214-模型训练)
- [3. 模型评估与推理部署](#3-模型评估与推理部署)
- [3.1 模型评估](#31-模型评估)
- [3.1 模型推理与部署](#31-模型推理与部署)
- [3.1.1 推理模型准备](#311-推理模型准备)
- [3.1.2 基于 Python 预测引擎推理](#312-基于-python-预测引擎推理)
- [3.1.3 基于 C++ 预测引擎推理](#313-基于-c-预测引擎推理)
- [3.2 服务化部署](#32-服务化部署)
- [3.3 端侧部署](#33-端侧部署)
- [3.4 Paddle2ONNX 模型转换与预测](#34-paddle2onnx-模型转换与预测)
- [3.2 模型推理](#32-模型推理)
- [3.2.1 推理模型准备](#321-推理模型准备)
- [3.2.2 基于 Python 预测引擎推理](#322-基于-python-预测引擎推理)
- [3.2.3 基于 C++ 预测引擎推理](#323-基于-c-预测引擎推理)
- [3.3 服务化部署](#33-服务化部署)
- [3.4 端侧部署](#34-端侧部署)
- [3.5 Paddle2ONNX 模型转换与预测](#35-paddle2onnx-模型转换与预测)
- [4. 总结](#4-总结)
- [4.1 方法总结与对比](#41-方法总结与对比)
- [4.2 使用建议/FAQ](#42-使用建议faq)
......@@ -56,11 +56,11 @@
以下表格总结了复现的ReID strong-baseline的3种配置在 Market1501 数据集上的精度指标,
| 配置文件 | recall@1 | mAP | 参考recall@1 | 参考mAP | 预训练模型下载地址 | inference模型下载地址 |
| -------------------------------- | -------- | ----- | ------------ | ------- | --------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- |
| baseline.yaml | 88.45 | 74.37 | 87.7 | 74.0 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/reid/pretrain/baseline_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/reid/inference/baseline_infer.tar) |
| softmax_triplet.yaml | 94.29 | 85.57 | 94.1 | 85.7 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/reid/pretrain/softmax_triplet_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/reid/inference/softmax_triplet_infer.tar) |
| softmax_triplet_with_center.yaml | 94.50 | 85.82 | 94.5 | 85.9 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/reid/pretrain/softmax_triplet_with_center_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/reid/inference/softmax_triplet_with_center_infer.tar) |
| 配置文件 | recall@1(\%) | mAP(\%) | 参考recall@1(\%) | 参考mAP(\%) | 预训练模型下载地址 | inference模型下载地址 |
| -------------------------------- | ------------ | ------- | ---------------- | ----------- | --------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------ |
| baseline.yaml | 88.45 | 74.37 | 87.7 | 74.0 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/reid/pretrain/baseline_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/reid/inference/baseline_infer.tar) |
| softmax_triplet.yaml | 94.29 | 85.57 | 94.1 | 85.7 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/reid/pretrain/softmax_triplet_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/reid/inference/softmax_triplet_infer.tar) |
| softmax_triplet_with_center.yaml | 94.50 | 85.82 | 94.5 | 85.9 | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/reid/pretrain/softmax_triplet_with_center_pretrained.pdparams) | [下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/reid/inference/softmax_triplet_with_center_infer.tar) |
注:上述参考指标由使用作者开源的代码在我们的设备上训练多次得到,由于系统环境、torch版本、CUDA版本不同等原因,与作者提供的指标可能存在略微差异。
......@@ -170,9 +170,9 @@
```
默认评估日志保存在`PaddleClas/output/RecModel/eval.log`中,可以看到我们提供的 `softmax_triplet_with_center_pretrained.pdparams` 模型在 Market1501 数据集上的评估指标为recall@1=0.94507,recall@5=0.98248,mAP=0.85827
#### 3.1 模型推理与部署
#### 3.2 模型推理
##### 3.1.1 推理模型准备
##### 3.2.1 推理模型准备
可以将训练过程中保存的模型文件转换成 inference 模型并推理,或者使用我们提供的转换好的 inference 模型直接进行推理
- 将训练过程中保存的模型文件转换成 inference 模型,同样以 `latest.pdparams` 为例,执行以下命令进行转换
......@@ -191,7 +191,7 @@
cd ../
```
##### 3.1.2 基于 Python 预测引擎推理
##### 3.2.2 基于 Python 预测引擎推理
1. 修改 `PaddleClas/deploy/configs/inference_rec.yaml`
-`infer_imgs:` 后的路径段改为 Market1501 中 query 文件夹下的任意一张图片路径(下方配置使用的是`0294_c1s1_066631_00.jpg`图片的路径)
......@@ -245,23 +245,23 @@
4. 批量预测,将配置文件中`infer_imgs:`后的路径改为为文件夹即可,如`../dataset/market1501/Market-1501-v15.09.15/query`,会预测并逐个输出query下所有图片的特征向量。
##### 3.1.3 基于 C++ 预测引擎推理
##### 3.2.3 基于 C++ 预测引擎推理
PaddleClas 提供了基于 C++ 预测引擎推理的示例,您可以参考[服务器端 C++ 预测](../inference_deployment/cpp_deploy.md)来完成相应的推理部署。如果您使用的是 Windows 平台,可以参考基于 Visual Studio 2019 Community CMake 编译指南完成相应的预测库编译和模型预测工作。
##### 3.2 服务化部署
#### 3.3 服务化部署
Paddle Serving 提供高性能、灵活易用的工业级在线推理服务。Paddle Serving 支持 RESTful、gRPC、bRPC 等多种协议,提供多种异构硬件和多种操作系统环境下推理解决方案。更多关于Paddle Serving 的介绍,可以参考Paddle Serving 代码仓库。
PaddleClas 提供了基于 Paddle Serving 来完成模型服务化部署的示例,您可以参考[模型服务化部署](../inference_deployment/paddle_serving_deploy.md)来完成相应的部署工作。
##### 3.3 端侧部署
#### 3.4 端侧部署
Paddle Lite 是一个高性能、轻量级、灵活性强且易于扩展的深度学习推理框架,定位于支持包括移动端、嵌入式以及服务器端在内的多硬件平台。更多关于 Paddle Lite 的介绍,可以参考Paddle Lite 代码仓库。
PaddleClas 提供了基于 Paddle Lite 来完成模型端侧部署的示例,您可以参考[端侧部署](../inference_deployment/paddle_lite_deploy.md)来完成相应的部署工作。
##### 3.4 Paddle2ONNX 模型转换与预测
#### 3.5 Paddle2ONNX 模型转换与预测
Paddle2ONNX 支持将 PaddlePaddle 模型格式转化到 ONNX 模型格式。通过 ONNX 可以完成将 Paddle 模型到多种推理引擎的部署,包括TensorRT/OpenVINO/MNN/TNN/NCNN,以及其它对 ONNX 开源格式进行支持的推理引擎或硬件。更多关于 Paddle2ONNX 的介绍,可以参考Paddle2ONNX 代码仓库。
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册