项目作者: BannyStone

项目描述 :
Video Classification based on PyTorch
高级语言: Python
项目地址: git://github.com/BannyStone/Video_Classification_PyTorch.git
创建时间: 2018-09-25T08:32:25Z
项目社区:https://github.com/BannyStone/Video_Classification_PyTorch

开源协议:

下载


Video-Classification-Pytorch

This is an archived repo. Stronly recommend PySlowFast or mmaction for video understanding.

This is a repository containing 3D models and 2D models for video classification. The code is based on PyTorch 1.0.
Until now, it supports the following datasets:
Kinetics-400, Mini-Kinetics-200, UCF101, HMDB51

Results

Kinetics-400

We report the baselines with ResNet-50 backbone on Kinetics-400 validation set as below (all models are trained on training set).
All the models are trained in one single server with 8 GTX 1080 Ti GPUs.

network pretrain data spatial resolution input frames sampling stride backbone top1 top5
ResNet50-SlowOnly ImageNet-1K 224x224 8 8 ResNet50 73.77 91.17

Get the Code

  1. git clone --recursive https://github.com/BannyStone/Video_Classification_PyTorch.git

Preparing Dataset

Kinetics-400

  1. cd data/kinetics400
  2. mkdir access && cd access
  3. ln -s $YOUR_KINETICS400_DATASET_TRAIN_DIR$ RGB_train
  4. ln -s $YOUR_KINETICS400_DATASET_VAL_DIR$ RGB_val

Note that:

  • The reported models are trained with the Kinetics data provided by Xiaolong Wang.https://github.com/facebookresearch/video-nonlocal-net/blob/master/DATASET.md
  • In train and validation lists for all datasets, each line represents one video where the first element is the video frame directory, the second element is the number of frames and the third element is the index of class. Please prepare your own list accordingly because different video parsing method may lead to different frame numbers. We show part of Kinetics-400 train list as an example:
    1. RGB_train/D32_1gwq35E 300 66
    2. RGB_train/-G-5CJ0JkKY 250 254
    3. RGB_train/4uZ27ivBl00 300 341
    4. RGB_train/pZP-dHUuGiA 240 369
  • This code can read the image files in each video frame folder according to the image template argument image_tmpl, such as image_{:06d}.jpg.

Training

Execute training script:

  1. ./scripts/kinetics400_3d_res50_slowonly_im_pre.sh

We show script kinetics400_3d_res50_slowonly_im_pre.sh here:

  1. python main.py \
  2. kinetics400 \
  3. data/kinetics400/kinetics_train_list_xlw \
  4. data/kinetics400/kinetics_val_list_xlw \
  5. --arch resnet50_3d_slowonly \
  6. --dro 0.5 \
  7. --mode 3D \
  8. --t_length 8 \
  9. --t_stride 8 \
  10. --pretrained \
  11. --epochs 110 \
  12. --batch-size 96 \
  13. --lr 0.02 \
  14. --wd 0.0001 \
  15. --lr_steps 50 80 100 \
  16. --workers 16 \

Testing

  1. python ./test_kaiming.py \
  2. kinetics400 \
  3. data/kinetics400/kinetics_val_list_xlw \
  4. output/kinetics400_resnet50_3d_slowonly_3D_length8_stride8_dropout0.5/model_best.pth \
  5. --arch resnet50_3d_slowonly \
  6. --mode TSN+3D \
  7. --batch_size 1 \
  8. --num_segments 10 \
  9. --input_size 256 \
  10. --t_length 8 \
  11. --t_stride 8 \
  12. --dropout 0.5 \
  13. --workers 12 \
  14. --image_tmpl image_{:06d}.jpg \