示例#1
0
def main():
    """SiamRPN benchmark.
    evaluation according to txt of test result.now supports benchmark is Success and Precision
    Currently only supports test OTB 2015 dataset.

    Parameters
    ----------
    tracker_path : str, txt of test result path.
    tracker_prefix : str, model name.
    test_dataset : str, Path to test label json.
    """
    opt = parse_args()
    tracker_dir = os.path.join(opt.tracker_path, opt.dataset)
    trackers = glob(os.path.join(opt.tracker_path,
                                 opt.dataset,
                                 opt.tracker_prefix+'*'))
    trackers = [x.split('/')[-1] for x in trackers]
    assert len(trackers) > 0
    opt.num = min(opt.num, len(trackers))
    dataset = OTBDataset(name=opt.dataset, dataset_root=opt.test_dataset, load_img=False)
    dataset.set_tracker(tracker_dir, trackers)
    benchmark = OPEBenchmark(dataset)
    success_ret = {}
    with Pool(processes=opt.num) as pool:
        for ret in tqdm(pool.imap_unordered(benchmark.eval_success, trackers),
                        desc='eval success', total=len(trackers), ncols=100):
            success_ret.update(ret)
    precision_ret = {}
    with Pool(processes=opt.num) as pool:
        for ret in tqdm(pool.imap_unordered(benchmark.eval_precision, trackers),
                        desc='eval precision', total=len(trackers), ncols=100):
            precision_ret.update(ret)
    benchmark.show_result(success_ret, precision_ret,
                          show_video_level=opt.show_video_level)
示例#2
0
def main():
    """SiamRPN test.

    function
    ----------
        record the output of the model. The output information of each video is recorded in the txt
    corresponding to the video name.
        if you want to evaluation, you need to python benchmark.py according to txt of text result.
        Currently only supports test OTB 2015 dataset

    Parameters
    ----------
    dataset_root : str, default '~/mxnet/datasets/OTB2015'
                   Path to folder test the dataset.
    model_path :   str, Path of test model .
    results_path:  str, Path to store txt of test reslut .
    """
    opt = parse_args()
    if opt.use_gpu:
        ctx = mx.gpu()
    else:
        ctx = mx.cpu()
    # dataloader
    dataset = OTBDataset(name=opt.dataset,
                         dataset_root=opt.dataset_root,
                         load_img=False)
    net = get_model(opt.model_name, pretrained=True)
    net.collect_params().reset_ctx(ctx)
    if opt.mode == 'hybrid':
        net.hybridize(static_alloc=True, static_shape=True)
    if opt.model_path:
        net.load_parameters(opt.model_path, ctx=ctx)
        print('Pre-trained model %s is successfully loaded.' %
              (opt.model_path))
    else:
        print('Pre-trained model is successfully loaded from the model zoo.')
    # bulid tracker
    tracker = build_tracker(net)
    # record the output of the model.
    test(dataset, tracker, opt, ctx)