前言
B站讲解视频
我的研究生毕业论文方向就是时空行为检测,所以,slowfast和ava是我重点搞的,我的博客主页也有很多这些相关内容。
终于,到了标注数据这一块了,为了更简单的标注数据,我要做的这部分的数据包含大量的人,每张图片有30到40个人,如果要手动框人,再做行为标注,那是非常大的工作量,为了减小工作量,先使用faster rcnn把人的坐标算出来,然后倒入via中,实现算法的自动框人。
1 准备
1.1 detectron2安装及faster rcnn运行
1.1.1 detectron2官方网站
1.1.2 安装步骤
安装:
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
1.1.3 Faster RCNN目标检测
在终端输入:
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
1.1.4 参考
【Faster RCNN & detectron2】detectron2实现Faster RCNN目标检测
1.2 via的安装及使用
安装很简单,下载下来后,点开via.html就可以了
下载及使用指南:via官网
我下载的是2.0的版本,如下
2 faster rcnn 算法导出人类候选框为via格式
2.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 time
import cv2
import tqdm
import os
from detectron2.config import get_cfg
from detectron2.data.detection_utils import read_image
from detectron2.utils.logger import setup_logger
from predic