예제 #1
0
 def __init__(self, lbp_operator=ExtendedLBP(), sz=(8, 8)):
     AbstractFeature.__init__(self)
     if not isinstance(lbp_operator, LocalDescriptor):
         raise TypeError(
             "Only an operator of type facerec.lbp.LocalDescriptor is a valid lbp_operator."
         )
     self.lbp_operator = lbp_operator
     self.sz = sz
예제 #2
0
 def __init__(self, lbp_operator = ExtendedLBP(radius=1, neighbors=8)):
     AbstractFeature.__init__(self)
     self._lbp_operator = lbp_operator
예제 #3
0
 # Define filters for the Dataset:
 yale_subset_0_40 = YaleBaseFilter(0, 40, 0, 40)
 # Now read in the image data. Apply filters, scale to 128 x 128 pixel:
 [X, y] = read_images(sys.argv[1], yale_subset_0_40, sz=(64, 64))
 # Set up a handler for logging:
 handler = logging.StreamHandler(sys.stdout)
 formatter = logging.Formatter(
     '%(asctime)s - %(name)s - %(levelname)s - %(message)s')
 handler.setFormatter(formatter)
 # Add handler to facerec modules, so we see what's going on inside:
 logger = logging.getLogger("facerec")
 logger.addHandler(handler)
 logger.setLevel(logging.INFO)
 # The models we want to evaluate:
 model0 = PredictableModel(
     feature=SpatialHistogram(lbp_operator=ExtendedLBP()),
     classifier=NearestNeighbor(dist_metric=ChiSquareDistance(), k=1))
 model1 = PredictableModel(feature=SpatialHistogram(lbp_operator=LPQ()),
                           classifier=NearestNeighbor(
                               dist_metric=ChiSquareDistance(), k=1))
 # The sigmas we'll apply for each run:
 sigmas = [0]
 print('The experiment will be run %s times!' % ITER_MAX)
 # Initialize experiments (with empty results):
 experiments = {}
 experiments['lbp_model'] = {
     'model': model0,
     'results': {},
     'color': 'r',
     'linestyle': '--',
     'marker': '*'
예제 #4
0
     print "USAGE: lpq_experiment.py </path/to/images>"
     sys.exit()
 # Define filters for the Dataset:
 yale_subset_0_40 = YaleBaseFilter(0, 40, 0, 40)
 # Now read in the image data. Apply filters, scale to 128 x 128 pixel:
 [X,y] = read_images(sys.argv[1], yale_subset_0_40, sz=(64,64))
 # Set up a handler for logging:
 handler = logging.StreamHandler(sys.stdout)
 formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
 handler.setFormatter(formatter)
 # Add handler to facerec modules, so we see what's going on inside:
 logger = logging.getLogger("facerec")
 logger.addHandler(handler)
 logger.setLevel(logging.INFO)
 # The models we want to evaluate:
 model0 = PredictableModel(feature=SpatialHistogram(lbp_operator=ExtendedLBP()), classifier=NearestNeighbor(dist_metric=ChiSquareDistance(), k=1))
 model1 = PredictableModel(feature=SpatialHistogram(lbp_operator=LPQ()), classifier=NearestNeighbor(dist_metric=ChiSquareDistance(), k=1))
 # The sigmas we'll apply for each run:
 sigmas = [0]
 print 'The experiment will be run %s times!' % ITER_MAX
 # Initialize experiments (with empty results):
 experiments = {}
 experiments['lbp_model'] = { 'model': model0, 'results' : {}, 'color' : 'r', 'linestyle' : '--', 'marker' : '*'} 
 experiments['lpq_model'] = { 'model': model1, 'results' : {}, 'color' : 'b', 'linestyle' : '--', 'marker' : 's'}
 # Loop to acquire the results for each experiment:
 for sigma in sigmas:
     print "Setting sigma=%s" % sigma
     for key, value in experiments.iteritems():
         print 'Running experiment for model=%s' % key
         # Define the validators for the model:
         cv0 = SimpleValidation(value['model'])