此处提供预训练模型。所有模型都在 Kinetics-700 ( K )、Moments in Time ( M )、STAIR-Actions ( S ) 或它们的合并数据集(KM、KS、MS、KMS) 上进行训练。 如果您想微调数据集上的模型,您应该指定以下选项。
r3d18_K_200ep.pth: --model resnet --model_depth 18 --n_pretrain_classes 700
r3d18_KM_200ep.pth: --model resnet --model_depth 18 --n_pretrain_classes 1039
r3d34_K_200ep.pth: --model resnet --model_depth 34 --n_pretrain_classes 700
r3d34_KM_200ep.pth: --model resnet --model_depth 34 --n_pretrain_classes 1039
r3d50_K_200ep.pth: --model resnet --model_depth 50 --n_pretrain_classes 700
r3d50_KM_200ep.pth: --model resnet --model_depth 50 --n_pretrain_classes 1039
r3d50_KMS_200ep.pth: --model resnet --model_depth 50 --n_pretrain_classes 1139
r3d50_KS_200ep.pth: --model resnet --model_depth 50 --n_pretrain_classes 800
r3d50_M_200ep.pth: --model resnet --model_depth 50 --n_pretrain_classes 339
r3d50_MS_200ep.pth: --model resnet --model_depth 50 --n_pretrain_classes 439
r3d50_S_200ep.pth: --model resnet --model_depth 50 --n_pretrain_classes 100
r3d101_K_200ep.pth: --model resnet --model_depth 101 --n_pretrain_classes 700
r3d101_KM_200ep.pth: --model resnet --model_depth 101 --n_pretrain_classes 1039
r3d152_K_200ep.pth: --model resnet --model_depth 152 --n_pretrain_classes 700
r3d152_KM_200ep.pth: --model resnet --model_depth 152 --n_pretrain_classes 1039
r3d200_K_200ep.pth: --model resnet --model_depth 200 --n_pretrain_classes 700
r3d200_KM_200ep.pth: --model resnet --model_depth 200 --n_pretrain_classes 1039
此处仍然提供旧的预训练模型。 但是,需要进行一些修改才能在当前脚本中使用旧的预训练模型。
[hidecontent type="logged" desc="隐藏内容:登录后可查看"]
conda install pytorch torchvision cudatoolkit=10.1 -c soumith
FFmpeg, FF探针
python3
util_scripts/generate_video_jpgs.py
python -m util_scripts.generate_video_jpgs mp4_video_dir_path jpg_video_dir_path activitynet
util_scripts/add_fps_into_activitynet_json.py
python -m util_scripts.add_fps_into_activitynet_json mp4_video_dir_path json_file_path
video_directory/test
。util_scripts/generate_video_jpgs.py
python -m util_scripts.generate_video_jpgs mp4_video_dir_path jpg_video_dir_path kinetics
util_scripts/kinetics_json.py
python -m util_scripts.kinetics_json csv_dir_path 700 jpg_video_dir_path jpg dst_json_path
util_scripts/generate_video_jpgs.py
python -m util_scripts.generate_video_jpgs avi_video_dir_path jpg_video_dir_path ucf101
util_scripts/ucf101_json.py
annotation_dir_path
包括 classInd.txt, trainlist0{1, 2, 3}.txt, testlist0{1, 2, 3}.txtpython -m util_scripts.ucf101_json annotation_dir_path jpg_video_dir_path dst_json_path
util_scripts/generate_video_jpgs.py
python -m util_scripts.generate_video_jpgs avi_video_dir_path jpg_video_dir_path hmdb51
util_scripts/hmdb51_json.py
annotation_dir_path
包括 brush_hair_test_split1.txt,...python -m util_scripts.hmdb51_json annotation_dir_path jpg_video_dir_path dst_json_path
假设数据目录的结构如下:
~/
data/
kinetics_videos/
jpg/
.../ (directories of class names)
.../ (directories of video names)
... (jpg files)
results/
save_100.pth
kinetics.json
确认所有选项。
python main.py -h
使用 4 个 CPU 线程(用于数据加载)在 Kinetics-700 数据集(700 个类)上训练 ResNets-50。
批量大小为 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 50 --n_classes 700 --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 50 --n_classes 700 --batch_size 128 --n_threads 4 --checkpoint 5
使用经过训练的模型 (~/data/results/save_200.pth.) 计算每个视频的前 5 类概率。
请注意,它inference_batch_size
应该很小,因为实际批量大小是由inference_batch_size * (n_video_frames / inference_stride)
.
python main.py --root_path ~/data --video_path kinetics_videos/jpg --annotation_path kinetics.json \
--result_path results --dataset kinetics --resume_path results/save_200.pth \
--model_depth 50 --n_classes 700 --n_threads 4 --no_train --no_val --inference --output_topk 5 --inference_batch_size 1
评估识别结果的 top-1 视频准确度 (~/data/results/val.json)。
python -m util_scripts.eval_accuracy ~/data/kinetics.json ~/data/results/val.json --subset val -k 1 --ignore
在 UCF-101 上微调预训练模型 (~/data/models/resnet-50-kinetics.pth) 的 fc 层。
python main.py --root_path ~/data --video_path ucf101_videos/jpg --annotation_path ucf101_01.json \
--result_path results --dataset ucf101 --n_classes 101 --n_pretrain_classes 700 \
--pretrain_path models/resnet-50-kinetics.pth --ft_begin_module fc \
--model resnet --model_depth 50 --batch_size 128 --n_threads 4 --checkpoint 5
[/hidecontent]