示例#1
0
 def test_compute_cls_map_gt_half(self):
   rand_inds = np.random.permutation(range(5011))[:2500]
   table_gt_half = Table()
   table_gt_half.arr = np.hstack((self.trainval_gt.arr,np.array(np.arange(5011), ndmin=2).T))
   table_gt_half.arr = table_gt_half.arr[rand_inds,:]
   table_gt_half.cols = list(self.trainval_gt.cols) + ['img_ind']
   res = Evaluation.compute_cls_map(table_gt_half, self.trainval_gt)
   assert(round(res,6) == 1)
示例#2
0
 def test_compute_cls_map_half(self):
   table_csc_half = Table()
   table_csc_half.cols = list(self.csc_trainval.cols)
   for _ in range(10):
     rand_inds = np.random.permutation(range(5011))[:2500]
     table_csc_half.arr = self.csc_trainval.arr[rand_inds,:]      
     res = Evaluation.compute_cls_map(table_csc_half, self.trainval_gt)
     assert(round(res,6) > .45)
示例#3
0
 def test_compute_cls_map_half(self):
     table_csc_half = Table()
     table_csc_half.cols = list(self.csc_trainval.cols)
     for _ in range(10):
         rand_inds = np.random.permutation(range(5011))[:2500]
         table_csc_half.arr = self.csc_trainval.arr[rand_inds, :]
         res = Evaluation.compute_cls_map(table_csc_half, self.trainval_gt)
         assert (round(res, 6) > .45)
示例#4
0
 def test_compute_cls_map_gt_half(self):
     rand_inds = np.random.permutation(range(5011))[:2500]
     table_gt_half = Table()
     table_gt_half.arr = np.hstack(
         (self.trainval_gt.arr, np.array(np.arange(5011), ndmin=2).T))
     table_gt_half.arr = table_gt_half.arr[rand_inds, :]
     table_gt_half.cols = list(self.trainval_gt.cols) + ['img_ind']
     res = Evaluation.compute_cls_map(table_gt_half, self.trainval_gt)
     assert (round(res, 6) == 1)
示例#5
0
 def test_compute_cls_map_random_clf(self):
   clf_table = Table()
   num_test = 10
   ress = np.zeros((num_test,))
   for idx in range(num_test):
     clf_table.arr = np.hstack((np.random.rand(5011, 20),np.array(np.arange(5011), ndmin=2).T))
     clf_table.cols = list(self.trainval_gt.cols) + ['img_ind']
     res = Evaluation.compute_cls_map(clf_table, self.trainval_gt)
     ress[idx] = res
   assert(np.mean(ress) < 0.09)
示例#6
0
 def test_compute_cls_map_random_clf(self):
     clf_table = Table()
     num_test = 10
     ress = np.zeros((num_test, ))
     for idx in range(num_test):
         clf_table.arr = np.hstack(
             (np.random.rand(5011, 20), np.array(np.arange(5011),
                                                 ndmin=2).T))
         clf_table.cols = list(self.trainval_gt.cols) + ['img_ind']
         res = Evaluation.compute_cls_map(clf_table, self.trainval_gt)
         ress[idx] = res
     assert (np.mean(ress) < 0.09)
  train_gt = d_train.get_cls_ground_truth()
  val_gt = d_val.get_cls_ground_truth()

  if mpi.comm_rank == 0:
    filename = os.path.join(config.get_classifier_dataset_dirname(CSCClassifier('default','dog', d_train, d_val), d_train),'crossval.txt')
  
  kernels =  ['linear']
  Cs = [50]
  
  settings = list(itertools.product(kernels, Cs))
  
  for setin in settings:
    kernel = setin[0]
    C = setin[1]
    
    #train_csc_svms(d_train, d_val, kernel, C)
    safebarrier(comm)
    table_arr = test_csc_svm(d_train, d_val)
    
    safebarrier(comm)
    
    if mpi.comm_rank == 0:
      table = conv(d_val, table_arr)
      cPickle.dump(table, open(os.path.join(config.get_ext_dets_foldname(d_val),'table'),'w'))
      
      res = Evaluation.compute_cls_map(table, val_gt)
      res_file = open(filename,'a')
      res_file.write('%s, C=%d - %f\n'%(kernel, C, res))
      res_file.close()
      print res
示例#8
0
            'crossval.txt')

    kernels = ['linear']
    Cs = [50]

    settings = list(itertools.product(kernels, Cs))

    for setin in settings:
        kernel = setin[0]
        C = setin[1]

        #train_csc_svms(d_train, d_val, kernel, C)
        safebarrier(comm)
        table_arr = test_csc_svm(d_train, d_val)

        safebarrier(comm)

        if mpi.comm_rank == 0:
            table = conv(d_val, table_arr)
            cPickle.dump(
                table,
                open(
                    os.path.join(config.get_ext_dets_foldname(d_val), 'table'),
                    'w'))

            res = Evaluation.compute_cls_map(table, val_gt)
            res_file = open(filename, 'a')
            res_file.write('%s, C=%d - %f\n' % (kernel, C, res))
            res_file.close()
            print res
示例#9
0
 def test_other_scores(self):
   print 'csc_test', Evaluation.compute_cls_map(self.csc_test, self.test_gt)
   print 'csc_trainval', Evaluation.compute_cls_map(self.csc_trainval, self.trainval_gt)
   
   print 'ext_test', Evaluation.compute_cls_map(self.ext_csc_test, self.test_gt)
   print 'ext_trainval', Evaluation.compute_cls_map(self.ext_csc_trainval, self.trainval_gt)
   
   filename = os.path.join(config.get_ext_dets_foldname(self.d_test), 'dp', 'table_chi2_20')
   ext_table_chi2_20 = cPickle.load(open(filename, 'r'))
   print 'ext_chi2_20_test', Evaluation.compute_cls_map(ext_table_chi2_20, self.test_gt)    
   
   filename = os.path.join(config.get_ext_dets_foldname(self.d_train), 'dp', 'table_chi2_20')
   ext_table_chi2_20_tv = cPickle.load(open(filename, 'r'))
   print 'ext_chi2_20_trainval', Evaluation.compute_cls_map(ext_table_chi2_20_tv, self.trainval_gt)
   
   filename = os.path.join(config.get_ext_dets_foldname(self.d_test), 'dp', 'table_rbf_20')
   ext_table_rbf_20 = cPickle.load(open(filename, 'r'))
   print 'ext_rbf_20_test', Evaluation.compute_cls_map(ext_table_rbf_20, self.test_gt)    
   
   filename = os.path.join(config.get_ext_dets_foldname(self.d_train), 'dp', 'table_rbf_20')
   ext_table_rbf_20_tv = cPickle.load(open(filename, 'r'))
   print 'ext_rbf_20_trainval', Evaluation.compute_cls_map(ext_table_rbf_20_tv, self.trainval_gt)
      
   filename = os.path.join(config.get_ext_dets_foldname(self.d_test), 'dp', 'table_linear_20')
   ext_linear_20_test = cPickle.load(open(filename, 'r'))
   print 'ext_linear_test', Evaluation.compute_cls_map(ext_linear_20_test, self.test_gt)
   
   filename = os.path.join(config.get_ext_dets_foldname(self.d_train), 'dp', 'table_linear_20')
   ext_table_linear_20 = cPickle.load(open(filename, 'r'))
   print 'ext_linear_20_trainval', Evaluation.compute_cls_map(ext_table_linear_20, self.trainval_gt)    
       
   filename = 'tab_linear_5'
   ext_tab_lin_5 = cPickle.load(open(filename, 'r'))
   print 'ext_tab_lin_5_trainval', Evaluation.compute_cls_map(ext_tab_lin_5, self.trainval_gt)    
示例#10
0
 def test_compute_cls_map_gt(self):
   res = Evaluation.compute_cls_map(self.trainval_gt, self.trainval_gt)
   assert(round(res,6) == 1)
示例#11
0
 def test_compute_cls_map(self):
   res = Evaluation.compute_cls_map(self.csc_trainval, self.trainval_gt)
   assert(round(res,11) == 0.47206391958)
示例#12
0
    def test_other_scores(self):
        print 'csc_test', Evaluation.compute_cls_map(self.csc_test,
                                                     self.test_gt)
        print 'csc_trainval', Evaluation.compute_cls_map(
            self.csc_trainval, self.trainval_gt)

        print 'ext_test', Evaluation.compute_cls_map(self.ext_csc_test,
                                                     self.test_gt)
        print 'ext_trainval', Evaluation.compute_cls_map(
            self.ext_csc_trainval, self.trainval_gt)

        filename = os.path.join(config.get_ext_dets_foldname(self.d_test),
                                'dp', 'table_chi2_20')
        ext_table_chi2_20 = cPickle.load(open(filename, 'r'))
        print 'ext_chi2_20_test', Evaluation.compute_cls_map(
            ext_table_chi2_20, self.test_gt)

        filename = os.path.join(config.get_ext_dets_foldname(self.d_train),
                                'dp', 'table_chi2_20')
        ext_table_chi2_20_tv = cPickle.load(open(filename, 'r'))
        print 'ext_chi2_20_trainval', Evaluation.compute_cls_map(
            ext_table_chi2_20_tv, self.trainval_gt)

        filename = os.path.join(config.get_ext_dets_foldname(self.d_test),
                                'dp', 'table_rbf_20')
        ext_table_rbf_20 = cPickle.load(open(filename, 'r'))
        print 'ext_rbf_20_test', Evaluation.compute_cls_map(
            ext_table_rbf_20, self.test_gt)

        filename = os.path.join(config.get_ext_dets_foldname(self.d_train),
                                'dp', 'table_rbf_20')
        ext_table_rbf_20_tv = cPickle.load(open(filename, 'r'))
        print 'ext_rbf_20_trainval', Evaluation.compute_cls_map(
            ext_table_rbf_20_tv, self.trainval_gt)

        filename = os.path.join(config.get_ext_dets_foldname(self.d_test),
                                'dp', 'table_linear_20')
        ext_linear_20_test = cPickle.load(open(filename, 'r'))
        print 'ext_linear_test', Evaluation.compute_cls_map(
            ext_linear_20_test, self.test_gt)

        filename = os.path.join(config.get_ext_dets_foldname(self.d_train),
                                'dp', 'table_linear_20')
        ext_table_linear_20 = cPickle.load(open(filename, 'r'))
        print 'ext_linear_20_trainval', Evaluation.compute_cls_map(
            ext_table_linear_20, self.trainval_gt)

        filename = 'tab_linear_5'
        ext_tab_lin_5 = cPickle.load(open(filename, 'r'))
        print 'ext_tab_lin_5_trainval', Evaluation.compute_cls_map(
            ext_tab_lin_5, self.trainval_gt)
示例#13
0
 def test_compute_cls_map_gt(self):
     res = Evaluation.compute_cls_map(self.trainval_gt, self.trainval_gt)
     assert (round(res, 6) == 1)
示例#14
0
 def test_compute_cls_map(self):
     res = Evaluation.compute_cls_map(self.csc_trainval, self.trainval_gt)
     assert (round(res, 11) == 0.47206391958)