模型推理
在使用MMDetection框架完成训练后便可以使用训练所得的权重文件进行推理了,具体可以使用MMDetection
文件下的demo
文件夹的image_demo.py
文件。
from argparse import ArgumentParser
from mmengine.logging import print_log
from mmdet.apis import DetInferencer
def parse_args():
parser = ArgumentParser()
parser.add_argument(
'--inputs', type=str,default="/home/ubuntu/programs/mmdetection/tools/images/4.jpg", help='Input image file or folder path.')
parser.add_argument(
'--model',
type=str,default="/home/ubuntu/programs/mmdetection/output/faster-rcnn_r50_fpn_2x_coco.py",
help='Config or checkpoint .pth file or the model name '
'and alias defined in metafile. The model configuration '
'file will try to read from .pth if the parameter is '
'a .pth weights file.')
parser.add_argument('--weights', default="/home/ubuntu/programs/mmdetection/output//epoch_24.pth", help='Checkpoint file'