object has no attribute ‘show_result‘,mmdetection3.0最新检测方法

之前是使用 show_result 来绘制检测结果,并保存,现在已经无法使用,会报错
‘xxx Model’ object has no attribute ‘show_result’

最新的方法如下:

# -*- coding: UTF-8 -*-

import os
from mmdet.apis import init_detector, inference_detector
from mmdet.registry import VISUALIZERS
import mmcv

# 使用前修改下面的路径
image_path = r'E:\Models\mmdetection-3.0.0\data\coco\test\JPEGImages'
savepath = r'E:\Models_exp\mmdetection\yolact\save_for_clamp'

config_file = r'E:\Models\mmdetection-3.0.0\work_dirs\yolact_r50_1xb8-55e_coco_clamp\yolact_r50_1xb8-55e_coco_clamp.py'
checkpoint_file = r'E:\Models\mmdetection-3.0.0\work_dirs\yolact_r50_1xb8-55e_coco_clamp\epoch_55.pth'

# gpu 不行 会 Out of memory
device = 'cuda:0'

model = init_detector(config_file, checkpoint_file, device=device)

visualizer = VISUALIZERS.build(model.cfg.visualizer)
# the dataset_meta is loaded from the checkpoint and
# then pass to the model in init_detector
visualizer.dataset_meta = model.dataset_meta

for filename in os.listdir(image_path):
    imgpath = os.path.join(image_path, filename)

    print('process ', imgpath)
    img = mmcv.imread(imgpath)
    result = inference_detector(model, img)
    out_file = os.path.join(savepath, filename)

    ### old implementation invalid
    # show_result_pyplot(model, img, result, out_file, score_thr=0.3)
    ###

    # show the results
    visualizer.add_datasample('result',
                              img, data_sample=result,
                              draw_gt=False,
                              wait_time=0,
                              out_file=out_file,
                              pred_score_thr=0.3
                              )
    # vis
    # visualizer.show()
    # break

有问题,后期维护更新,欢迎留言、进群讨论或私聊:【群号:392784757】

  • 9
    点赞
  • 27
    收藏
    觉得还不错? 一键收藏
  • 23
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 23
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值