-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTest.py
More file actions
62 lines (54 loc) · 1.91 KB
/
Test.py
File metadata and controls
62 lines (54 loc) · 1.91 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
58
59
60
61
62
# net import
import numpy as np
import tensorflow as tf
from keras.layers import *
from matplotlib import pyplot as plt
np.random.seed(123)
config = tf.ConfigProto(
device_count = {'GPU': 0}
)
sess = tf.Session(config=config)
K.set_session(sess)
ROWS = 256
COLS = 256
def show_images(images, cols=1, titles=None):
"""Display a list of images in a single figure with matplotlib.
Parameters
—-------
images: List of np.arrays compatible with plt.imshow.
cols (Default = 1): Number of columns in figure (number of rows is
set to np.ceil(n_images/float(cols))).
titles: List of titles corresponding to each image. Must have
the same length as titles.
"""
assert ((titles is None) or (len(images) == len(titles)))
n_images = len(images)
if titles is None: titles = ['Image (%d)' % i for i in range(1, n_images + 1)]
fig = plt.figure()
for n, (image, title) in enumerate(zip(images, titles)):
a = fig.add_subplot(cols, np.ceil(n_images / float(cols)), n + 1)
if image.ndim == 2:
plt.gray()
plt.imshow(image)
a.set_title(title)
fig.set_size_inches(np.array(fig.get_size_inches()) * n_images)
plt.show()
def generator():
i = 0
while True:
x = np.load("C:\\data12\\pic_from" + str(i) + ".txt.npy")
y = np.load("C:\\data12\\pic_to" + str(i) + ".txt.npy")
x = np.expand_dims(np.expand_dims(x, 0),-1)
y = np.expand_dims(np.expand_dims(y, 0), -1)
if i == 1999: i = -1
i += 1
print(i)
yield x,y
a = generator()
for i in range(1999):
#for j in range(20):
x_data, y_data = next(a)
n_x_data, n_y_data = next(a)
show_images([np.reshape(x_data, (ROWS, COLS)), np.reshape(n_x_data, (ROWS, COLS)),
np.reshape(x_data, (ROWS, COLS)) - np.reshape(n_x_data, (ROWS, COLS))
], 1, ["1", "2", 'minus'])