model=init_detector(config_file,checkpoint_file,device=device)# 推理演示图像 img='img/demo.jpg'result=inference_detector(model,img)show_result_pyplot(model,img,result,score_thr=0.3) 加载模型主要通过init_detector这个函数,注意模型的config_file文件和模型权重必须对应。 运行之后,输出下图。 这里顺便对con...
apis import init_detector, inference_detector, show_result config_file = 'configs/faster_rcnn/faster_rcnn_r50_fpn_1x_coco.py' checkpoint_file = 'checkpoints/faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth' # 初始化检测器 model = init_detector(config_file, checkpoint_file, device='cu...
在mmdet里面集成了很多现成的api也可以直接用来查看检测结果,这里写一个简单的调用方法。 from mmdet.apis import init_detector, inference_detector, show_result_pyplot import cv2 import numpy as np # config文件地址 config_file = 'others_ct/ct_head_mask_rcnn_r50_rpn_100_coco/mask_rcnn_r50_fpn_1x...
# 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 and show the results img = 'test.jpg' # or img = mmcv.imread(img), which will only load it once result = inference_detector(model...
model = init_detector(config_file, checkpoint_file, device='cuda:0') image = mmcv.imread('demo/demo.jpg',channel_order='rgb')result = inference_detector(model, image) from mmdet.registryimportVISUALIZERSvisualizer = VISUALIZERS.build(model.cfg...
inference_detector(model,'demo/demo.jpg') 如果报错ModuleNotFoundError, 可以在mmdetection目录下,运行下面代码升级库: python setup.py install 执行完毕,会在mmdetection目录下生产build目录。 如果还不行,就再执行下 python setup.py develop 然后就可以运行成功了!
import mmcv import os import numpy as np from mmcv.runner import load_checkpoint from mmdet.models import build_detector from mmdet.apis import init_detector, inference_detector, show_result config_file = 'configs/faster_rcnn_voc.py' checkpoint_file = 'work_dirs/faster_rcnn_voc/epoch_24.pth...
在使用result=inference_detector(model,img)测试单张图片时,返回对应类别数长度的list,其中元素是每一类的bbox,五个值分别代表框的左上角、右下角坐标,以及置信度。 (6)后台执行命令:&后台执行,nohup服务器链接断了还能运行程序 nohup python test.py> test.log 2>&1& ...
faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth'# build the model from a config file and a checkpoint filemodel = init_detector(config_file, checkpoint_file, device='cuda:0')# test a single imageimg ='demo.jpg'result = inference_detector(model, img)# show the resultsshow_result_...
安装好 mmdetection 之后,就想好好学学,现在就边学边记。先从最简单的模型推理开始,参考MMlab 的教程就好啦:https://github.com/open-mmlab/OpenMMLabCourse,清晰易懂! 首先试试RetinaNet: # mmdet常见的推理apifrommmdet.apisimportinit_detector,inference_detector,show_result_pyplot# mmcv是mmdet之类的通用库import...