-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutil.py
More file actions
39 lines (30 loc) · 901 Bytes
/
Copy pathutil.py
File metadata and controls
39 lines (30 loc) · 901 Bytes
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
import matplotlib.pyplot as plt
import matplotlib.image as ilib
import tensorflow as tf
import numpy as np
plt.style.use('ggplot')
def get_image(path, before=False, after=False):
img = ilib.imread(path)
if before:
plt.imshow(img)
plt.show()
img = ilib.imread(path)[..., :3]
img = (img/127.5) - 1 #scale into [1, -1] range
img = tf.image.resize(img, (160, 160))
if after:
plt.imshow(img)
plt.show()
img = tf.expand_dims(img, axis=0)
return img
def plot_images(dataset, reps=5):
x = dataset.take(5).repeat(reps)
for output in x:
plt.figure()
plt.imshow(np.array(output[0]))
plt.show()
#for images in x:
# if(output[:, row*160:(row+1)*160].shape[1] == 0):
# break
# output[:, row*160:(row+1)*160] = np.vstack(images[0].numpy())
# print(row)
# row += 1