内存地址不连续的问题
加一句np.ascontiguousarray就好了
报错
pytorch使用cv2读取图片,并转换成RGB顺序的时候,在用torch.from_numpy转换成tensor的时候,报错:{ValueError}some of the strides of a given numpy array are negative. This is currently not supported, but will be added in future releases.
解决方案
图像颜色通道转换之后,使用copy(),然后在转换成tensor
参考代码
img = cv2.imread(imgpath)
img = img[:,:,::-1].copy()
img_tensor = torch.from_numpy(img)
some of the strides of a given numpy array are negative
解决:
conf_t3[np.ascontiguousarray(order).copy()]