首页 > 其他分享> > ValueError: Error when checking : expected input_1 to have 4 dimensions, but got array with shape
ValueError: Error when checking : expected input_1 to have 4 dimensions, but got array with shape
作者:互联网
原因:预测的时候给的是数组,需要转成array。
正确的写法:
emotion_classifier=load_model("weights_best_simple_model.h5") t1=time.time() image = cv2.imdecode(np.fromfile('0.jpg', dtype=np.uint8), -1) # load the image, pre-process it, and store it in the data list image = cv2.resize(image, (norm_size, norm_size), interpolation=cv2.INTER_LANCZOS4) image = img_to_array(image) imagelist.append(image) imageList = np.array(imagelist, dtype="float") / 255.0 pre=np.argmax(emotion_classifier.predict(imageList))
标签:emotion,load,dimensions,checking,image,cv2,np,got,array 来源: https://blog.51cto.com/u_15194128/2761769