Skip to content

Commit 842dd27

Browse files
authored
Merge pull request #352 from WasabiThumb/patch-1
Changed resize function; scipy deprecated Issue #351
2 parents 98d2810 + 2489c1d commit 842dd27

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

utils.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import datetime
1515
from time import gmtime, strftime
1616
from six.moves import xrange
17+
from PIL import Image
1718

1819
import tensorflow as tf
1920
import tensorflow.contrib.slim as slim
@@ -90,8 +91,8 @@ def center_crop(x, crop_h, crop_w,
9091
h, w = x.shape[:2]
9192
j = int(round((h - crop_h)/2.))
9293
i = int(round((w - crop_w)/2.))
93-
return scipy.misc.imresize(
94-
x[j:j+crop_h, i:i+crop_w], [resize_h, resize_w])
94+
im = Image.fromarray(x[j:j+crop_h, i:i+crop_w])
95+
return np.array(im.resize([resize_h, resize_w]), PIL.Image.BILINEAR)
9596

9697
def transform(image, input_height, input_width,
9798
resize_height=64, resize_width=64, crop=True):
@@ -100,8 +101,8 @@ def transform(image, input_height, input_width,
100101
image, input_height, input_width,
101102
resize_height, resize_width)
102103
else:
103-
cropped_image = scipy.misc.imresize(image, [resize_height, resize_width])
104-
return np.array(cropped_image)/127.5 - 1.
104+
im = Image.fromarray(image[j:j+crop_h, i:i+crop_w])
105+
return np.array(im.resize([resize_h, resize_w]), PIL.Image.BILINEAR)/127.5 - 1.
105106

106107
def inverse_transform(images):
107108
return (images+1.)/2.

0 commit comments

Comments
 (0)