运行该命令获取的视频结果与运行HRNet中的demo/inference.py效果相同。
一、遵循官网程序运行命令
python mmskl.py pose_demo [--gpus $GPUS]
# or "python mmskl.py pose_demo_HD [--gpus $GPUS]" for a higher accuracy
运行过程:
mmskl.py——>./configs/pose_estimation/pose_demo.yaml
——>(pose_demo.py)mmskeleton.processor.pose_demo.inference——>(pose_demo.py)mmskeleton.apis.estimation.init_pose_estimator(姿态估计hrnet)——>(estimation.py)mmdet.apis.inference.init_detector(目标检测cascade_rcnn)——>(estimation.py)mmskeleton.processor.apis.init_twodimestimator——>(apis.py)mmskeleton.utils.load_checkpoint(加载人体姿态估计模型权重文件)
~注:此过程只加载目标检测模型和人体姿态估计模型,无需加载动作识别模型。
二、
报错:权重文件不存在
OSError: F:/Action Recognition/st-gcn/checkpoints/cascade_rcnn_r50_fpn_20e_20181123-db483a09.pth is not a checkpoint file
(open) F:\Action_Recognition\st-gcn>python mmskl.py pose_demo --video resource/data_example/50.mp4
Load configuration information from ./configs/pose_estimation/pose_demo.yaml
Pose estimation:
Traceback (most recent call last):
File "mmskl.py", line 147, in <module>
main()
File "mmskl.py", line 126, in main
call_obj(**cfg.processor_cfg)
File "F:\Action_Recognition\st-gcn\mmskeleton\utils\importer.py", line 34, in call_obj
return import_obj(type)(**kwargs)
File "F:\Action_Recognition\st-gcn\mmskeleton\processor\pose_demo.py", line 80, in inference
model = init_pose_estimator(detection_cfg, estimation_cfg, device=0)
File "F:\Action_Recognition\st-gcn\mmskeleton\apis\estimation.py", line 23, in init_pose_estimator
device='cuda:0')
File "H:\Anaconda3\envs\open\lib\site-packages\mmdet-1.0+unknown-py3.6-win-amd64.egg\mmdet\apis\inference.py", line 36, in init_detector
checkpoint = load_checkpoint(model, checkpoint)
File "H:\Anaconda3\envs\open\lib\site-packages\mmcv\runner\checkpoint.py", line 184, in load_checkpoint
checkpoint = _load_checkpoint(filename, map_location)
File "H:\Anaconda3\envs\open\lib\site-packages\mmcv\runner\checkpoint.py", line 161, in _load_checkpoint
raise IOError('{} is not a checkpoint file'.format(filename))
OSError: F:/Action Recognition/st-gcn/checkpoints/cascade_rcnn_r50_fpn_20e_20181123-db483a09.pth is not a checkpoint file
原因:文件路径名错误
解决:将Action Recognition改为Action_Recognition即可成功运行。
前提:将mmskeleton.apis.estimation.py中的权重加载路径改为绝对路径。
三、
报错:加载到的模型权重不完全匹配。
The model and loaded state dict do not match exactly
原因:pose_demo.py只输出二维目标检测框和人体姿态,所以无需加载ST-GCN模型。
解决:修改权重加载文件mmskeleton.utils.checkpoint.py
中的路径为原程序中的路径即可。
def load_checkpoint(model, filename, *args, **kwargs):
try:
# filename = "F:/Action_Recognition/st-gcn/checkpoints/st_gcn.kinetics-6fa43f73.pth"################################
# filename = "F:/Action_Recognition/st-gcn/work_dir/recognition/ST_GCN_18/kinetics-skeleton/epoch_50.pth"################################
# filename = "F:/Action_Recognition/st-gcn/work_dir/recognition/ST_GCN_18/kinetics-skeleton_all/epoch_50.pth"################################
filename = get_mmskeleton_url(filename)