Views
No views yet
cat_dog_classifier_model.h5 - Pre-trained Keras/TensorFlow modeltensorflow>=2.0
numpy
pillowpip install tensorflow numpy pillow1from tensorflow.keras.models import load_model
2from tensorflow.keras.preprocessing import image
3import numpy as np
4
5# Load the model
6model = load_model('cat_dog_classifier_model.h5')
7
8# Load and preprocess an image
9img_path = 'your_image.jpg'
10img = image.load_img(img_path, target_size=(150, 150)) # Adjust size as needed
11img_array = image.img_to_array(img)
12img_array = np.expand_dims(img_array, axis=0)
13img_array = img_array / 255.0 # Normalize
14
15# Make prediction
16prediction = model.predict(img_array)
17
18# Interpret result
19if prediction[0] > 0.5:
20 print("Dog")
21else:
22 print("Cat")target_size based on the model's expected input dimensions