(自学之用)
在文章自定义AVA数据集(二)_退即是进的博客-优快云博客 中已经将视频以30帧为间隔进行切割,本文通过faster rcnn 将图片中的人框检测出来,最后将检测的结果转化为via可以识别的csv格式。
1 detectron2地址
地址:mirrors / facebookresearch / detectron2 · GitCode
2 detectron2安装
以下操作都是在AutoDL算力云 | 弹性、好用、省钱。租GPU就上AutoDL 上操作。
我将detectron2安装到/test目录下,所以先进入到此目录:
然后安装:
pip install -U torch torchvision cython
pip install -U 'git+https://github.com/facebookresearch/fvcore.git' 'git+https://github.com/cocodataset/cocoapi.git#subdirectory=PythonAPI'
git clone https://github.com/facebookresearch/detectron2 detectron2_repo
pip install -e detectron2_repo
3 faster rcnn 安装
进入到test/detectron2_repo/demo目录下,
输入命令:
python3 demo.py --config-file ../configs/COCO-Detection/faster_rcnn_R_50_FPN_3x.yaml \
--input ../img/1.jpg \
--output ../img/1_1.jpg \
--opts MODEL.WEIGHTS detectron2://COCO-Detection/faster_rcnn_R_50_FPN_3x/137849458/model_final_280758.pkl
4 via的安装及使用
下载地址:via官网
5 faster rcnn 算法导出人类候选框为via格式
5.1 新建python脚本
在目录/detectron2_repo/demo/下新建一个python脚本,名字为:myvia.py
myvia.py 代码如下:
#Copyright (c) Facebook, Inc. and its affiliates.
import argparse
import glob
import multiprocessing as mp
import os
import tim