【代码解析】显示detectron2中faster R-CNN的检测结果,利用visualizer显示

在上一个博客:detectron2实现Faster RCNN目标检测
讲解了如何实现,这一个博客剖析其中一些关键代码。

1,准备及目的

  • detectron2项目地址
  • 目的是跟踪代码,清楚代码的相关部分的作用。

安装:

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

2,Faster RCNN目标检测

步骤和detectron2实现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

3.错误解决

运行过程中可能会出现

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

3,代码跟踪

在代码中设置输出,在终端中观察输出的顺序。

出现的运行代码文件包括:

  1. detectron2_repo/demo/demo.py
  2. detectron2_repo/demo/predictor.py
  3. detectron2/utils/visualizer.py
  • 2
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值