Ejemplo n.º 1
0
def load_dagger_generator(args):
    port = args.port
    ports = args.ports
    assert ports
    assert port in ports
    assert args.dataset_name
    assert args.eval_dataset_name
    port_index = ports.index(port)

    eval_param = Parameter()
    eval_param.exp_index = args.exp_index
    eval_param.exp_name = args.exp_name
    eval_param.load()
    eval_param.batch_size = 1
    eval_param.dataset_data_names = [args.dataset_name]
    eval_param.eval_data_name = args.eval_dataset_name
    eval_param.max_data_length = -1

    if eval_param.split_train:
        train_dataset, valid_dataset = fetch_dataset_pair(eval_param)
    else:
        train_dataset = fetch_dataset(eval_param)

    num_data = len(train_dataset)
    index_func = partial(fetch_index_from_road_option,
                         low_level=eval_param.use_low_level_segment)
    data_list = []
    for i in range(num_data):
        # road_option, data_frame = train_dataset.get_trajectory_data(i)
        # images = data_frame.images
        # drives = data_frame.drives
        # fixme: this may not work if train_dataset is a HighLevelDataset? Cuz it does not even have this method!
        road_option, images, drives = train_dataset.get_trajectory_data(i)
        data_list.append({
            'road_option': road_option,
            'action_index': index_func(road_option),
            'src_transform': drives[0].state.transform,
            'dst_location': drives[-1].state.transform.location,
            'length': len(images)
        })

    def chunker_list(seq, size):
        return (seq[i::size] for i in range(size))

    index_data_lists = list(
        chunker_list(list(enumerate(data_list)), len(ports)))
    index_data_list = index_data_lists[port_index]
    return DaggerGeneratorEnvironment(args, eval_param, index_data_list)
Ejemplo n.º 2
0
def _prepare_evaluation_param(param: Parameter) -> Parameter:
    assert param.eval_data_name
    assert param.eval_info_name
    assert param.eval_keyword
    if param.model_level == 'low':
        param.eval_keyword = fetch_road_option_from_str(param.eval_keyword.upper())
    elif param.model_level == 'high':
        param.eval_keyword = param.eval_keyword.lower()
    else:
        logger.info(param.model_level)
        raise TypeError('invalid eval_keyword was given {}'.format(param.eval_keyword))
    param.max_data_length = -1
    param.shuffle = False
    param.batch_size = 1
    param.dataset_data_names = [param.eval_data_name]
    param.dataset_info_names = [param.eval_info_name]
    if param.model_level == 'low':
        param.use_multi_cam = False
        param.use_sequence = False
        param.has_clusters = False
    return param