-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheval.py
More file actions
27 lines (19 loc) · 676 Bytes
/
Copy patheval.py
File metadata and controls
27 lines (19 loc) · 676 Bytes
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
import sys
import numpy as np
from tensorflow.keras.optimizers import Adam
from tensorflow.keras.models import load_model
# Load a trained model checkpoint
model = load_model(sys.argv[1])
# compile model
model.compile(loss="binary_crossentropy", optimizer=Adam(lr=1e-3), metrics=["accuracy"])
# Load a test dataset (UINT8)
new_xtest = np.load("data/img_uint8.npy")
new_ytest = np.load("data/msk_uint8.npy")
# Evaluate model
score = model.evaluate(
np.float32(new_xtest / 255.0), np.float32(new_ytest / 255.0), verbose=0
)
# Print loss and accuracy
print("Test loss:", score[0])
print("Test accuracy:", score[1])
# Sample run: python eval.py checkpoints/model.hdf5