def predict(model_file): import keras.models _, languages = common.build_label_binarizer() model = keras.models.load_model(model_file) results = model.predict(samples) scores = np.zeros(len(languages)) for result in results: scores[np.argmax(result)] += 1 return scores, languages
parser.add_argument( '--test', dest='test', action='store_true', help='test the previously trained model against the test set') parser.set_defaults(test=False) args = parser.parse_args() input_shape = (FB_HEIGHT, WIDTH, COLOR_DEPTH) if args.test: model = load_model(modelFileName) input_shape = (FB_HEIGHT, WIDTH, COLOR_DEPTH) label_binarizer, clazzes = common.build_label_binarizer() test_labels, test_features, test_metadata = common.load_data( label_binarizer, foldsFolder, 'test', [1], input_shape) common.test(test_labels, test_features, test_metadata, model, clazzes) else: accuracies = [] numFolds = len( glob(os.path.join(foldsFolder, "train_metadata.fold*.npy"))) generator = common.train_generator(numFolds, foldsFolder, input_shape, max_iterations=1) first = True