diff --git a/docs/advanced_tutorials/customization/action_recognotion/videobased_rec.md b/docs/advanced_tutorials/customization/action_recognotion/videobased_rec.md index be260180b403d75b701f214ab096188f9d5b60c2..522eebe3d135a789a7843676ca477ec5e4b23a2c 100644 --- a/docs/advanced_tutorials/customization/action_recognotion/videobased_rec.md +++ b/docs/advanced_tutorials/customization/action_recognotion/videobased_rec.md @@ -130,3 +130,30 @@ python tools/export_model.py -c pptsm_fight_frames_dense.yaml \ -p ppTSM_fight_best.pdparams \ -o inference/ppTSM ``` + + +#### 推理可视化 + +利用上步骤导出的模型,基于PaddleDetection中推理pipeline可完成自定义行为识别及可视化。 + +新增行为后,需要对现有的可视化代码进行修改,目前代码支持打架二分类可视化,新增类别后需要根据识别结果自适应可视化推理结果。 + +具体修改PaddleDetection中develop/deploy/pipeline/pipeline.py路径下PipePredictor类中visualize_video成员函数。当结果中存在'video_action'数据时,会对行为进行可视化。目前的逻辑是如果推理的类别为1,则为打架行为,进行可视化;否则不进行显示,即"video_action_score"为None。用户新增行为后,可根据类别index和对应的行为设置"video_action_text"字段,目前index=1对应"Fight"。相关代码块如下: + +``` +video_action_res = result.get('video_action') +if video_action_res is not None: + video_action_score = None + if video_action_res and video_action_res["class"] == 1: + video_action_score = video_action_res["score"] + mot_boxes = None + if mot_res: + mot_boxes = mot_res['boxes'] + image = visualize_action( + image, + mot_boxes, + action_visual_collector=None, + action_text="SkeletonAction", + video_action_score=video_action_score, + video_action_text="Fight") +```