paddleDetection-target detection whole process tutorial

Reference link:
https://github.com/PaddlePaddle/PaddleDetection/blob/release/2.0-rc/docs/tutorials/DetectionPipeline.md

This tutorial uses the road sign data set as an example, and uses the yoloV3 algorithm to explain the entire process of paddleDetection. It includes: data preparation, model selection, model training, evaluation, prediction, model compression and model deployment.

data preparation

For data preparation, please refer to:

Note:
(1) Do not include spaces in the path name and file name in the data set, and try not to use Chinese.
(2) User data. It is recommended to check the data carefully before training to avoid errors in the training process due to incorrect data annotation format or incomplete image data. Interruption
(2) If the image size is too large, it will take up more memory without limiting the size of the read data, which will cause memory/video memory overflow. Please set batch_size reasonably, and try from small to large.

Model selection

PaddleDetection provides a rich model library. You can view the indicators of each model in the model library. You can select the appropriate model based on the actual deployment of computing power.

This tutorial uses YOLOv3 as the training model.

Training and model evaluation

Please refer to this link:

Model training and prediction

Reasoning department

Before model deployment, if you need to compress the model, PaddleDetection provides a complete tutorial and experimental results of model compression based on PaddleSlim. For details, please refer to: quantification, pruning, distillation, and search.
For detailed deployment documents, please refer to PaddleDetection Predictive Deployment Documents. Here we take the PaddleServing deployment method as an example.

Install paddle-serving-client and paddle-serving-server

# 安装 paddle-serving-client
pip install paddle-serving-client -i https://mirror.baidu.com/pypi/simple

# 安装 paddle-serving-server
pip install paddle-serving-server -i https://mirror.baidu.com/pypi/simple

# 安装 paddle-serving-server-gpu
pip install paddle-serving-server-gpu -i https://mirror.baidu.com/pypi/simple

Export model

python tools/export_serving_model.py -c configs/yolov3_mobilenet_v1_roadsign.yml -o use_gpu=true weights=output/yolov3_mobilenet_v1_roadsign/best_model --output_dir=./inference_model

The results show that
The above command will generate a yolov3_mobilenet_v1_roadsign folder under the ./inference_model folder:

inference_model
│   ├── yolov3_mobilenet_v1_roadsign
│   │   ├── infer_cfg.yml
│   │   ├── serving_client
│   │   │   ├── serving_client_conf.prototxt
│   │   │   ├── serving_client_conf.stream.prototxt
│   │   ├── serving_server
│   │   │   ├── conv1_bn_mean
│   │   │   ├── conv1_bn_offset
│   │   │   ├── conv1_bn_scale
│   │   │   ├── ...

Start PaddleServing service

cd inference_model/yolov3_mobilenet_v1_roadsign/

# GPU
python -m paddle_serving_server_gpu.serve --model serving_server --port 9393 --gpu_ids 0

# CPU
python -m paddle_serving_server.serve --model serving_server --port 9393
注意:
遇到的一些问题:
1:/root/anaconda3/lib/python3.7/site-packages/paddle_serving_server/serving-cpu-avx-openblas-0.5.0/serving: /lib64/libstdcn `CXXABI_1.3.8' not found (required by /root/anaconda3/lib/python3.7/site-packages/paddle_serving_server/serving-cpu-av0/serving)

https://github.com/cdr/code-server/issues/347#issuecomment-482670081

2:

Insert picture description here

Test the deployed service

Prepare label_list.txt file

# 进入到导出模型文件夹
cd inference_model/yolov3_mobilenet_v1_roadsign/

# 将数据集对应的label_list.txt文件拷贝到当前文件夹下
cp ../../dataset/roadsign_voc/label_list.txt .

Set the path of the prototxt file in the test file test_client.py to serving_client/serving_client_conf.prototxt.
Set fetch to fetch=["multiclass_nms_0.tmp_0"])

test

# 进入目录
cd inference_model/yolov3_mobilenet_v1_roadsign/

# 测试代码 test_client.py 会自动创建output文件夹,并在output下生成`bbox.json`和`road554.png`两个文件
python ../../deploy/serving/test_client.py ../../demo/road554.png

Please follow my personal WeChat public account

Insert picture description here

Reference link

  • https://github.com/PaddlePaddle/PaddleDetection/blob/release/2.0-rc/docs/tutorials/DetectionPipeline.md

Guess you like

Origin blog.csdn.net/zhonglongshen/article/details/114661956