Slowfast在something something v2上训练

Slowfast在something something v2上训练

网上的都只有一部分,整理了一下完整流程。

1-requirements

PyTorch(1.8.0+preferred): (https://pytorch.org/)
fvcore: pip install 'git+https://github.com/facebookresearch/fvcore'
simplejson: pip install simplejson
PyAV,ffmpeg: conda install av -c conda-forge
PyTorchVideo: pip install pytorchvideo
Detectron2(Pre-Built preferred): (https://detectron2.readthedocs.io/en/latest/tutorials/install.html)
slowfast: git clone https://github.com/facebookresearch/slowfast
          cd slowfast
          python setup.py build develop

2-data preparation

ssv2官网数据集已经503了,使用百度网盘下载(19G)。

https://pan.baidu.com/s/1NCqL7JVoFZO6D131zGls-A(pwd:07ka)

下载完成后进入文件夹,执行

cat 20bn-something-something-v2-?? | tar zx

新建extract.py,抽帧(397G)

import os
import subprocess

videos_root="./20bn-something-something-v2/"
save_root="/home/data/extracted_frames/"
if not os.path.exists(save_root):
	os.mkdir(save_root)

for root, dirs, files in os.walk(videos_root):
	for name in files:
		name1=name.split('.')[0]
		save_dir=save_root+name1+'/'
		if not os.path.exists(save_dir):
			os.mkdir(save_dir)
		cmd='ffmpeg -i "{}" -r 30 -q:v 1 "{}/{}_%06d.jpg\"'.format(videos_root+name, save_dir, name1)
		subprocess.call(cmd, shell=True)

3-下载权重

wget https://dl.fbaipublicfiles.com/pyslowfast/model_zoo/kinetics400/SLOWFAST_8x8_R50.pkl

(官方model zoo提供的Kinetics 400 and 600权重)

ps: ssv2中提供的权重好像不可用

在这里插入图片描述

4-开始训练

CUDA_VISIBLE_DEVICES=0,1 python tools/run_net.py \
  --cfg configs/SSv2/SLOWFAST_16x8_R50.yaml \
  TRAIN.BATCH_SIZE 8 \
  TRAIN.CHECKPOINT_FILE_PATH SLOWFAST_8x8_R50.pkl \
  DATA.PATH_TO_DATA_DIR path_to_your_dataset \
  DATA.PATH_PREFIX path_to_your_dataset \
  NUM_GPUS 2 \
  BN.NUM_SYNC_DEVICES 2

ps: NUM_GPUS % BN.NUM_SYNC_DEVICES should be 0.

两块TITAN XP 22个epoch需要大概10天。

在这里插入图片描述

参考链接:

  1. https://github.com/facebookresearch/SlowFast

  2. https://blog.youkuaiyun.com/YoJayC/article/details/108918768

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值