forked from Namenaro/ecg_segmentation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpredict.py
31 lines (23 loc) · 856 Bytes
/
predict.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
import matplotlib.pyplot as plt
import numpy as np
import easygui
from keras.models import load_model
from utils import *
from metrics import Metrics
def predict():
filepath = easygui.fileopenbox("select model (.h5)")
dataset_path = filepath[0:-2] + "pkl"
metric = Metrics()
Se = metric.Se
PPV = metric.PPV
model = load_model(filepath, custom_objects={'Se': Se, 'PPV':PPV})
X, Y = restore_set_from_pkl(dataset_path)
y_predicted = model.predict_on_batch(X)
time_len = len(y_predicted[1,:])
for i in range(len(X)):
draw_prediction_and_reality(X[i,0:time_len,:],
prediction=y_predicted[i],
right_answer=Y[i,0:time_len,:],
plot_name="Predicted2" + str(i))
if __name__ == "__main__":
predict()