<jupyter_start><jupyter_text>Dogs vs. Cats Prediction Problem* https://www.tensorflow.org/tutorials/images/cnn* https://machinelearningmastery.com/how-to-develop-a-convolutional-neural-network-to-classify-photos-of-dogs-and-cats/<jupyter_code>from tensorflow.keras.preprocessing.image import load_img, img_to_array
from tensorflow.keras.models import load_model<jupyter_output><empty_output><jupyter_text>Load image to be predicted<jupyter_code># Load and prepare the image
def load_image(filename):
    # Load the image
    img = load_img(filename, target_size=(32, 32))
    # Convert to array
    img = img_to_array(img)
    # Reshape into a single sample with 3 channels
    img = img.reshape(1, 32, 32, 3)
    # Center pixel data
    img = img.astype('float32')
    img = img - [123.68, 116.779, 103.939]
    return img
# Load the image
# https://3qeqpr26caki16dnhd19sv6by6v-wpengine.netdna-ssl.com/wp-content/uploads/2019/03/sample_image.jpg
img = load_image('sample_image.jpeg')
# Load model
model = load_model('final_model.h5')
# Predict the class
result = model.predict(img)
# 0 - Cat , 1 - Dog
# Wrong prediction
result[0]<jupyter_output><empty_output>
StarcoderdataJupyterStructuredCleanDedup