
import pre_ecg as p
import keras
import sys
import numpy as np
from keras.models import model_from_json
from keras.callbacks import ModelCheckpoint
from keras.models import model_from_json

fname=sys.argv[1]
test=p.Read_ecg(fname)
test=test.reshape([-1,1,18286,1]).astype('float32')


np.random.seed(7)
json_file = open('model.json', 'r')
loaded_model_json = json_file.read()
json_file.close()
model = model_from_json(loaded_model_json)
model.load_weights('Weigths.hdf5')
values=model.predict(test, batch_size=10, verbose=0)
v=values.argmax()
id_to_class = {0:"N", 1:"A", 2:"O", 3:"~"}
p=id_to_class.get(v)
print (fname +","+ p)

f= open("answers.txt","a")
f.write(fname +","+p+"\n")
f.close()
