Files
FastDeploy/examples/vision/keypointdetection/det_keypoint_unite/python
yeliang2258 7b15f72516 [Backend] Add OCR、Seg、 KeypointDetection、Matting、 ernie-3.0 and adaface models for XPU Deploy (#960)
* [FlyCV] Bump up FlyCV -> official release 1.0.0

* add seg models for XPU

* add ocr model for XPU

* add matting

* add matting python

* fix infer.cc

* add keypointdetection support for XPU

* Add adaface support for XPU

* add ernie-3.0

* fix doc

Co-authored-by: DefTruth <qiustudent_r@163.com>
Co-authored-by: DefTruth <31974251+DefTruth@users.noreply.github.com>
2022-12-26 15:02:58 +08:00
..

PP-PicoDet + PP-TinyPose (Pipeline) Python部署示例

在部署前,需确认以下两个步骤

本目录下提供det_keypoint_unite_infer.py快速完成多人模型配置 PP-PicoDet + PP-TinyPose 在CPU/GPU以及GPU上通过TensorRT加速部署的单图多人关键点检测示例。执行如下脚本即可完成

注意: PP-TinyPose单模型独立部署请参考PP-TinyPose 单模型

#下载部署示例代码
git clone https://github.com/PaddlePaddle/FastDeploy.git
cd FastDeploy/examples/vision/keypointdetection/det_keypoint_unite/python

# 下载PP-TinyPose模型文件和测试图片
wget https://bj.bcebos.com/paddlehub/fastdeploy/PP_TinyPose_256x192_infer.tgz
tar -xvf PP_TinyPose_256x192_infer.tgz
wget https://bj.bcebos.com/paddlehub/fastdeploy/PP_PicoDet_V2_S_Pedestrian_320x320_infer.tgz
tar -xvf PP_PicoDet_V2_S_Pedestrian_320x320_infer.tgz
wget https://bj.bcebos.com/paddlehub/fastdeploy/000000018491.jpg
# CPU推理
python det_keypoint_unite_infer.py --tinypose_model_dir PP_TinyPose_256x192_infer --det_model_dir PP_PicoDet_V2_S_Pedestrian_320x320_infer --image 000000018491.jpg --device cpu
# GPU推理
python det_keypoint_unite_infer.py --tinypose_model_dir PP_TinyPose_256x192_infer --det_model_dir PP_PicoDet_V2_S_Pedestrian_320x320_infer --image 000000018491.jpg --device gpu
# GPU上使用TensorRT推理 注意TensorRT推理第一次运行有序列化模型的操作有一定耗时需要耐心等待
python det_keypoint_unite_infer.py --tinypose_model_dir PP_TinyPose_256x192_infer --det_model_dir PP_PicoDet_V2_S_Pedestrian_320x320_infer --image 000000018491.jpg --device gpu --use_trt True
# XPU推理
python det_keypoint_unite_infer.py --tinypose_model_dir PP_TinyPose_256x192_infer --det_model_dir PP_PicoDet_V2_S_Pedestrian_320x320_infer --image 000000018491.jpg --device xpu

运行完成可视化结果如下图所示

PPTinyPosePipeline Python接口

fd.pipeline.PPTinyPose(det_model=None, pptinypose_model=None)

PPTinyPosePipeline模型加载和初始化其中det_model是使用fd.vision.detection.PicoDet参考Detection文档初始化的检测模型pptinypose_model是使用fd.vision.keypointdetection.PPTinyPose参考PP-TinyPose文档初始化的检测模型

参数

  • det_model(str): 初始化后的检测模型
  • pptinypose_model(str): 初始化后的PP-TinyPose模型

predict函数

PPTinyPosePipeline.predict(input_image)

模型预测结口,输入图像直接输出检测结果。

参数

  • input_image(np.ndarray): 输入数据注意需为HWCBGR格式

返回

返回fastdeploy.vision.KeyPointDetectionResult结构体,结构体说明参考文档视觉模型预测结果

类成员属性

后处理参数

  • detection_model_score_threshold(bool): 输入PP-TinyPose模型前Detectin模型过滤检测框的分数阈值

其它文档