Open followingcode opened 3 months ago
The --config parameter in demo/demo_skeleton.py is default='configs/rgbpose_conv3d/rgbpose_conv3d.py', and the --checkpoint parameter is default='https://download.openmmlab.com/mmaction/pyskl/ckpt/ rgbpose_conv3d/rgbpose_conv3d.pth'
Run the Python demo/demo_skeleton.py demo/ntu_sample.avi demo/demo.mp4 command line and find an error KeyError: 'test_mode'
@kennymckormick
The code from lines 258 to 265 of demo/demo_skeleton.py is modified as follows:
fake_anno = dict(
frame_dir='',
label=-1,
img_shape=(h, w),
original_shape=(h, w),
start_index=0,
modality='Pose',
total_frames=num_frame,
test_mode = True
)
print('fake_anno', fake_anno)
if not fake_anno['frame_dir']:
fake_anno['frame_dir'] = args.video
print(fake_anno['frame_dir'])
and pyskl/pyskl/apis/inference.py line 173 deleted And lines 173 to 176 of pyskl/pyskl/apis/inference.py need to be changed to:
output = model(return_loss=False,**data)
print('Model output' , output)
if isinstance(output[0], dict):
if 'pose' in output[0] and 'rgb' in output[0]:
# 取出 rgb 和 pose 数据
rgb_data = output[0]['rgb']
pose_data = output[0]['pose']
# 比较两种模态,取最大值
scores = np.maximum(rgb_data, pose_data)
else:
raise ValueError('输出字典不包括‘rgb’和‘pose’')
else:
scores = output[0]
print('scores type ', type(scores))
print('socres shape', scores.shape)
print(scores.ndim)
if scores.ndim == 1:
num_classes = scores.shape[0]
print(num_classes)
elif scores.ndim > 1:
num_classes = scores.shape[-1]
else:
raise ValueError(f'Unexpected shape: {scores.shape}')
Traceback (most recent call last): File "demo/demo_skeleton.py", line 314, in
main()
File "demo/demo_skeleton.py", line 293, in main
results = inference_recognizer(model, fake_anno)
File "/root/pyskl/pyskl/apis/inference.py", line 163, in inference_recognizer
data = test_pipeline(data)
File "/root/pyskl/pyskl/datasets/pipelines/compose.py", line 41, in call
data = t(data)
File "/root/pyskl/pyskl/datasets/pipelines/multi_modality.py", line 65, in call
if results['test_mode']:
KeyError: 'test_mode'