Beispiel #1
0
def evaluate_rank(distmat, q_pids, g_pids, q_camids, g_camids, max_rank=50,
                  use_metric_cuhk03=False, use_cython=True):
    """Evaluates CMC rank.

    Args:
        distmat (numpy.ndarray): distance matrix of shape (num_query, num_gallery).
        q_pids (numpy.ndarray): 1-D array containing person identities
            of each query instance.
        g_pids (numpy.ndarray): 1-D array containing person identities
            of each gallery instance.
        q_camids (numpy.ndarray): 1-D array containing camera views under
            which each query instance is captured.
        g_camids (numpy.ndarray): 1-D array containing camera views under
            which each gallery instance is captured.
        max_rank (int, optional): maximum CMC rank to be computed. Default is 50.
        use_metric_cuhk03 (bool, optional): use single-gallery-shot setting for cuhk03.
            Default is False. This should be enabled when using cuhk03 classic split.
        use_cython (bool, optional): use cython code for evaluation. Default is True.
            This is highly recommended as the cython code can speed up the cmc computation
            by more than 10x. This requires Cython to be installed.
    """
    if use_cython and IS_CYTHON_AVAI:
        return evaluate_cy(distmat, q_pids, g_pids, q_camids, g_camids, max_rank, use_metric_cuhk03)
    else:
        return evaluate_py(distmat, q_pids, g_pids, q_camids, g_camids, max_rank, use_metric_cuhk03)
Beispiel #2
0
def evaluate_rank(distmat,
                  q_pids,
                  g_pids,
                  q_camids,
                  g_camids,
                  max_rank=50,
                  use_metric_cuhk03=False,
                  use_metric_market1501=False,
                  use_metric_mars=False,
                  use_cython=True):
    """
    Evaluate CMC and mAP.
    :param distmat: (numpy.ndarray): distance matrix of shape (num_query, num_gallery).
    :param q_pids: (numpy.ndarray): 1-D array containing person identities of each query instance.
    :param g_pids: (numpy.ndarray): 1-D array containing person identities of each gallery instance.
    :param q_camids: 1-D array containing camera views under which each query instance is captured.
    :param g_camids: 1-D array containing camera views under which each gallery instance is captured.
    :param max_rank: maximum CMC rank to be computed. Default is 50.
    :param use_metric_cuhk03:
    :param use_metric_market1501:
    :param use_metric_mars:
    :param use_metric_dukev: same as use_metric_mars
    :param use_cython:
    :return:
    """
    if use_metric_market1501 or use_metric_cuhk03:
        if use_cython and IS_CYTHON_AVAI:
            return evaluate_cy(distmat, q_pids, g_pids, q_camids, g_camids,
                               max_rank, use_metric_cuhk03)
        else:
            return evaluate_py(distmat, q_pids, g_pids, q_camids, g_camids,
                               max_rank, use_metric_cuhk03)
    elif use_metric_mars:
        return evaluate_mars(distmat, q_pids, g_pids, q_camids, g_camids,
                             max_rank)