-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy patheval.py
36 lines (29 loc) · 1.05 KB
/
eval.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import os
import glob
import keras
from keras_vggface.vggface import VGGFace
from keras_vggface.utils import preprocess_input
from keras.models import load_model
Height = 224
Width = 224
BatchSize = 32
Version = 1
baseDir = 'D:/Kaggle-Autism/models/eval/'
modelName = os.listdir(baseDir)
fullPath = os.path.join(baseDir, modelName[0])
TrainPath = 'D:/Autism-Data/Kaggle/v' + str(Version) + '/train'
ValidPath = 'D:/Autism-Data/Kaggle/v' + str(Version) + '/valid'
TestPath = 'D:/Autism-Data/Kaggle/v' + str(Version) + '/test'
print("Loading:", fullPath)
model = load_model(fullPath)
def preprocess_input_new(x):
img = preprocess_input(keras.preprocessing.image.img_to_array(x), version = 2)
return keras.preprocessing.image.array_to_img(img)
ValidGen = keras.preprocessing.image.ImageDataGenerator(
preprocessing_function=preprocess_input_new).flow_from_directory(
TestPath,
target_size=(Height, Width),
batch_size=BatchSize,
shuffle=False)
results = model.evaluate_generator(ValidGen, verbose=0)
print(results)