示例#1
0
    def test(self):
        self.cfg.model_flow = 'test'
        print('======test======')

        score_strs = []
        score_summary = []
        for test_dataset_name, test_dict in self.test_loader.items():
            self.cfg.eval.test_feat_cache_file = osp.join(self.cfg.log.exp_dir, '{}_to_{}_feat_cache.pkl'.format(
                self.cfg.dataset.train.source.name, test_dataset_name))
            self.cfg.eval.score_prefix = '{} -> {}'.format(self.cfg.dataset.train.source.name, test_dataset_name).ljust(30)
            score_dict = evaluation_creation(self.model_for_eval,
                                             test_dict['query'],
                                             test_dict['gallery'],
                                             deepcopy(self.cfg))
            score_strs.append(score_dict['scores_str'])
            score_summary.append("{}->{}: {} ({})".format(self.cfg.dataset.train.source.name,
                                                          test_dataset_name,
                                                          score_str(score_dict['cmc_scores'][0]).replace('%', ''),
                                                          score_str(score_dict['mAP']).replace('%', '')))

        score_str_ = join_str(score_strs, '\n')
        score_summary = ('Epoch {}'.format(self.current_ep)).ljust(12) + ', '.join(score_summary) + '\n'
        write_to_file(self.cfg.log.score_file, score_summary, append=True)

        self.cfg.model_flow = 'train'
        return score_str_
示例#2
0
 def _evaluation(self, score_strs, score_summary, test_dataset_name,
                 test_dict, use_gcn, use_gm):
     score_dict = evaluation_creation(self.model_for_eval,
                                      test_dict['query'],
                                      test_dict['gallery'],
                                      deepcopy(self.cfg),
                                      use_gcn=use_gcn,
                                      use_gm=use_gm)
     score_strs.append(score_dict['scores_str'])
     score_summary.append("{}->{}: {} ({})".format(
         self.cfg.dataset.train.source.name, test_dataset_name,
         score_str(score_dict['cmc_scores'][0]).replace('%', ''),
         score_str(score_dict['mAP']).replace('%', '')))
示例#3
0
def get_scores_str(mAP, CMC_scores, score_prefix):
    return score_prefix + '[mAP: {}], [cmc1: {}], [cmc5: {}], [cmc10: {}]'.format(
        score_str(mAP), score_str(CMC_scores[0]), score_str(CMC_scores[4]), score_str(CMC_scores[9]))