def evaluate_all(distmat, query=None, gallery=None, query_ids=None, gallery_ids=None, query_cams=None, gallery_cams=None, cmc_topk=(1, 5, 10), dataset="veri"): name = {"veri": "VeRi", "vihicleid": "VehicleID"} if query is not None and gallery is not None: query_ids = [label for _, label, _ in query] gallery_ids = [label for _, label, _ in gallery] query_cams = [cam for _, _, cam in query] gallery_cams = [cam for _, _, cam in gallery] else: assert (query_ids is not None and gallery_ids is not None and query_cams is not None and gallery_cams is not None) # Compute mean AP mAP = mean_ap(distmat, query_ids, gallery_ids, query_cams, gallery_cams) dataName = name[dataset] print("------------------------------") print("The result of the dataset({})".format(dataName)) print('Mean AP: {:4.1%}'.format(mAP)) cmc_scores = cmc(distmat, query_ids, gallery_ids, query_cams, gallery_cams) print('CMC Scores:{:4.1%}'.format(cmc_scores[0])) for k in cmc_topk: print(' top-{0:}: {1:4.1%}'.format(k, cmc_scores[k - 1])) # Use the allshots cmc top-1 score for validation criterion return cmc_scores[0]
def rank(dist): r = cmc(dist, self.queryset.ids, self.testset.ids, self.queryset.cameras, self.testset.cameras, separate_camera_set=False, single_gallery_shot=False, first_match_break=True) m_ap = mean_ap(dist, self.queryset.ids, self.testset.ids, self.queryset.cameras, self.testset.cameras) return r, m_ap
def evaluate_all(distmat, query=None, gallery=None, query_ids=None, gallery_ids=None, query_cams=None, gallery_cams=None, cmc_topk=(1, 5, 10), dataset="veri"): name = {"veri": "VeRi", "vihicleid": "VehicleID"} if query is not None and gallery is not None: query_ids = [label for _, label, _ in query] gallery_ids = [label for _, label, _ in gallery] query_cams = [cam for _, _, cam in query] gallery_cams = [cam for _, _, cam in gallery] else: assert (query_ids is not None and gallery_ids is not None and query_cams is not None and gallery_cams is not None) # Compute mean AP mAP = mean_ap(distmat, query_ids, gallery_ids, query_cams, gallery_cams) dataName = name[dataset] print("------------------------------") print("The result of the dataset({})".format(dataName)) print('Mean AP: {:4.1%}'.format(mAP)) # Compute all kinds of CMC scores cmc_configs = { 'allshots': dict(separate_camera_set=False, single_gallery_shot=False, first_match_break=False), 'cuhk03': dict(separate_camera_set=True, single_gallery_shot=True, first_match_break=False), 'market1501': dict(separate_camera_set=False, single_gallery_shot=False, first_match_break=True) } cmc_scores = { name: cmc(distmat, query_ids, gallery_ids, query_cams, gallery_cams, **params) for name, params in cmc_configs.items() } print('CMC Scores{:>12}{:>12}{:>12}'.format('allshots', 'cuhk03', 'market1501')) for k in cmc_topk: print(' top-{:<4}{:12.1%}{:12.1%}{:12.1%}'.format( k, cmc_scores['allshots'][k - 1], cmc_scores['cuhk03'][k - 1], cmc_scores['market1501'][k - 1])) # Use the allshots cmc top-1 score for validation criterion return cmc_scores['allshots'][0]