|
@@ -1,8 +1,13 @@
|
|
import os
|
|
import os
|
|
from glob import glob
|
|
from glob import glob
|
|
|
|
|
|
-from scipy.misc import imread, imresize
|
|
|
|
|
|
+#from scipy.misc import imread, imresize
|
|
|
|
+import imageio
|
|
|
|
+from imageio import imread
|
|
|
|
+import numpy
|
|
|
|
+from PIL import Image
|
|
import numpy as np
|
|
import numpy as np
|
|
|
|
+from skimage.transform import resize
|
|
from tqdm import tqdm
|
|
from tqdm import tqdm
|
|
import h5py
|
|
import h5py
|
|
|
|
|
|
@@ -19,11 +24,11 @@ def read_image(path):
|
|
assert w in [256, 512, 1200], 'Image size mismatch ({}, {})'.format(h, w)
|
|
assert w in [256, 512, 1200], 'Image size mismatch ({}, {})'.format(h, w)
|
|
assert h in [128, 256, 600], 'Image size mismatch ({}, {})'.format(h, w)
|
|
assert h in [128, 256, 600], 'Image size mismatch ({}, {})'.format(h, w)
|
|
if 'maps' in path:
|
|
if 'maps' in path:
|
|
- image_a = image[:, w/2:, :].astype(np.float32) / 255.0
|
|
|
|
- image_b = image[:, :w/2, :].astype(np.float32) / 255.0
|
|
|
|
|
|
+ image_a = image[:, int(w/2):, :].astype(np.float32) / 255.0
|
|
|
|
+ image_b = image[:, :int(w/2), :].astype(np.float32) / 255.0
|
|
else:
|
|
else:
|
|
- image_a = image[:, :w/2, :].astype(np.float32) / 255.0
|
|
|
|
- image_b = image[:, w/2:, :].astype(np.float32) / 255.0
|
|
|
|
|
|
+ image_a = image[:, :int(w/2), :].astype(np.float32) / 255.0
|
|
|
|
+ image_b = image[:, int(w/2):, :].astype(np.float32) / 255.0
|
|
|
|
|
|
# range of pixel values = [-1.0, 1.0]
|
|
# range of pixel values = [-1.0, 1.0]
|
|
image_a = image_a * 2.0 - 1.0
|
|
image_a = image_a * 2.0 - 1.0
|
|
@@ -53,7 +58,10 @@ def store_h5py(base_dir, dir_name, images, image_size):
|
|
for i in range(len(images)):
|
|
for i in range(len(images)):
|
|
grp = f.create_group(str(i))
|
|
grp = f.create_group(str(i))
|
|
if images[i].shape[0] != image_size:
|
|
if images[i].shape[0] != image_size:
|
|
- image = imresize(images[i], (image_size, image_size, 3))
|
|
|
|
|
|
+ #image = imresize(images[i], (image_size, image_size, 3))
|
|
|
|
+ #print(i)
|
|
|
|
+ #image = numpy.array(Image.fromarray(images[i]).resize((image_size, image_size, 3)))
|
|
|
|
+ image = resize(images[i], (image_size, image_size, 3))
|
|
# range of pixel values = [-1.0, 1.0]
|
|
# range of pixel values = [-1.0, 1.0]
|
|
image = image.astype(np.float32) / 255.0
|
|
image = image.astype(np.float32) / 255.0
|
|
image = image * 2.0 - 1.0
|
|
image = image * 2.0 - 1.0
|