CNN Program
CNN Program
import tensorflow as tf
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Conv2D, MaxPooling2D, Flatten,
Dense, Dropout
from tensorflow.keras.preprocessing.image import ImageDataGenerator
import numpy as np
import matplotlib.pyplot as plt
import cv2
# Load and preprocess the CIFAR-10 dataset, selecting only dog and cat
classes
(x_train, y_train), (x_test, y_test) =
tf.keras.datasets.cifar10.load_data()
model.compile(optimizer='adam',
loss='binary_crossentropy',
metrics=['accuracy'])
prediction = model.predict(img)
# Example usage:
image_path = '/content/ket.jpg'
predict_image(image_path)
Output: