1. 环境准备
- 安装conda,创建Python环境并激活
- 安装pytorch、ffmpeg、detectron2
- 下载数据集
# 环境预处理
# https://shiboliu.com/2022/07/15/step1-videopose3d-prepare/
# 安装ffmpeg
conda config --add channels conda-forge
conda install ffmpeg
ffmpeg -version
# 安装detectron2
# 官方文档 https://detectron2.readthedocs.io/en/latest/tutorials/install.html
# 教程 https://blog.csdn.net/willbetter01/article/details/120906567
python -m pip install detectron2 -f \ https://dl.fbaipublicfiles.com/detectron2/wheels/cu100/torch1.4/index.html
# 数据集下载 https://blog.csdn.net/weixin_42001132/article/details/103437104
matlib
pip install cdflib
2. 数据集处理
参考源码包中DATASETS.md文件中的Instructions without MATLAB (recommended)章节执行命令
执行前要修改data/prepare_data_h36m.py文件代码
# positions = hf['3D_positions'].value.reshape(32, 3, -1).transpose(2, 0, 1)
positions = hf['3D_positions'][:].reshape(32, 3, -1).transpose(2, 0, 1)
2. 跑预测
pip安装pyparsing
- CPU跑预测需要调整inference/infer_video_d2.py中代码,在cfg = get_cfg()的下一行新增一行:cfg.MODEL.DEVICE = 'cpu' 。参考 https://github.com/facebookresearch/detectron2/issues/300
- 下载一个视频或者自己用ffmpeg命令去剪辑一个视频片段,太长了要跑很久,不建议。放到/tmp。这里我下载了一个视频 cd /tmp && wget https://modelscope.oss-cn-beijing.aliyuncs.com/test/videos/Walking.54138969.mp4
- 执行 python infer_video_d2.py --cfg COCO-Keypoints/keypoint_rcnn_R_101_FPN_3x.yaml --output-dir /tmp --image-ext mp4 /tmp
- 得到一个npz文件,尝试打开