因为我之前好多包版本有问题,我反复弄了两边,最后我确定没问题了就去跑demo,然后发现。
官方给的demo
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_coco/faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth
checkpoint_file = 'checkpoints/faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth'
device = 'cuda:0'
# init a detector
model = init_detector(config_file, checkpoint_file, device=device)
# inference the demo image
inference_detector(model, 'demo/demo.jpg')
这里面没存储图片啊,汗
然后我从网上找的demo
from mmdet.apis import init_detector, inference_detector, show_result
import mmcv
config_file = '../configs/retinanet_r50_fpn_1x.py'
checkpoint_file = '../checkpoints/retinanet_r50_fpn_1x_20181125-7b0c2548.pth'
# 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 = 'demo.jpg' # or img = mmcv.imread(img), which will only load it once
result = inference_detector(model, img)
# visualize the results in a new window
show_result(img, result, model.CLASSES)
# or save the visualization results to image files
show_result(img, result, model.CLASSES, out_file='result.jpg')
他这个是18年写的程序,mmdet更新以后都吗show_result这个函数删了,我拿这个model.show_result调用才跑起来,可能就是因为这样才一直报错。然后我把人家的一行代码删了终于出结果了,就是准确率很低,可能是demo程序不行,因为我返工了两边,所以把服务器的数据集删了,我先上传着,先睡了,明天再试试训练。