Beispiel #1
0
    Args:
        dataset: The dataset returned by ``compute_attr``

    Returns:
        The pairwise distance matrix D
    """

    from sklearn.metrics.pairwise import pairwise_distances as pwdist

    gA, gY, pA, pY = dataset

    return pwdist(gA, pA, 'euclidean')


if __name__ == '__main__':
    data = load_data(['CUHKL'])
    data = decompose(data)
    dataset = preprocess(data)

    import cPickle
    with open('../cache/attr_model.pkl', 'rb') as f:
        model = cPickle.load(f)

    dataset = compute_attr(model, dataset)

    D = compute_distance(dataset)

    from reid.utils import cmc
    cmcret = cmc.count(D, dataset[1], dataset[3], 100)

    print cmcret
Beispiel #2
0
            R[i] = output_func(X[i:i + 1, :]).ravel()
        R = numpy.asarray(R)

        D = cdist(R, Y, 'euclidean')

        G = numpy.asarray([pid for pid, image in data[0]])
        P = numpy.asarray([pid for pid, image in data[1]])

    if save_to_cache:
        with open(_cached_distmat, 'wb') as f:
            cPickle.dump((D, G, P), f, protocol=cPickle.HIGHEST_PROTOCOL)

    with open(_cached_output, 'wb') as f:
        cPickle.dump((X, Y, R), f, protocol=cPickle.HIGHEST_PROTOCOL)

    return (D, G, P)


if __name__ == '__main__':
    views_data, datasets = _prepare_data(load_from_cache=True,
                                         save_to_cache=False)

    model = _train_model(datasets, load_from_cache=False, save_to_cache=True)

    distmat, glabels, plabels = _get_distance(model,
                                              views_data,
                                              load_from_cache=False,
                                              save_to_cache=True)

    print cmc.count(distmat, glabels, plabels, 100)
Beispiel #3
0
        for i in xrange(X.shape[0]):
            R[i] = output_func(X[i:i+1, :]).ravel()
        R = numpy.asarray(R)

        D = cdist(R, Y, 'euclidean')

        G = numpy.asarray([pid for pid, image in data[0]])
        P = numpy.asarray([pid for pid, image in data[1]])

    if save_to_cache:
        with open(_cached_distmat, 'wb') as f:
            cPickle.dump((D, G, P), f, protocol=cPickle.HIGHEST_PROTOCOL)

    with open(_cached_output, 'wb') as f:
        cPickle.dump((X, Y, R), f, protocol=cPickle.HIGHEST_PROTOCOL)

    return (D, G, P)

if __name__ == '__main__':
    views_data, datasets = _prepare_data(load_from_cache=True,
                                         save_to_cache=False)

    model = _train_model(datasets, load_from_cache=False, save_to_cache=True)

    distmat, glabels, plabels = _get_distance(model, views_data,
                                              load_from_cache=False,
                                              save_to_cache=True)

    print cmc.count(distmat, glabels, plabels, 100)

Beispiel #4
0
    Args:
        dataset: The dataset returned by ``compute_attr``

    Returns:
        The pairwise distance matrix D
    """

    from sklearn.metrics.pairwise import pairwise_distances as pwdist

    gA, gY, pA, pY = dataset

    return pwdist(gA, pA, 'euclidean')


if __name__ == '__main__':
    data = load_data(['CUHKL'])
    data = decompose(data)
    dataset = preprocess(data)

    import cPickle
    with open('../cache/attr_model.pkl', 'rb') as f:
        model = cPickle.load(f)

    dataset = compute_attr(model, dataset)

    D = compute_distance(dataset)

    from reid.utils import cmc
    cmcret = cmc.count(D, dataset[1], dataset[3], 100)

    print cmcret