-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathp2ptest.py
31 lines (28 loc) · 939 Bytes
/
p2ptest.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
from keras.models import load_model
from numpy import load
from numpy import vstack
from matplotlib import pyplot
from numpy.random import randint
def loadex(filename):
data = load(filename)
X1, X2 = data['arr_0'], data['arr_1']
X1 = (X1 - 127.5) / 127.5
X2 = (X2 - 127.5) / 127.5
return [X1, X2]
def drw(src_img, gen_img, tar_img):
images = vstack((src_img, gen_img, tar_img))
images = (images + 1) / 2.0
titles = ['Source', 'Generated', 'Expected']
for i in range(len(images)):
pyplot.subplot(1, 3, 1 + i)
pyplot.axis('off')
pyplot.imshow(images[i])
pyplot.title(titles[i])
pyplot.show()
[X1, X2] = loadex('D:/Dissertation/Pix2PixDepthEst/t2.npz')
print('Loaded', X1.shape, X2.shape)
model = load_model('D:/Dissertation/Pix2PixDepthEst/pix.h5')
ix = randint(0, len(X1), 1)
src_image, tar_image = X1[ix], X2[ix]
gen_image = model.predict(src_image)
drw(src_image, gen_image, tar_image)