Code:
from tensorflow.keras.models import load_model
import numpy as np
import cv2
model = load_model(“model.h5”)
model.compile(optimizer=“adam”, loss=“binary_crossentropy”, metrics=[“accuracy”])
image = cv2.imread("/content/000001-13.jpg")
image = cv2.resize(image, (222,222))
image = np.reshape(image, [-1, 222, 222, 3])
classes = model.predict_classes(image)
Error: “Input 0 of layer dense is incompatible with the layer: expected axis -1 of input shape to have value 86528 but received input with shape [None, 80000]”
Summary:
Layer (type) Output Shape Param #
conv2d (Conv2D) (None, 222, 222, 32) 896
conv2d_1 (Conv2D) (None, 220, 220, 64) 18496
max_pooling2d (MaxPooling2D) (None, 110, 110, 64) 0
dropout (Dropout) (None, 110, 110, 64) 0
conv2d_2 (Conv2D) (None, 108, 108, 64) 36928
max_pooling2d_1 (MaxPooling2 (None, 54, 54, 64) 0
dropout_1 (Dropout) (None, 54, 54, 64) 0
conv2d_3 (Conv2D) (None, 52, 52, 128) 73856
max_pooling2d_2 (MaxPooling2 (None, 26, 26, 128) 0
dropout_2 (Dropout) (None, 26, 26, 128) 0
flatten (Flatten) (None, 86528) 0
dense (Dense) (None, 64) 5537856
dropout_3 (Dropout) (None, 64) 0
dense_1 (Dense) (None, 1) 65
Total params: 5,668,097
Trainable params: 5,668,097
Non-trainable params: 0
Traaining :
history = model.fit(
train_images,
epochs = 12,
validation_data = val_images,
)
Sir can you please look whats the mistake here
Train % : model.evaluate(train_images)
[0.25312402844429016, 0.9093277454376221]
Val% : model.evaluate(val_images)
[0.49530839920043945, 0.7916666865348816]