if args.skip_detection: dataset = torch_utils.FaceDataset(x, preprocess) else: imgs = pipeline.load_faces(x, gpu=args.gpu) dataset = torch_utils.FaceDataset(imgs, preprocess, x_image=True) res = torch_utils.evaluate(model, loader(dataset), gpu=args.gpu) misc.display_result(x, misc.softmax(res)) else: if tw_face.data_exist(): print('evaluate the model on Taiwanese faces') tw_loader = lambda data: loader( torch_utils.FaceDatasetWithLabel(*data, preprocess), ) data = tw_face.read_data('young') torch_utils.eval_acc(model, tw_loader(data), data[1], 'TW face young', gpu=args.gpu) data = tw_face.read_data('old') torch_utils.eval_acc(model, tw_loader(data), data[1], 'TW face old', gpu=args.gpu) else: print( 'please download Taiwanese faces data first, or use --input / --input_folder to specify inputs'
def test_label(self): x, y = tw_face.read_data() for yy in y.flat: self.assertIn(yy, range(7))
def test_readable(self): x, y = tw_face.read_data() for xx in x: Image.open(xx).close()
def test_all_count(self): x, y = tw_face.read_data() self.assertEqual(len(x), self.young_size + self.old_size) self.assertEqual(y.shape, (self.young_size + self.old_size, ))
def test_young_count(self): x, y = tw_face.read_data('young') self.assertEqual(len(x), self.young_size) self.assertEqual(y.shape, (self.young_size, ))
def test_old_count(self): x, y = tw_face.read_data('old') self.assertEqual(len(x), self.old_size) self.assertEqual(y.shape, (self.old_size, ))