Exemplo n.º 1
0
def test_net_on_dataset(args,
                        dataset_name,
                        proposal_file,
                        output_dir,
                        multi_gpu=False,
                        gpu_id=0,
                        include_feat=False):
    """Run inference on a dataset."""
    dataset = JsonDataset(dataset_name)
    test_timer = Timer()
    test_timer.tic()
    if multi_gpu:
        num_images = len(dataset.get_roidb(gt=args.do_val))
        all_results = multi_gpu_test_net_on_dataset(args,
                                                    dataset_name,
                                                    proposal_file,
                                                    num_images,
                                                    output_dir,
                                                    include_feat=include_feat)
    else:
        all_results = test_net(args,
                               dataset_name,
                               proposal_file,
                               output_dir,
                               gpu_id=gpu_id,
                               include_feat=include_feat)
    test_timer.toc()
    logger.info('Total inference time: {:.3f}s'.format(
        test_timer.average_time))

    # logger.info('Starting evaluation now...')
    # task_evaluation.eval_rel_results(all_results, output_dir, args.do_val)

    return all_results
Exemplo n.º 2
0
def get_roidb_and_dataset(dataset_name, proposal_file, ind_range, do_val=True):
    """Get the roidb for the dataset specified in the global cfg. Optionally
    restrict it to a range of indices if ind_range is a pair of integers.
    """
    dataset = JsonDataset(dataset_name)
    roidb = dataset.get_roidb(gt=do_val)

    if ind_range is not None:
        total_num_images = len(roidb)
        start, end = ind_range
        roidb = roidb[start:end]
    else:
        start = 0
        end = len(roidb)
        total_num_images = end

    return roidb, dataset, start, end, total_num_images