MMDetection3.0以上推理

MMDetection3.0以上推理

mmdetection3.02以后推理代码有所更改,具体代码为:

from mmdet.apis import inference_detector, init_detector  #, show_result_pyplot
from mmdet.apis import DetInferencer

def main():
    # config文件
    config_file = 'work_dirs/retinanet-TinyCityPerson/retinanet_r50_fpn_1x_coco.py'
    # 训练好的模型
    checkpoint_file = 'work_dirs/retinanet-TinyCityPerson/epoch_12.pth'
 	#初始化推理器
    inferencer = DetInferencer(model = config_file, weights = checkpoint_file)
    imgs_path = "sssssss"#这里放图片路径
    out_dir = “sss”#这里放输出路径
    inferencer(imgs_path , out_dir=out_dir )

if __name__== '__main__':
	main()

如需更改画框颜色和删除类别名,需要在 ./mmdet/visualizetion/local_visualizer.py中更改画框颜色和类别名显示。

你可能感兴趣的:(python,目标检测,人工智能,计算机视觉,深度学习)