-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain_dm.py
30 lines (24 loc) · 838 Bytes
/
main_dm.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
######## Imports ########
import numpy as np
import keras as k
import cv2
import h5py
import time
######## Script #######
def main(start_time):
# Load Model and Images
model = k.models.load_model('./modules/model_keras2.h5')
train_imgs = h5py.File('./input_data/input_images.hdf5', 'r')
pred = model.predict(np.array(train_imgs['input_images'][0:1][..., np.newaxis]))
# Print out time it takes for prediction
elapsed_time = time.time() - start_time
print("Time elapsed: {0:.1f} min".format(elapsed_time / 60.))
# Display Results
cv2.imshow('Predicted', pred[0])
cv2.imshow('Original', train_imgs['input_images'][0])
cv2.waitKey(0)
cv2.destroyAllWindows()
######## To Invoke Main Function #######
if __name__ == '__main__':
start_time = time.time()
main(start_time)