Ejemplo n.º 1
0
 def compute_recognition_data(self, dim=48, resample=True):
     # Assign labels to actual template data structure.
     for i, temp in enumerate(self.templates):
         temp.name = self.labels[i]
     self.join_graph = groups_to_join_graph(self.groups)
     self.image_templates = group_image_templates(self.templates,
                                                  self.groups, dim=dim,
                                                  resample=resample)
     self.raw_features = compute_features_equation(self.templates)
     (self.group_features, self.group_labels) = features_to_classifier_input(
         self.raw_features, self.join_graph)
Ejemplo n.º 2
0
def group_classify(page, clf):
    features = page.group_features
    
    y = clf.predict(features)
    real = page.group_labels
    accuracy = sum([1.0 if r == p else 0.0
                    for r,p in zip(real, y)])/len(y)
    groups = clf_results_to_join_graph(page.raw_features,
                                       y, 
                                       page.num_temps)
    return (accuracy, group_image_templates(page.templates,
                                            groups))