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...
def init_detector(config, checkpoint=None, device='cuda:0'): """Initialize a detector from config file. Args: config (str or :obj:`mmcv.Config`): Config file path or the config object. checkpoint (str, optional): Checkpoint path. If left as None, the model will not load any weights...
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...
首先需要根据官方教程指引,下载faster_rcnn的权重文件faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth,放置在checkpoints文件夹下。 frommmdet.apisimportinit_detector,inference_detector,show_result_pyplot config_file='configs/faster_rcnn/faster_rcnn_r50_fpn_1x_coco.py' checkpoint...
from mmdet.apis import init_detector, inference_detector config_file = 'configs/faster_rcnn/faster_rcnn_r50_fpn_1x_coco.py' # download the checkpoint from model zoo and put it in `checkpoints/` # url: https://download.openmmlab.com/mmdetection/v2.0/faster_rcnn/faster_rcnn_r50_fpn_1x...
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_...
importmmcvfrommmdet.apisimportinit_detector,inference_detector# 一、指定模型的配置文件和 checkpoint 文件路径# 下载 https://github.com/open-mmlab/mmdetection 项目并解压# 把 mmdetection-master/configs/_base_ 文件夹复制到当前项目 configs/ 目录下# 把 mmdetection-master/configs/faster_rcnn 文件夹复制到当...
from mmdet.apis import init_detector, inference_detector, show_result 1.2 训练自定义数据集 CatDog 1.2.1 准备数据集 创建data 文件夹,软链接到数据集根目录,其中标记好的数据集采用 coco 数据格式, cd mmdetection mkdir data export COCO_ROOT=/data1/Projects/datasets/coco ...
model= init_detector(config_file, device=device) # inference the demo image inference_detector(model,'demo/demo.jpg') 如果报错ModuleNotFoundError, 可以在mmdetection目录下,运行下面代码升级库: python setup.py install 执行完毕,会在mmdetection目录下生产build目录。
from mmdet.apis import init_detector, inference_detector, show_resultimport mmcvconfig_file = 'configs/faster_rcnn_r50_fpn_1x.py'checkpoint_file = 'checkpoints/faster_rcnn_r50_fpn_1x_20181010-3d1b3351.pth'# 从配置文件和检查点文件构建模型model = init_detector(config_file, checkpoint_file, ...