Views
No views yet
InceptionV3_Dogs_and_Cats_Classification.h51from tensorflow.keras.models import load_model
2from PIL import Image
3import numpy as np
4
5# Load the model
6model = load_model("InceptionV3_Dogs_and_Cats_Classification.h5")
7
8# Preprocess an image
9img = Image.open("cat_or_dog.jpg").resize((256, 256))
10img_array = np.expand_dims(np.array(img)/255.0, axis=0)
11
12# Predict
13prediction = model.predict(img_array)
14print("Dog" if prediction[0][0] > 0.5 else "Cat")