detectron2开源项目位置:
https://github.com/facebookresearch/detectron2
detectron2安装文档:
Installation — detectron2 0.6 documentation
测试demo
python demo.py --config-file ../configs/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x.yaml --input ../test_img/test3.png --opts MODEL.WEIGHTS ../mask_rcnn/model_final_a54504.pkl
MMdetection 项目位置:
https://github.com/open-mmlab/mmdetection
MMdetection安装文档:
测试demo
下载模型并放到checkpoint文件夹下http://download.openmmlab.com/mmdetection/v2.0/faster_rcnn/faster_rcnn_r50_fpn_1x_coco/faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth
在mmdetection目录下创建demo.py ,执行即可看到渲染效果图
from mmdet.apis import init_detector, inference_detector,async_inference_detector, show_result_pyplot
import time
config_file = 'configs/faster_rcnn/faster_rcnn_r50_fpn_1x_coco.py'
# 从 model zoo 下载 checkpoint 并放在 `checkpoints/` 文件下
# 网址为: http://download.openmmlab.com/mmdetection/v2.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'
device = 'cuda:0'
# 初始化检测器
model = init_detector(config_file, checkpoint_file, device=device)
# 推理演示图像
img = 'demo/demo.jpg'
start_time = time.time()
result = inference_detector(model, img)
print("inference cost time:{}s".format(time.time()-start_time))
# print(result)
show_result_pyplot(model, img, result, score_thr=0.3)
版权声明:本文为CSDN博主「blog_1103」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/qq_42393859/article/details/121145478
暂无评论