在上一篇博客记录了 SlowFast的复现过程,slowfast其中有一部分是detectron2实现Faster RCNN对人的目标检测。
这一篇博客就单独记录detectron2实现Faster RCNN目标检测的解析
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
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
4. 效果
5.错误解决
运行过程中可能会出现
Traceback (most recent call last):
File “demo.py”, line 7, in
import cv2
File “/opt/conda/lib/python3.7/site-packages/cv2/init.py”, line 5, in
from .cv2 import *
ImportError: libGL.so.1: cannot open shared object file: No such file or directory
解决方案:
在终端运行:
apt update
apt install libgl1-mesa-glx
6.参考博客
Ubuntu18.04 配置detectron2实现Faster RCNN目标检测和Mask RCNN实例分割(一)