replacing deprecated imresize
In scipy v1.3, the scipy.misc.imread and scipy.misc.imresize functions are no longer available. These are used throughout this package, especially in loading data in pose_dataset.py.
There's an easy replacement for imread : imageio.imread
For imresize, there are several choices:
-
scipy.ndimage.zoom -
skimage.transform.resize -
PIL.Image.resize
These differ slightly in their implementation details (e.g., type of interpolation, anti-aliasing filters). Any preferences for which would be best?
My feeling is that scipy.ndimage.zoom is the best because it doesn't require adding a dependency (skimage or PIL). Also, the function signature is the same as the old scipy.misc.imresize, so it's a drop-in replacement.
Here is a commit in my own fork that demonstrates the change: https://github.com/cxrodgers/PoseTF/commit/f36d9f17a3fa784c98055ee5df49b4419a9a2b3f
I can turn this into a PR if people like this approach
My feeling is that scipy.ndimage.zoom is the best because it doesn't require adding a dependency (skimage or PIL). Also, the function signature is the same as the old scipy.misc.imresize, so it's a drop-in replacement.
not quite correct. It does not have 'interp' keyword argument which is used in util/visualize.py But anyway, unfortunately this repository is abandoned as many others intended to have papers as outputs...
I see. I don't use util/visualize.py so I didn't know about that.
Here is the code I'm currently using in pose_dataset.py. Perhaps it will be useful for others.
# Resize the image
if scale == 1:
img = image
else:
# Zoom each color channel separately
img = np.array([
scipy.ndimage.zoom(image[:, :, channel], scale, mode='reflect')
for channel in range(image.shape[2])])
img = np.moveaxis(img, 0, -1)
I solve it by uninstalling scipy, and: pip install scipy==1.21