无法弄清楚为什么CV2无法调整图像大小。我尝试使用不同的图像尺寸,但似乎没有任何效果。 TRAIN_DIR包含大小约为(1000,1700)的.jpg图像。无法弄清楚如何将我的图像获取为numpy数组,并避免函数调整大小时出现错误(-215)ssize.width> 0 && ssize.height> 0
TRAIN_DIR = 'rgupt44/projects/project0/train'
TEST_DIR = 'rgupt44/projects/project0/test'
IMG_SIZE = 500
LR = 1e-3
Model_Name = 'SkinCancer-{}-{}.model'.format(LR, '2conv-basic')
def create_train_data():
train_data = []
for img in os.listdir(TRAIN_DIR):
label = label_img
path = os.path.join(TRAIN_DIR,img)
img = cv2.resize(cv2.imread(path, cv2.IMREAD_GRAYSCALE), (IMG_SIZE, IMG_SIZE))
train_data.append([np.array(img), np.array(label)])
shuffle(train_data)
np.save('train_data.npy', train_data)
return(train_data)
error Traceback (most recent call last)
<ipython-input-80-b04e7dcaf926> in <module>()
----> 1 Train_data = create_train_data()
<ipython-input-78-8b419e328251> in create_train_data()
4 label = label_img
5 path = os.path.join(TRAIN_DIR,img)
----> 6 img = cv2.resize(cv2.imread(path, cv2.IMREAD_GRAYSCALE), (IMG_SIZE, IMG_SIZE))
7 train_data.append([np.array(img), np.array(label)])
8 shuffle(train_data)
error: /tmp/build/80754af9/opencv_1512680316562/work/modules/imgproc/src/resize.cpp:3289: error: (-215) ssize.width > 0 && ssize.height > 0 in function resize