def single_gpu_test(model, data_loader, show=False, out_dir=None, show_score_thr=0.3):
    model.eval()
    results = []
    dataset = data_loader.dataset
    prog_bar = mmcv.ProgressBar(len(dataset))
    for (i, data) in enumerate(data_loader):
        with torch.no_grad():
            result = model(return_loss=False, rescale=True, **data)
        batch_size = len(result)
        if (show or out_dir):
            if ((batch_size == 1) and isinstance(data['img'][0], torch.Tensor)):
                img_tensor = data['img'][0]
            else:
                img_tensor = data['img'][0].data[0]
            img_metas = data['img_metas'][0].data[0]
            imgs = tensor2imgs(img_tensor, **img_metas[0]['img_norm_cfg'])
            assert (len(imgs) == len(img_metas))
            for (i, (img, img_meta)) in enumerate(zip(imgs, img_metas)):
                (h, w, _) = img_meta['img_shape']
                img_show = img[:h, :w, :]
                (ori_h, ori_w) = img_meta['ori_shape'][:(- 1)]
                img_show = mmcv.imresize(img_show, (ori_w, ori_h))
                if out_dir:
                    out_file = osp.join(out_dir, img_meta['ori_filename'])
                else:
                    out_file = None
                model.module.show_result(img_show, result[i], show=show, out_file=out_file, score_thr=show_score_thr)
        if isinstance(result[0], tuple):
            result = [(bbox_results, encode_mask_results(mask_results)) for (bbox_results, mask_results) in result]
        results.extend(result)
        for _ in range(batch_size):
            prog_bar.update()
    return results
def single_gpu_test(model, data_loader, show=False, out_dir=None, show_score_thr=0.3):
    model.eval()
    results = []
    dataset = data_loader.dataset
    prog_bar = mmcv.ProgressBar(len(dataset))
    for (i, data) in enumerate(data_loader):
        with torch.no_grad():
            result = model(return_loss=False, rescale=True, **data)
        batch_size = len(result)
        if (show or out_dir):
            if ((batch_size == 1) and isinstance(data['img'][0], torch.Tensor)):
                img_tensor = data['img'][0]
            else:
                img_tensor = data['img'][0].data[0]
            img_metas = data['img_metas'][0].data[0]
            imgs = tensor2imgs(img_tensor, **img_metas[0]['img_norm_cfg'])
            assert (len(imgs) == len(img_metas))
            for (i, (img, img_meta)) in enumerate(zip(imgs, img_metas)):
                (h, w, _) = img_meta['img_shape']
                img_show = img[:h, :w, :]
                (ori_h, ori_w) = img_meta['ori_shape'][:(- 1)]
                img_show = mmcv.imresize(img_show, (ori_w, ori_h))
                if out_dir:
                    out_file = osp.join(out_dir, img_meta['ori_filename'])
                else:
                    out_file = None
                model.module.show_result(img_show, result[i], show=show, out_file=out_file, score_thr=show_score_thr)
        if isinstance(result[0], tuple):
            result = [(bbox_results, encode_mask_results(mask_results)) for (bbox_results, mask_results) in result]
        results.extend(result)
        for _ in range(batch_size):
            prog_bar.update()
    return results