我使用以下程序來預測圖像的類別。from tensorflow.keras.preprocessing.image import load_img, img_to_arrayx = load_img("8-SignLanguageMNIST/test1.jpg", target_size = (28, 28))x = img_to_array(x)x = np.expand_dims(x, axis = 0)x = np.vstack([x])classes = model.predict(x)print(classes[0])我用于訓練的圖像形狀為 (28, 28, 1)。在這里,我上傳了一個形狀為 (28, 28, 3) 的 RGB 圖像,我嘗試將該圖像轉(zhuǎn)換為灰度,然后進行預測,但一直出現(xiàn)以下錯誤。ValueError: Input 0 of layer sequential is incompatible with the layer: expected axis -1 of input shape to have value 1 but received input with shape [None, 28, 28, 3]誰能告訴我我做錯了什么,并幫助我解決這個問題。
添加回答
舉報
0/150
提交
取消