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.csdn.net/YoJayC/article/details/108918768

猜你喜欢

转载自blog.csdn.net/qq_43268106/article/details/123737549
今日推荐