Exemplo n.º 1
0
 def classify_image(self, scores):
   """
   Return score as a probability [0,1] for this class.
   Scores should be a vector of scores of the detections for this image.
   """
   # TODO: rename classify_scores(), does not use image at all!
   
   vector = self.create_vector_from_scores(scores)
   return svm_proba(vector, self.svm)[0][1]
Exemplo n.º 2
0
    def classify_image(self, scores):
        """
    Return score as a probability [0,1] for this class.
    Scores should be a vector of scores of the detections for this image.
    """
        # TODO: rename classify_scores(), does not use image at all!

        vector = self.create_vector_from_scores(scores)
        return svm_proba(vector, self.svm)[0][1]
Exemplo n.º 3
0
 def train(self, pos, neg, kernel, C):
   y = [1]*pos.shape[0] + [-1]*neg.shape[0]
   x = np.concatenate((pos,neg))
   model = train_svm(x, y, kernel, C)
   self.svm = model
   print 'model.score(C=%d): %f'%(C, model.score(x,y))
   table_t = svm_proba(x, model)
   y2 = np.array(y)
   y2 = (y2+1)/2 # switch to 0/1
   ap,_,_ = Evaluation.compute_cls_pr(table_t[:,1], y2)
   print 'ap on train set: %f'%ap
   filename = config.get_classifier_filename(self, self.cls, self.train_dataset)
   self.svm = model
   self.save_svm(model, filename)
   return model