|
@@ -7,6 +7,9 @@ import pprint
|
|
|
import scipy.misc
|
|
|
import numpy as np
|
|
|
import copy
|
|
|
+from skimage.transform import resize
|
|
|
+from skimage.io import imsave
|
|
|
+
|
|
|
try:
|
|
|
_imread = scipy.misc.imread
|
|
|
except AttributeError:
|
|
@@ -44,7 +47,7 @@ class ImagePool(object):
|
|
|
|
|
|
def load_test_data(image_path, fine_size=256):
|
|
|
img = imread(image_path)
|
|
|
- img = scipy.misc.imresize(img, [fine_size, fine_size])
|
|
|
+ img = resize(img, [fine_size, fine_size])
|
|
|
img = img/127.5 - 1
|
|
|
return img
|
|
|
|
|
@@ -52,8 +55,8 @@ def load_train_data(image_path, load_size=286, fine_size=256, is_testing=False):
|
|
|
img_A = imread(image_path[0])
|
|
|
img_B = imread(image_path[1])
|
|
|
if not is_testing:
|
|
|
- img_A = scipy.misc.imresize(img_A, [load_size, load_size])
|
|
|
- img_B = scipy.misc.imresize(img_B, [load_size, load_size])
|
|
|
+ img_A = resize(img_A, [load_size, load_size])
|
|
|
+ img_B = resize(img_B, [load_size, load_size])
|
|
|
h1 = int(np.ceil(np.random.uniform(1e-2, load_size-fine_size)))
|
|
|
w1 = int(np.ceil(np.random.uniform(1e-2, load_size-fine_size)))
|
|
|
img_A = img_A[h1:h1+fine_size, w1:w1+fine_size]
|
|
@@ -63,8 +66,8 @@ def load_train_data(image_path, load_size=286, fine_size=256, is_testing=False):
|
|
|
img_A = np.fliplr(img_A)
|
|
|
img_B = np.fliplr(img_B)
|
|
|
else:
|
|
|
- img_A = scipy.misc.imresize(img_A, [fine_size, fine_size])
|
|
|
- img_B = scipy.misc.imresize(img_B, [fine_size, fine_size])
|
|
|
+ img_A = resize(img_A, [fine_size, fine_size])
|
|
|
+ img_B = resize(img_B, [fine_size, fine_size])
|
|
|
|
|
|
img_A = img_A/127.5 - 1.
|
|
|
img_B = img_B/127.5 - 1.
|
|
@@ -79,13 +82,13 @@ def get_image(image_path, image_size, is_crop=True, resize_w=64, is_grayscale =
|
|
|
return transform(imread(image_path, is_grayscale), image_size, is_crop, resize_w)
|
|
|
|
|
|
def save_images(images, size, image_path):
|
|
|
- return imsave(inverse_transform(images), size, image_path)
|
|
|
+ return imsave(image_path, inverse_transform(images))
|
|
|
|
|
|
def imread(path, is_grayscale = False):
|
|
|
if (is_grayscale):
|
|
|
return _imread(path, flatten=True).astype(np.float)
|
|
|
else:
|
|
|
- return _imread(path, mode='RGB').astype(np.float)
|
|
|
+ return _imread(path, pilmode='RGB').astype(np.float)
|
|
|
|
|
|
def merge_images(images, size):
|
|
|
return inverse_transform(images)
|
|
@@ -100,8 +103,8 @@ def merge(images, size):
|
|
|
|
|
|
return img
|
|
|
|
|
|
-def imsave(images, size, path):
|
|
|
- return scipy.misc.imsave(path, merge(images, size))
|
|
|
+#def imsave(images, size, path):
|
|
|
+# return scipy.misc.imsave(path, merge(images, size))
|
|
|
|
|
|
def center_crop(x, crop_h, crop_w,
|
|
|
resize_h=64, resize_w=64):
|