И выводит одну из трех категорий.
Код: Выделить всё
img = cv2.imread(path)
img = cv2.Canny(img, 33, 76)
img = np.resize(img, (26, 26, 1))
imgs.append(img)
Код: Выделить всё
IMG_HEIGHT = 26
IMG_WIDTH = 26
no_Of_Filters=60
size_of_Filter=(5,5)
size_of_pool=(2,2)
no_Of_Nodes = 500
model_new = Sequential([
Conv2D(no_Of_Filters, size_of_Filter, padding='same', activation='relu', input_shape=(IMG_HEIGHT, IMG_WIDTH , 1)),
MaxPooling2D(pool_size=size_of_pool),
Conv2D(no_Of_Filters, size_of_Filter, padding='same', activation='relu'),
MaxPooling2D(pool_size=size_of_pool),
Conv2D(64, size_of_Filter, padding='same', activation='relu'),
MaxPooling2D(pool_size=size_of_pool),
Flatten(),
Dense(512, activation='relu'),
Dense(3, activation='softmax')
])
Код: Выделить всё
test_image = cv2.Canny(test_image ,33,76)
test_image = np.resize(test_image, (26, 26, 1))
test_image = test_image [np.newaxis, ...]
prediction = model.predict(test_image)
print(prediction)
Код: Выделить всё
ValueError: Error when checking input: expected conv2d_1_input to have 4 dimensions, but got array with shape (26, 26, 1)
Подробнее здесь: https://stackoverflow.com/questions/608 ... -to-have-4