mask-rcnn demo

本文档介绍了在Python中使用maskrcnn-benchmark库进行对象检测时遇到的问题,特别是由于OpenCV版本差异导致的cv2.findContours()函数调用错误。作者提供了详细的配置步骤,包括pytorch和torchvision的版本匹配,以及opencv-python的版本选择。在解决这些问题后,可以成功运行webcam.py脚本的简化示例,展示了一个图像的处理前后的效果。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

bug参考论文:

Python开发:OpenCV版本差异所引发的cv2.findContours()函数传参问题 - 我命倾尘 - 博客园

 

 

官方mask rcnn 地址:

Vedanuj Goswami / vqa-maskrcnn-benchmark · GitLab

https://github.com/Cadene/vqa-maskrcnn-benchmark

meetshah1995 / vqa-maskrcnn-benchmark · GitLab

 我一般直接解压vqa-maskrcnn-benchmark,然后进入目录里,setup.py 运行。

注意:pytorch 版本号和torchvision 版本号,opencv-python 版本号(不能特别高)参考第一个bug链接。

直接;运行webcam.py 有段错误问题,但是具体哪里错了也未指明,可以运行他的小demo 样例

from maskrcnn_benchmark.config import cfg
from predictor import COCODemo
import cv2
import os

config_file = "/home/byd/vqa-maskrcnn-benchmark-master/configs/caffe2/e2e_mask_rcnn_R_50_FPN_1x_caffe2.yaml"

# update the config options with the config file
cfg.merge_from_file(config_file)
# manual override some options
cfg.merge_from_list(["MODEL.DEVICE", "cpu"])

coco_demo = COCODemo(
    cfg,
    min_image_size=800,
    confidence_threshold=0.7,
)
# load image and then run prediction
image = cv2.imread("/home/byd/demo/COCO_val2014_000000218224.jpg")
predictions = coco_demo.run_on_opencv_image(image)
save_path = os.path.join("/home/byd/demo_feats/", "COCO_val2014_000000218224.jpg")
cv2.imwrite(save_path, predictions)

 原图:

处理结果图:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值