Exemple #1
0
def extract_mlp_features(filename):
    features = load_label_feature(filename)

    mlp_features = None
    for feature in features:
        if not feature.HasField('lane') or \
           not feature.lane.HasField('lane_graph'):
            continue
        lane_seq_sz = len(feature.lane.lane_graph.lane_sequence)
        for i in range(lane_seq_sz):
            lane_seq = feature.lane.lane_graph.lane_sequence[i]
            if len(lane_seq.features.mlp_features) != mlp_feature_size:
                continue
            mlp_feature = []
            for i in range(mlp_feature_size):
                mlp_feature.append(lane_seq.features.mlp_features[i])
            mlp_feature.append(lane_seq.label)
            mlp_feature_np = np.array(mlp_feature)
            if mlp_features is None:
                mlp_features = mlp_feature_np
            else:
                mlp_features = np.concatenate((mlp_features, mlp_feature_np),
                                              axis=0)
    if (mlp_features is None) or (np.size(mlp_features) == 0):
        return
    mlp_features = mlp_features.reshape(
        (np.shape(mlp_features)[0] / (mlp_feature_size + 1),
         (mlp_feature_size + 1)))
    return mlp_features
Exemple #2
0
def extract_mlp_features(filename):
    features = load_label_feature(filename)

    mlp_features = None
    for feature in features:
        if not feature.HasField('lane') or \
           not feature.lane.HasField('lane_graph'):
            continue
        lane_seq_sz = len(feature.lane.lane_graph.lane_sequence)
        for i in range(lane_seq_sz):
            lane_seq = feature.lane.lane_graph.lane_sequence[i]
            if len(lane_seq.features.mlp_features) != mlp_feature_size:
                continue
            mlp_feature = []
            for i in range(mlp_feature_size):
                mlp_feature.append(lane_seq.features.mlp_features[i])
            mlp_feature.append(lane_seq.label)
            mlp_feature_np = np.array(mlp_feature)
            if mlp_features is None:
                mlp_features = mlp_feature_np
            else:
                mlp_features = np.concatenate(
                    (mlp_features, mlp_feature_np), axis=0)
    if (mlp_features is None) or (np.size(mlp_features) == 0):
        return
    mlp_features = mlp_features.reshape(
        (np.shape(mlp_features)[0] / (mlp_feature_size + 1),
         (mlp_feature_size + 1)))
    return mlp_features
Exemple #3
0
def extract_mlp_features(filename):
    features = load_label_feature(filename)

    mlp_features = None
    for feature in features:
        if not feature.HasField('lane') or \
           not feature.lane.HasField('lane_graph'):
            continue
        lane_seq_sz = len(feature.lane.lane_graph.lane_sequence)
        for i in range(lane_seq_sz):
            lane_seq = feature.lane.lane_graph.lane_sequence[i]
            if len(lane_seq.features.mlp_features) != mlp_feature_size:
                continue
            mlp_feature = []
            for j in range(mlp_feature_size):
                mlp_feature.append(lane_seq.features.mlp_features[j])
            mlp_feature.append(lane_seq.label)
            mlp_feature.append(lane_seq.time_to_lane_edge)
            mlp_feature.append(lane_seq.time_to_lane_center)
            mlp_feature_np = np.array(mlp_feature)
            if mlp_features is None:
                mlp_features = mlp_feature_np.reshape(
                    1, mlp_feature_size + num_output)
            else:
                mlp_features = np.concatenate(
                    (mlp_features,
                     mlp_feature_np.reshape(1, mlp_feature_size + num_output)),
                    axis=0)

    if (mlp_features is None) or (np.size(mlp_features) == 0):
        return None

    return mlp_features
Exemple #4
0
def extract_mlp_features(filename):
    features = load_label_feature(filename)

    mlp_features = None
    for fea in features:
        if not fea.HasField('junction_feature'):
            continue
        if len(fea.junction_feature.junction_mlp_feature) != mlp_feature_size or \
           len(fea.junction_feature.junction_mlp_label) != mlp_label_size:
            continue
        mlp_feature = []
        for i in range(mlp_feature_size):
            mlp_feature.append(fea.junction_feature.junction_mlp_feature[i])
        for i in range(mlp_label_size):
            mlp_feature.append(fea.junction_feature.junction_mlp_label[i])
        mlp_feature_np = np.array(mlp_feature)
        if mlp_features is None:
            mlp_features = mlp_feature_np.reshape(
                1, mlp_feature_size+mlp_label_size)
        else:
            mlp_features = np.concatenate(
                (mlp_features, mlp_feature_np.reshape(1, mlp_feature_size+mlp_label_size)), axis=0)
    if (mlp_features is None) or (np.size(mlp_features) == 0):
        return
    #mlp_features = mlp_features.reshape(
    #    (np.shape(mlp_features)[0] / (mlp_feature_size + 2),
    #     (mlp_feature_size + 2)))
    return mlp_features