mmaction2配置与测试

源码地址:https://github.com/open-mmlab/mmaction2

一、安装环境:

Ubuntu16.04+anaconda: Python3.7  pytorch1.5.0 cuda10.1

mmaction2 V0.13.0:https://github.com/open-mmlab/mmaction2/releases/tag/v0.13.0

mmcv-full==1.3.0

二、安装步骤

  1. 创建虚拟环境:conda create -n py37 python=3.7
  2. 激活环境
  3. 安装torch==1.5.0(本文使用的是离线安装包)
  4. 安装mmcv-ful(根据cuda和torch版本): pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/cu101/torch1.5.0/index.html
  5. 克隆mmaction2的仓库:git clone https://github.com/open-mmlab/mmaction2.git
  6. 编译并安装:
    1. cd mmaction2
    2. pip install -r requirements/build.txt
    3. python setup.py develop
    4. 进入Python后,导入mmcv和mmaction查看是否成功。

三、功能测试

  1. cd demo
  2. 查看demo.ipynb文件,本文将其转为py文件,方便测试。
  3. from mmaction.apis import init_recognizer, inference_recognizer
    
    config_file = '../configs/recognition/tsn/tsn_r50_video_inference_1x1x3_100e_kinetics400_rgb.py'
    # download the checkpoint from model zoo and put it in `checkpoints/`
    checkpoint_file = '../checkpoints/tsn_r50_256p_1x1x8_100e_kinetics400_rgb.pth'
    model = init_recognizer(config_file, checkpoint_file, device='cpu')
    
    
    # test a single video and show the result:
    video = 'demo.mp4'
    label = 'label_map_k400.txt'
    results = inference_recognizer(model, video, label)
    
    # show the results
    for result in results:
        print(f'{result[0]}: ', result[1])
  4. 根据加载的网络,下载模型(重命名了):tsn_r50_256p_1x1x8_100e_kinetics400_rgb.pth(地址:https://github.com/open-mmlab/mmaction2/blob/master/configs/recognition/tsn/README.md
  5. 运行测试文件:python demo_test.py 
  6. 得到识别结果
  7. 待续

 

 

  • 1
    点赞
  • 16
    收藏
    觉得还不错? 一键收藏
  • 16
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 16
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值