detectron2开源项目位置:
detectron2安装文档:
测试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 项目位置:
MMdetection安装文档:
测试demo
在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)
Original: https://blog.csdn.net/qq_42393859/article/details/121145478
Author: blog_1103
Title: 计算机视觉之目标检测库安装记录
原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/687488/
转载文章受原作者版权保护。转载请注明原作者出处!