示例#1
0
 def evaluation(self, args, down_ratio):
     save_path = 'weights_' + args.dataset  # 权重放的位置
     self.model = self.load_model(self.model,
                                  os.path.join(save_path, args.resume))
     self.model = self.model.to(self.device)
     self.model.eval()
     result_path = 'result_' + args.dataset  # 根据类别分别存储检测结果
     if not os.path.exists(result_path):
         os.mkdir(result_path)
     dataset_module = self.dataset[args.dataset]
     dsets = dataset_module(data_dir=args.data_dir,
                            phase='test',
                            input_h=args.input_h,
                            input_w=args.input_w,
                            down_ratio=down_ratio)
     func_utils.write_results(args,
                              self.model,
                              dsets,
                              down_ratio,
                              self.device,
                              self.decoder,
                              result_path,
                              print_ps=True)
     if args.dataset == 'dota':
         merge_path = 'merge_' + args.dataset
         if not os.path.exists(merge_path):
             os.mkdir(merge_path)
         dsets.merge_crop_image_results(result_path, merge_path)
         return None
     else:
         ap = dsets.dec_evaluation(result_path)
         return ap
    def dec_eval(self, args, dsets):
        result_path = 'result_' + args.dataset
        if not os.path.exists(result_path):
            os.mkdir(result_path)

        self.model.eval()
        func_utils.write_results(args, self.model, dsets, self.down_ratio,
                                 self.device, self.decoder, result_path)
        ap = dsets.dec_evaluation(result_path)
        return ap