When use torch.from_numpy from the Ndarray with negative strides, there is a runtime error
’RuntimeError: some of the strides of a given numpy array are negative.'
For example,
import numpy as np
x=np.random.random(size=(32,32,7))
torch.from_numpy(np.flip(x,axis=0))
RuntimeError: some of the strides of a given numpy array are negative. This is currently not supported, but will be added in future releases.
This means that your numpy array has undergone such operation: image = image[..., ::-1]
I guess this has something to do with how numpy array are stored in memory, and unfortunately PyTorch doesn’t currently support numpy array that has been reversed using negative stride.
If you don’t want to flip the image, if for example you have already trained a network with un-flipped images, then you can save and load the image before passing it for inference.