基于之前本人的项目如果感到快乐你就跳跳舞 进行升级迭代开发。项目通过比较在音乐鼓点时姿态的相似度进行计分统计,有较强的互动娱乐性,特别是对于作者这种老肥宅的程序员有很不错的减脂效果。欢迎大家尝试体验!
本次项目主要升级点:
todo 视频
注意: 所有素材均来自互联网,若有侵权,请联系删除
界面布局主要分成3部分,上方中间显示姿态匹配正确的次数:
这次升级中暂无明显改动,在参考舞蹈视频源区域右键单击显示菜单, 主要包括
点击歌曲管理后可以添加删除舞蹈视频, 也可以在歌曲列表切换当前选中歌曲。
# 下载openvino
!pip install openvino-dev --user
# 下载框架代码
!git clone https://gitee.com/paddlepaddle/PaddleDetection.git
Cloning into 'PaddleDetection'...
remote: Enumerating objects: 254557, done.[K
remote: Counting objects: 100% (235027/235027), done.[K
remote: Compressing objects: 100% (42643/42643), done.[K
remote: Total 254557 (delta 193625), reused 232717 (delta 191595), pack-reused 19530[K
Receiving objects: 100% (254557/254557), 411.82 MiB | 24.67 MiB/s, done.
Resolving deltas: 100% (208174/208174), done.
Checking connectivity... done.
# 导出行人检测静态图模型
%cd /home/aistudio/PaddleDetection
!python tools/export_model.py -c configs/picodet/application/pedestrian_detection/picodet_s_320_lcnet_pedestrian.yml \-o weights=https://bj.bcebos.com/v1/paddledet/models/keypoint/tinypose_enhance/picodet_s_320_lcnet_pedestrian.pdparams \export.benchmark=False export.nms=False \--output_dir=output_pedestrain_onnx
/home/aistudio/PaddleDetection
Warning: import ppdet from source directory without installing, run 'python setup.py install' to install ppdet firstly
[11/22 00:28:41] ppdet.utils.checkpoint INFO: Finish loading model weights: /home/aistudio/.cache/paddle/weights/picodet_s_320_lcnet_pedestrian.pdparams
[11/22 00:28:41] ppdet.data.source.category WARNING: anno_file 'dataset/coco/annotations/instances_val2017.json' is None or not set or not exist, please recheck TrainDataset/EvalDataset/TestDataset.anno_path, otherwise the default categories will be used by metric_type.
[11/22 00:28:41] ppdet.data.source.category WARNING: metric_type: COCO, load default categories of COCO.
[11/22 00:28:41] ppdet.engine INFO: Export inference config file to output_pedestrain_onnx/picodet_s_320_lcnet_pedestrian/infer_cfg.yml
[11/22 00:28:46] ppdet.engine INFO: Export model and saved in output_pedestrain_onnx/picodet_s_320_lcnet_pedestrian
# 导出onnx
# !pip install paddle2onnx
%cd /home/aistudio/PaddleDetection
!paddle2onnx --model_dir output_pedestrain_onnx/picodet_s_320_lcnet_pedestrian/ \--model_filename model.pdmodel \--params_filename model.pdiparams \--opset_version 11 \--input_shape_dict "{'image':[1, 3, 320, 320]}" \--save_file pedestrain.onnx
/home/aistudio/PaddleDetection
[1;31;40m2022-11-22 00:29:45 [WARNING] [Deprecated] The flag `--input_shape_dict` is deprecated, if you need to modify the input shape of PaddlePaddle model, please refer to this tool https://github.com/jiangjiajun/PaddleUtils/tree/main/paddle [0m
[Paddle2ONNX] Start to parse PaddlePaddle model...
[Paddle2ONNX] Model file path: output_pedestrain_onnx/picodet_s_320_lcnet_pedestrian/model.pdmodel
[Paddle2ONNX] Paramters file path: output_pedestrain_onnx/picodet_s_320_lcnet_pedestrian/model.pdiparams
[Paddle2ONNX] Start to parsing Paddle model...
[Paddle2ONNX] Use opset_version = 11 for ONNX export.
[Paddle2ONNX] PaddlePaddle model is exported as ONNX format now.
2022-11-22 00:29:46 [INFO] ===============Make PaddlePaddle Better!================
2022-11-22 00:29:46 [INFO] A little survey: https://iwenjuan.baidu.com/?code=r8hu2s
# 安装onnx和onnxsim
!pip install -U onnx onnxsim onnxruntime
# 优化onnx模型
%cd /home/aistudio/PaddleDetection
!onnxsim pedestrain.onnx pedestrain_sim.onnx
/home/aistudio/PaddleDetection
Simplifying[33m...[0m
Finish! Here is the difference:
┏━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━┓
┃[1m [0m[1m [0m[1m [0m┃[1m [0m[1mOriginal Model[0m[1m [0m┃[1m [0m[1mSimplified Model[0m[1m [0m┃
┡━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━┩
│ Add │ 81 │ 81 │
│ BatchNormalization │ 82 │ [1;32m0 [0m │
│ Clip │ 78 │ 78 │
│ Concat │ 7 │ 7 │
│ Constant │ 774 │ [1;32m0 [0m │
│ Conv │ 98 │ 98 │
│ Div │ 78 │ 78 │
│ GlobalAveragePool │ 6 │ 6 │
│ HardSigmoid │ 2 │ 2 │
│ MatMul │ 4 │ 4 │
│ Mul │ 90 │ 90 │
│ Relu │ 2 │ 2 │
│ Reshape │ 12 │ 12 │
│ Resize │ 2 │ 2 │
│ Sigmoid │ 12 │ 12 │
│ Softmax │ 4 │ 4 │
│ Split │ 1 │ 1 │
│ Sqrt │ 4 │ 4 │
│ Transpose │ 4 │ 4 │
│ Model Size │ 4.6MiB │ [1;32m4.5MiB [0m │
└────────────────────┴────────────────┴──────────────────┘
# 导出姿态模型静态图
%cd /home/aistudio/PaddleDetection
!python tools/export_model.py -c configs/keypoint/tiny_pose/tinypose_256x192.yml \-o weights=https://bj.bcebos.com/v1/paddledet/models/keypoint/tinypose_enhance/tinypose_256x192.pdparams \--output_dir=output_pose
/home/aistudio/PaddleDetection
Warning: import ppdet from source directory without installing, run 'python setup.py install' to install ppdet firstly
[11/21 23:24:52] ppdet.utils.download INFO: Downloading tinypose_256x192.pdparams from https://bj.bcebos.com/v1/paddledet/models/keypoint/tinypose_enhance/tinypose_256x192.pdparams
100%|█████████████████████████████████████| 5439/5439 [00:01<00:00, 3179.96KB/s]
[11/21 23:24:55] ppdet.utils.checkpoint INFO: Finish loading model weights: /home/aistudio/.cache/paddle/weights/tinypose_256x192.pdparams
[11/21 23:24:55] ppdet.engine INFO: Export inference config file to output_pose/tinypose_256x192/infer_cfg.yml
[11/21 23:25:10] ppdet.engine INFO: Export model and saved in output_pose/tinypose_256x192
# 导出onnx模型
%cd /home/aistudio/PaddleDetection
!paddle2onnx --model_dir output_pose/tinypose_256x192/ \--model_filename model.pdmodel \--params_filename model.pdiparams \--opset_version 11 \--save_file tinypose.onnx
/home/aistudio/PaddleDetection
[Paddle2ONNX] Start to parse PaddlePaddle model...
[Paddle2ONNX] Model file path: output_pose/tinypose_256x192/model.pdmodel
[Paddle2ONNX] Paramters file path: output_pose/tinypose_256x192/model.pdiparams
[Paddle2ONNX] Start to parsing Paddle model...
[Paddle2ONNX] Use opset_version &#61; 11 for ONNX export.
[Paddle2ONNX] PaddlePaddle model is exported as ONNX format now.
2022-11-21 23:25:45 [INFO] &#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;Make PaddlePaddle Better!&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;
2022-11-21 23:25:45 [INFO] A little survey: https://iwenjuan.baidu.com/?code&#61;r8hu2s
# 将模型转为openvino的&#xff29;&#xff32;格式
%cd /home/aistudio/PaddleDetection
!mo --framework onnx --input_model tinypose.onnx --output_dir ./ --input_shape [1,3,256,192]
结合使用sort跟踪算法&#xff0c;推理第100帧图片, 目前在aistudio中无法直接运行openvino, 会报错 ModuleNotFoundError: No module named ‘openvino.runtime’
%cd /home/aistudio/track/
!python detector.py
运行推理结果示例如下&#xff1a;
本项目使用REID模型仅仅用于特征保存&#xff0c;方便快速查找某个舞者的历史分数&#xff0c;若要进一步更准确的查找&#xff0c;也可以用人脸识别模型替换。
参考转换姿态模型的步骤&#xff0c;简单几步即可完成:
CUDA_VISIBLE_DEVICES&#61;0 python tools/export_model.py -c configs/mot/deepsort/reid/deepsort_pplcnet.yml -o reid_weights&#61;https://paddledet.bj.bcebos.com/models/mot/deepsort/deepsort_pplcnet.pdparamspaddle2onnx --model_dir output_inference/deepsort_pplcnet \--model_filename model.pdmodel \--params_filename model.pdiparams \--opset_version 11 \--save_file reid.onnxmo reid.onnx --output_dir . --input_shape [1,3,64,192]
本项目需要本地运行&#xff0c;基本可以运行&#xff0c;程序运行稳定性和匹配效果还需要进一步优化。
后期将做更多的功能升级&#xff0c;例如尝试3D姿态&#xff0c;多人模式&#xff0c;Unity等等。
我在AI Studio上获得青铜等级&#xff0c;点亮0个徽章&#xff0c;来互关呀~ https://aistudio.baidu.com/aistudio/personalcenter/thirdview/89442
请点击此处查看本环境基本用法.
Please click here for more detailed instructions.
此文章为搬运
原项目链接