ValueError: Error when checking : expected input

xiaoxiao2021-02-28  10

ValueError: Error when checking : expected input_1 to have 4 dimensions, but got array with shape (50, 50, 3)

原因:预测的时候给的是数组,需要转成array,np.asarray(imagelist)

下面是正确代码:

path = '../../white_mouse_data/test/1/' # path=r"D:\git_project\mouse_detect_demo\mouse_data\0_test\\" files = os.listdir(path) aaa = 0 index = 0 imagelist = [] for file in files: a = cv2.imread(path + file) a=cv2.resize(a,(IMG_SIZE,IMG_SIZE),interpolation=cv2.INTER_CUBIC) imagelist.append(a) t0 = time.time() result = model.predict(np.asarray(imagelist))

转载请注明原文地址: https://www.6miu.com/read-1450102.html

最新回复(0)