-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexecute_validation.py
More file actions
57 lines (47 loc) · 1.81 KB
/
Copy pathexecute_validation.py
File metadata and controls
57 lines (47 loc) · 1.81 KB
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
52
53
54
55
56
57
import os
import re
import argparse
import h5py as f
from tensorflow import keras
def model_predictions(dataframes_path, model_name):
# Check if the model has mask
if bool(re.search('mask', model_name)):
mask = True
else:
mask = False
# Load the model
model = os.path.join('./models', model_name)
model = keras.models.load_model(model)
# Load the dataframes
dataframes = f.File(dataframes_path, "r")
for key in dataframes.keys():
globals()[key] = dataframes[key]
# Evaluate and save it
model_name = model_name[:-3]
results = ev.evaluate(model, X_val, y_val, list(range(len(y_val))), mask=mask)
ev.save_eval(model_name, 'validation', results)
# Predict and save it
pred.save_metricas(model_name, 'validation', model, X_val, y_val, list(range(len(y_val))), mask)
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('-d',
'--device',
help="GPU device",
type=str,
default=3)
parser.add_argument('-m',
'--model_name',
help="nombre del modelo",
type=str,
default='pneumonia_classification_model.h5')
parser.add_argument('-h5',
'--h5_dataset',
type=str,
default='./data/training_validation_dataset.h5',
help="h5 dataset file with train and test folders")
args = parser.parse_args()
os.environ['CUDA_VISIBLE_DEVICES'] = str(args.device)
model_name = args.model_name
import evaluation_functions.prediction as pred
import evaluation_functions.evaluation as ev
model_predictions(args.h5_dataset, model_name)