0
点赞
收藏
分享

微信扫一扫

[深度学习][原创]mmaction2预测结果top5得分改为0-1


测试版本:mmaction0.20.0

测试环境:ubuntu18.04

当我们测试tsn模型:

python demo/demo.py configs/recognition/tsn/tsn_r50_video_inference_1x1x3_100e_kinetics400_rgb.py checkpoints/tsn_r50_1x1x3_100e_kinetics400_rgb_20200614-e508be42.pth demo/demo.mp4 tools/data/kinetics/label_map_k400.txt

结果显示:

load checkpoint from local path: checkpoints/tsn_r50_1x1x3_100e_kinetics400_rgb_20200614-e508be42.pth
The top-5 labels with corresponding scores are:
arm wrestling:  29.61644
rock scissors paper:  10.754842
shaking hands:  9.908401
clapping:  9.189913
massaging feet:  8.305306
显然上面得分>1不符合0-1概率,因此如何改为0-1概率显示呢。

方法如下:

经过测试发现tsn_r50_video_inference_1x1x3_100e_kinetics400_rgb.py加入test_cfg已经没有效果,正确做法就是:

去mmaction2-0.20.0/configs/_base_/models/tsn_r50.py将tesct_cfg改为

test_cfg = dict(average_clips='prob', test_crops=1))

最终文件内容结果:

# model settings
 model = dict(
     type='Recognizer2D',
     backbone=dict(
         type='ResNet',
         pretrained='torchvision://resnet50',
         depth=50,
         norm_eval=False),
     cls_head=dict(
         type='TSNHead',
         num_classes=400,
         in_channels=2048,
         spatial_type='avg',
         consensus=dict(type='AvgConsensus', dim=1),
         dropout_ratio=0.4,
         init_std=0.01),
     # model training and testing settings
     train_cfg=None,
     test_cfg = dict(average_clips='prob', test_crops=1))

举报

相关推荐

0 条评论