资源算法利用3D残差网络学习时空特征,应用于动作识别场景

利用3D残差网络学习时空特征,应用于动作识别场景

2019-08-19 | |  533 |   0 |   0

3D ResNets for Action Recognition

更新(2018/2/21)

我们的论文“时空3D CNN可以回溯2D CNN和ImageNet的历史吗?” 被CVPR2018接受!
我们更新纸质信息。

更新(2018/01/16)

我们在UCF-101和HMDB-51上传了一些微调模型。

  • ResNeXt-101在UCF-101上进行了微调(split1)

  • 在UCF-101(split1)上微调ResNeXt-101(64帧输入)

  • ResNeXt-101在HMDB-51上进行了微调(split1)

  • 在HMDB-51(split1)上微调ResNeXt-101(64帧输入)

更新(2017/11/27)

我们发表了一篇关于arXiv 的新论文
我们还在此存储库中添加了以下新模型及其Kinetics预训练模型。  

  • ResNet-50,101,152,200

  • 预激活ResNet-200

  • 广泛的ResNet-50

  • ResNeXt-101

  • DenseNet-121,201

此外,我们还支持新的数据集(UCF-101和HDMB-51)和微调功能。

包括一些细微的变化。

  • 在测试中通过softmax对输出进行归一化。

    • 如果您不想执行标准化,请使用--no_softmax_in_test选项。

摘要

这是以下论文的PyTorch代码:

Kensho Hara,Hirokatsu Kataoka和Yutaka Satoh,
“时空3D CNN可以回溯2D CNN和ImageNet的历史吗?”,
arXiv preprint,arXiv:1711.09577,2017。(接受CVPR2018)

Kensho Hara,Hirokatsu Kataoka和Yutaka Satoh,
“用于动作识别的3D残余网络学习时空特征”,
ICCV行动,手势和情感识别研讨会论文集,2017年。

此代码包括对Kinetics,ActivityNet,UCF-101和HMDB-51的培训,微调和测试。
如果您想使用我们的预训练模型对视频进行分类或提取视频功能,请使用此代码

此代码的Torch(Lua)版本可在此处获得
请注意,Torch版本仅包括ResNet-18,34,50,101和152。

引文

如果您使用此代码或预先训练的模型,请引用以下内容:

@article{hara3dcnns,
  author={Kensho Hara and Hirokatsu Kataoka and Yutaka Satoh},
  title={Can Spatiotemporal 3D CNNs Retrace the History of 2D CNNs and ImageNet?},
  journal={arXiv preprint},
  volume={arXiv:1711.09577},
  year={2017},}

预先训练的模型

这里提供预先训练的模型
所有模型都接受了Kinetics的培训。
ResNeXt-101在我们的实验中取得了最佳性能。(详见论文。)

resnet-18-kinetics.pth: --model resnet --model_depth 18 --resnet_shortcut Aresnet-34-kinetics.pth: --model resnet --model_depth 34 --resnet_shortcut Aresnet-34-kinetics-cpu.pth: CPU ver. of resnet-34-kinetics.pthresnet-50-kinetics.pth: --model resnet --model_depth 50 --resnet_shortcut Bresnet-101-kinetics.pth: --model resnet --model_depth 101 --resnet_shortcut Bresnet-152-kinetics.pth: --model resnet --model_depth 152 --resnet_shortcut Bresnet-200-kinetics.pth: --model resnet --model_depth 200 --resnet_shortcut Bpreresnet-200-kinetics.pth: --model preresnet --model_depth 200 --resnet_shortcut Bwideresnet-50-kinetics.pth: --model wideresnet --model_depth 50 --resnet_shortcut B --wide_resnet_k 2resnext-101-kinetics.pth: --model resnext --model_depth 101 --resnet_shortcut B --resnext_cardinality 32densenet-121-kinetics.pth: --model densenet --model_depth 121densenet-201-kinetics.pth: --model densenet --model_depth 201

UCF-101和HMDB-51(拆分1)上的一些微调模型也可用。

resnext-101-kinetics-ucf101_split1.pth: --model resnext --model_depth 101 --resnet_shortcut B --resnext_cardinality 32resnext-101-64f-kinetics-ucf101_split1.pth: --model resnext --model_depth 101 --resnet_shortcut B --resnext_cardinality 32 --sample_duration 64resnext-101-kinetics-hmdb51_split1.pth: --model resnext --model_depth 101 --resnet_shortcut B --resnext_cardinality 32resnext-101-64f-kinetics-hmdb51_split1.pth: --model resnext --model_depth 101 --resnet_shortcut B --resnext_cardinality 32 --sample_duration 64

动力学模型的性能

该表显示了动力学上的前1和前5的平均精度。

| 方法| 准确度| |:--- |:---:| | ResNet-18 | 66.1 | | ResNet-34 | 71.0 | | ResNet-50 | 72.2 | | ResNet-101 | 73.3 | | ResNet-152 | 73.7 | | ResNet-200 | 73.7 | | ResNet-200(预先行动)| 73.4 | | 广泛的ResNet-50 | 74.7 | | ResNeXt-101 | 75.4 | | DenseNet-121 | 70.8 | | DenseNet-201 | 72.3 |

要求

conda install pytorch torchvision cuda80 -c soumith
  • FFmpeg,FFprobe

wget http://johnvansickle.com/ffmpeg/releases/ffmpeg-release-64bit-static.tar.xztar xvf ffmpeg-release-64bit-static.tar.xzcd ./ffmpeg-3.3.3-64bit-static/; sudo cp ffmpeg ffprobe /usr/local/bin;
  • Python 3

制备

ActivityNet

python utils/video_jpg.py avi_video_directory jpg_video_directory
  • 使用生成fps文件 utils/fps.py

python utils/fps.py avi_video_directory jpg_video_directory

动力学

  • 使用官方抓取工具下载视频

    • 找到测试集video_directory/test

  • 使用从avi转换为jpg文件 utils/video_jpg_kinetics.py

python utils/video_jpg_kinetics.py avi_video_directory jpg_video_directory
  • 使用生成n_frames文件 utils/n_frames_kinetics.py

python utils/n_frames_kinetics.py jpg_video_directory
  • 使用类似于ActivityNet的json格式生成注释文件 utils/kinetics_json.py

    • CSV文件(kinetics_ {train,val,test} .csv)包含在爬网程序中。

python utils/kinetics_json.py train_csv_path val_csv_path test_csv_path dst_json_path

UCF-101

  • 在此处下载视频和训练/测试分组

  • 使用从avi转换为jpg文件 utils/video_jpg_ucf101_hmdb51.py

python utils/video_jpg_ucf101_hmdb51.py avi_video_directory jpg_video_directory
  • 使用生成n_frames文件 utils/n_frames_ucf101_hmdb51.py

python utils/n_frames_ucf101_hmdb51.py jpg_video_directory
  • 使用类似于ActivityNet的json格式生成注释文件 utils/ucf101_json.py

    • annotation_dir_path 包括classInd.txt,trainlist0 {1,2,3} .txt,testlist0 {1,2,3} .txt

python utils/ucf101_json.py annotation_dir_path

HMDB-51

  • 在此处下载视频和训练/测试分组

  • 使用从avi转换为jpg文件 utils/video_jpg_ucf101_hmdb51.py

python utils/video_jpg_ucf101_hmdb51.py avi_video_directory jpg_video_directory
  • 使用生成n_frames文件 utils/n_frames_ucf101_hmdb51.py

python utils/n_frames_ucf101_hmdb51.py jpg_video_directory
  • 使用类似于ActivityNet的json格式生成注释文件 utils/hmdb51_json.py

    • annotation_dir_path 包括brush_hair_test_split1.txt,...

python utils/hmdb51_json.py annotation_dir_path

运行代码

假设数据目录的结构如下:

~/
  data/
    kinetics_videos/
      jpg/
        .../ (directories of class names)
          .../ (directories of video names)
            ... (jpg files)
    results/
      save_100.pth
    kinetics.json

确认所有选项。

python main.lua -h

在4个CPU线程的Kinetics数据集(400个类)上训练ResNets-34(用于数据加载)。
批量大小为128.
每5个时期保存模型。所有GPU都用于培训。如果您想要部分GPU,请使用CUDA_VISIBLE_DEVICES=...

python main.py --root_path ~/data --video_path kinetics_videos/jpg --annotation_path kinetics.json --result_path results --dataset kinetics --model resnet --model_depth 34 --n_classes 400 --batch_size 128 --n_threads 4 --checkpoint 5

从纪元101开始继续训练。(〜/ data / results / save_100.pth已加载。)

python main.py --root_path ~/data --video_path kinetics_videos/jpg --annotation_path kinetics.json --result_path results --dataset kinetics --resume_path results/save_100.pth --model_depth 34 --n_classes 400 --batch_size 128 --n_threads 4 --checkpoint 5

在UCF-101上微调预训练模型的conv5_x和fc层(〜/ data / models / resnet-34-kinetics.pth)。

python main.py --root_path ~/data --video_path ucf101_videos/jpg --annotation_path ucf101_01.json --result_path results --dataset ucf101 --n_classes 400 --n_finetune_classes 101 --pretrain_path models/resnet-34-kinetics.pth --ft_begin_index 4 --model resnet --model_depth 34 --resnet_shortcut A --batch_size 128 --n_threads 4 --checkpoint 5

上一篇:情绪发现

下一篇:SSD

用户评价
全部评价

热门资源

  • stanford_corenlp_...

    UPDATE MARCH 2018: this code is obsolete, beyon...

  • tensorflow-sketch...

    Discrlaimer: This is not an official Google pro...

  • Keras-ResNeXt

    Keras ResNeXt Implementation of ResNeXt models...

  • seetafaceJNI

    项目介绍 基于中科院seetaface2进行封装的JAVA...

  • qp_testing

    qp_testing mkdir build cd build cmake .. make