(debug到一半才想起要写这么个记录......)
2021/1/12
1. ValueError: At least one stride in the given numpy array is negative, and tensors with negative strides are not currently supported. (You can probably work around this by making a copy of your array with array.copy().)
这个原因是因为程序中操作的numpy中有使用负索引的情况:image[…, ::-1]。解决办法比较简单,加入image这个numpy变量引发了错误,返回image.copy()即可。因为copy操作可以在原先的numpy变量中创造一个新的不适用负索引的numpy变量。
所以我在image[…, ::-1]后边加了个.copy()就可以了。
image = cv2.imread(path)
## image = image[:,:,::-1] 这是出错时候写的
image = image[:,:,::-1].copy() ## 加上.copy()之后就没有报这个错误了