Search code examples
pythonscipyimage-resizingscikit-image

skimage.transform.resize is slower than scipy.misc.imresize


I am training a neural network, while training I came across errors in a data preparation section. where this line:

img = np.double(scipy.misc.imresize(img, [height, width, channels], interp='bilinear', mode = 'RGB'))

and this line:

img2 = np.double(scipy.misc.imresize(img2, [height, width], interp='bilinear'))

showed errors, as scipy.misc.imresize is deprecated in newer versions of scipy. What I did is I used skimage.transform.resize instead of scipy.misc.imresize, that's what is recommended, as:

img = np.double(resize(img, (height, width, channels)))

and

img2 = np.double(resize(img2, (height, width)))

It worked. But the problem is the data reading process has become very slow as compared to the scipy.misc.imresize. I had tested it before on old version of scipy.misc.imresize. Any help in this regard would be very much appreciated. Thanks!

P.S. I am training the model on Google Colab.


Solution

  • You can just copy-paste the source of imresize:

    https://github.com/scipy/scipy/blob/v1.1.0/scipy/misc/pilutil.py#L513