【导读】在全国电影院复工的第一个周末~ 本文将带来一个基于Pytorch的开源电影分析工具箱,才开基本视频处理、语义特征提取、电影信息爬虫等。
项目网站:
http://movienet.site/
Movienet 包含1.1k 电影,60k预告与375k的meta信息,拥有丰富的对演员、场景的标注,并提供了检测识别、场景分割、电影类型预测等不同类型的任务。
安装
安装需要用到的库
pip install -r requirements.txt
安装pytorch
conda install pytorch torchvision cudatoolkit=10.2 -c pytorch
build movienet-tools
python setup.py develop
下载预训练的模型权重
python scripts/download_models.py
运行demo来确认是否成功安装
python demos/face_demo.py
使用
工具包包括电影爬虫、shot检测器、人脸识别与特征提取、人物识别与特征提取、地点特征提取、动作特征提取、语音特征提取等。
下面以shot检测器为例说明工具包的用法。
shot检测器
为了初始化shot检测器,需要输入源视频输入与输出路径。下面是使用的例子。
from movienet.tools import ShotDetector
# build shot detectors
# if desire to specify detected duration,
# set being/edn_frame/time, otherwise just leave it blank
sdt = ShotDetector(
print_list=True, # print results on command line
save_keyf_txt=True, # save key frame text list
save_keyf=False, # save key frame image
split_video=False, # save split video
begin_frame=0,
end_frame=2000)
# specify source video path and output path
video_path = osp.join('tests', 'data/test1.mp4')
out_dir = osp.join('tests', 'data')
# detect shot and save results
sdt.shotdetect(video_path, out_dir)