-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtest.py
51 lines (43 loc) · 1.3 KB
/
test.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
'''
Loads a model and produces images based on the test set specified.
'''
import data
import numpy as np
from tensorflow import keras
index = "502_160_40_200"
trainIds = np.load("npy/train_{}.npy".format(index))
testIds = np.load("npy/test_{}.npy".format(index))
# Model specific code
# MSE model
model = keras.models.load_model("models/CIEmodel_502_160_40_200", compile=False)
'''
X, Y = data.loadImageData(trainIds)
print("Train error")
model.evaluate(X, Y, batch_size=32)
X, Y = data.loadImageData(testIds)
print("Test error")
model.evaluate(X, Y, batch_size=32)
'''
X_test, Y_test = data.loadImageData(testIds)
predictions = model.predict(X_test)
data.generateImages(X_test, predictions * 127, testIds)
'''
# Classification model
model = keras.models.load_model("models/ClassificationModel_50_20_4_100")
bins = np.load("npy/pts_in_hull.npy")
for ids in [trainIds, testIds]:
print(len(ids))
loss = 0.0
for id in ids:
X, Y = data.loadImageData([id])
Y = data.batchQuantize(Y, bins)
loss += model.evaluate(X, Y, verbose=0)
print("Loss: {}".format(loss / len(ids)))
'''
'''
for id in testIds:
X_test, Y_test = data.loadImageData([id])
predictions = model.predict(X_test)
AB = data.batchUnquantize(predictions, bins)
data.generateImages(X_test, AB, [id])
'''