使用MMDetection进行目标检测

编程入门 行业动态 更新时间:2024-10-11 19:17:23

使用MMDetection进行<a href=https://www.elefans.com/category/jswz/34/1770031.html style=目标检测"/>

使用MMDetection进行目标检测

首先需要按照官方文档在本机的电脑上安装好MMDetection,不熟悉的小伙伴可以看我下面的这篇教程。
mmdetection的使用_dejahu的博客-CSDN博客
安装好mmdetection后,对图片和视频进行目标检测非常简单,只需要3个文件即可

  • 模型的配置文件
  • 模型文件
  • 需要进行推理的图片或者视频

详细的代码如下:

from mmdet.apis import init_detector, inference_detector, show_result_pyplot
import mmcvconfig_file = '../configs/faster_rcnn/faster_rcnn_r50_fpn_1x_coco.py'
# download the checkpoint from model zoo and put it in `checkpoints/`
# url: .0/faster_rcnn/faster_rcnn_r50_fpn_1x_coco/faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth
checkpoint_file = '../checkpoints/faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth'# build the model from a config file and a checkpoint file
model = init_detector(config_file, checkpoint_file, device='cuda:0')# test a single image
img = 'demo.jpg'
result = inference_detector(model, img)# show the results
show_result_pyplot(model, img, result)

可视化的效果如下,boundingbox左上方的文字分别表示类别和置信度。

更多推荐

使用MMDetection进行目标检测

本文发布于:2024-03-08 13:24:51,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1721000.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:目标   MMDetection

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!