def test_training(self): ''' This trains the FaceFinder on the scraps database. ''' #import cProfile # Load an eyes file eyes_filename = join(pv.__path__[0],'data','csuScrapShots','coords.txt') #print "Creating eyes File." eyes_file = EyesFile(eyes_filename) # Create a face detector cascade_file = join(pv.__path__[0],'config','facedetector_celebdb2.xml') #print "Creating a face detector from:",cascade_file face_detector = CascadeDetector(cascade_file) image_dir = join(pv.__path__[0],'data','csuScrapShots') ed = SVMEyeDetectorFromDatabase(eyes_file, image_dir, image_ext=".pgm", face_detector=face_detector,random_seed=0) edt = EyeDetectionTest(name='scraps') #print "Testing..." for img in self.images: #print img.filename faces = ed.detect(img) #faces = ed.detect(img) pred_eyes = [] for _,_,pleye,preye in faces: #detections.append(rect) pred_eyes.append((pleye,preye)) truth_eyes = self.eyes.getEyes(img.filename) edt.addSample(truth_eyes, pred_eyes, im=img, annotate=False)
def test_ASEFEyeLocalization(self): '''FilterEyeLocator: Scrapshots Both10 rate == 0.4800...............''' ilog = None if 'ilog' in list(globals().keys()): ilog = globals()['ilog'] # Load a face database ssdb = ScrapShotsDatabase() # Create a face detector face_detector = CascadeDetector() # Create an eye locator eye_locator = FilterEyeLocator() # Create an eye detection test edt = EyeDetectionTest(name='asef_scraps') #print "Testing..." for face_id in list(ssdb.keys())[:25]: face = ssdb[face_id] im = face.image dist = face.left_eye.l2(face.right_eye) dist = np.ceil(0.1*dist) im.annotateCircle(face.left_eye,radius=dist,color='white') im.annotateCircle(face.right_eye,radius=dist,color='white') # Detect the faces faces = face_detector.detect(im) # Detect the eyes pred_eyes = eye_locator(im,faces) for rect,leye,reye in pred_eyes: im.annotateRect(rect) im.annotateCircle(leye,radius=1,color='red') im.annotateCircle(reye,radius=1,color='red') truth_eyes = [[face.left_eye,face.right_eye]] pred_eyes = [ [leye,reye] for rect,leye,reye in pred_eyes] # Add to eye detection test edt.addSample(truth_eyes, pred_eyes, im=im, annotate=True) if ilog != None: ilog.log(im,label='test_ASEFEyeLocalization') edt.createSummary() # Very poor accuracy on the scrapshots database self.assertAlmostEqual( edt.face_rate , 1.0000, places = 3 ) self.assertAlmostEqual( edt.both25_rate , 0.8800, places = 3 ) self.assertAlmostEqual( edt.both10_rate , 0.5200, places = 3 ) self.assertAlmostEqual( edt.both05_rate , 0.2800, places = 3 )
def test_ASEFEyeLocalization(self): '''FilterEyeLocator: Scrapshots Both10 rate == 0.4800...............''' ilog = None if 'ilog' in globals().keys(): ilog = globals()['ilog'] # Load a face database ssdb = ScrapShotsDatabase() # Create a face detector face_detector = CascadeDetector() # Create an eye locator eye_locator = FilterEyeLocator() # Create an eye detection test edt = EyeDetectionTest(name='asef_scraps') #print "Testing..." for face_id in ssdb.keys()[:25]: face = ssdb[face_id] im = face.image dist = face.left_eye.l2(face.right_eye) dist = np.ceil(0.1 * dist) im.annotateCircle(face.left_eye, radius=dist, color='white') im.annotateCircle(face.right_eye, radius=dist, color='white') # Detect the faces faces = face_detector.detect(im) # Detect the eyes pred_eyes = eye_locator(im, faces) for rect, leye, reye in pred_eyes: im.annotateRect(rect) im.annotateCircle(leye, radius=1, color='red') im.annotateCircle(reye, radius=1, color='red') truth_eyes = [[face.left_eye, face.right_eye]] pred_eyes = [[leye, reye] for rect, leye, reye in pred_eyes] # Add to eye detection test edt.addSample(truth_eyes, pred_eyes, im=im, annotate=True) if ilog != None: ilog.log(im, label='test_ASEFEyeLocalization') edt.createSummary() # Very poor accuracy on the scrapshots database self.assertAlmostEqual(edt.face_rate, 1.0000, places=3) self.assertAlmostEqual(edt.both25_rate, 0.8800, places=3) self.assertAlmostEqual(edt.both10_rate, 0.5200, places=3) self.assertAlmostEqual(edt.both05_rate, 0.2800, places=3)
def test_ASEFEyeLocalization(self): ''' This trains the FaceFinder on the scraps database. ''' # Load a face database ssdb = ScrapShotsDatabase() # Create a face detector face_detector = cd.CascadeDetector() # Create an eye locator eye_locator = FilterEyeLocator() # Create an eye detection test edt = EyeDetectionTest(name='asef_scraps') #print "Testing..." for face_id in ssdb.keys(): face = ssdb[face_id] im = face.image # Detect the faces faces = face_detector.detect(im) # Detect the eyes pred_eyes = eye_locator(im,faces) truth_eyes = [[face.left_eye,face.right_eye]] pred_eyes = [ [leye,reye] for _,leye,reye in pred_eyes] # Add to eye detection test edt.addSample(truth_eyes, pred_eyes, im=im, annotate=False) edt.createSummary() self.assertAlmostEqual( edt.face_rate , 0.97109826589595372, places = 3 ) # Updated numbers for OpenCV 2.0 self.assertAlmostEqual( edt.both25_rate , 0.82658959537572252, places = 3 ) self.assertAlmostEqual( edt.both10_rate , 0.47976878612716761, places = 3 ) self.assertAlmostEqual( edt.both05_rate , 0.30635838150289019, places = 3 )
def test_ASEFEyeLocalization(self): ''' This trains the FaceFinder on the scraps database. ''' # Load a face database ssdb = ScrapShotsDatabase() # Create a face detector face_detector = cd.CascadeDetector() # Create an eye locator eye_locator = FilterEyeLocator() # Create an eye detection test edt = EyeDetectionTest(name='asef_scraps') #print "Testing..." for face_id in ssdb.keys(): face = ssdb[face_id] im = face.image # Detect the faces faces = face_detector.detect(im) # Detect the eyes pred_eyes = eye_locator(im,faces) truth_eyes = [[face.left_eye,face.right_eye]] pred_eyes = [ [leye,reye] for _,leye,reye in pred_eyes] # Add to eye detection test edt.addSample(truth_eyes, pred_eyes, im=im, annotate=False) edt.createSummary() self.assertAlmostEqual( edt.face_rate , 0.97109826589595372, delta = 0.01 ) # Updated numbers for OpenCV 2.0 self.assertAlmostEqual( edt.both25_rate , 0.82658959537572252, delta = 0.01 ) self.assertAlmostEqual( edt.both10_rate , 0.47976878612716761, delta = 0.01 ) self.assertAlmostEqual( edt.both05_rate , 0.30635838150289019, delta = 0.01 )
def test_training(self): ''' This trains the FaceFinder on the scraps database. ''' #import cProfile # Load an eyes file eyes_filename = join(pv.__path__[0], 'data', 'csuScrapShots', 'coords.txt') #print "Creating eyes File." eyes_file = EyesFile(eyes_filename) # Create a face detector cascade_file = join(pv.__path__[0], 'config', 'facedetector_celebdb2.xml') #print "Creating a face detector from:",cascade_file face_detector = CascadeDetector(cascade_file) image_dir = join(pv.__path__[0], 'data', 'csuScrapShots') ed = SVMEyeDetectorFromDatabase(eyes_file, image_dir, image_ext=".pgm", face_detector=face_detector, random_seed=0) edt = EyeDetectionTest(name='scraps') #print "Testing..." for img in self.images: #print img.filename faces = ed.detect(img) #faces = ed.detect(img) pred_eyes = [] for _, _, pleye, preye in faces: #detections.append(rect) pred_eyes.append((pleye, preye)) truth_eyes = self.eyes.getEyes(img.filename) edt.addSample(truth_eyes, pred_eyes, im=img, annotate=False) #print edt.createSummary() self.assertAlmostEqual(edt.face_rate, 0.924855491329, places=3)