def resize_images(x, shape):
from scipy.misc import imresize
reszie_func = lambda x, shape: imresize(x, shape, interp='bilinear')
if x.ndim == 4:
def reszie_func(x, shape):
# x: 3D
# The color channel is the first dimension
tmp = []
for i in x:
tmp.append(imresize(i, shape).reshape((-1,) + shape))
return np.swapaxes(np.vstack(tmp).T, 0, 1)
imgs = []
for i in x:
imgs.append(reszie_func(i, shape))
return imgs
评论列表
文章目录