from mmdet.apis import init_detector, inference_detector, show_result_pyplot image = 'data/kitti_tiny/training/image_2/000066.jpeg' model = init_detector('retinanet_r18_fpn_1x_kitti.py', 'work_dirs/retinanet_r18_fpn_1x_kitti/latest.pth') result = inference_detector(model, image) show_...
为了查看模型的结构和参数,首先需要加载模型。在MMDetection中,模型通常是通过配置文件(config file)来定义的。以下是一个加载模型的示例代码: python from mmdet.apis import init_detector # 指定配置文件的路径 config_file = 'path/to/your/config_file.py' # 指定预训练模型权重文件的路径 checkpoint_file = ...
Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/xavier3/mmdetection/mmdet/apis/__init__.py", line 2, in <module> from .inference import (async_inference_detector, inference_detector, File "/home/xavier3/mmdetection/mmdet/apis/inference.py", line ...
init_detector(config_file, checkpoint_file, device='cuda:0') # 测试单张图片并展示结果 img = os.path.join(base_dir, r'demo\demo.jpg') # 或者 img = mmcv.imread(img),这样图片仅会被读一次 result = inference_detector(model, img) # 在一个新的窗口中将结果可视化 model.show_result(img, ...
importtorchfrommmdet.apisimportinit_detector,inference_detector# Load the model from config fileconfig_file='configs/faster_rcnn/faster_rcnn_r50_fpn_1x_coco.py'checkpoint_file='checkpoints/faster_rcnn_r50_fpn_1x_coco.pth'model=init_detector(config_file,checkpoint_file,device='cuda:0') ...
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...
importmmcvfrommmdet.apisimportinference_detector, init_detector, show_result_pyplot 下载并初始化预训练模型: !wget https://download.openmmlab.com/mmdetection/v2.0/fcos/fcos_r50_caffe_fpn_gn-head_4x4_1x_coco/fcos_r50_caffe_fpn_gn-head_4x4_1x_coco_20200229-4c4fc3ad.pth ...
File"/home/mmxsrt/sg-pcr-client/pr_handler_new.py", line4,in<module>from mmdet.apis import init_detector, inference_detector, show_result File"/mmdetection/mmdet/__init__.py", line1,in<module>from .version import __version__, short_version ...
then pass to the model in init_detector visualizer.dataset_meta = model.dataset_meta path to the image you want to test img = 'demo/demo.jpg' img = cv2.imread(img) apply the model to the image and get the output result = inference_detector(model, img) ...
importtorchfrommmdet.apisimportinit_detector,inference_detector,show_result_pyplot 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='...