AIOmarRehan/Cats_and_Dogs
Viewer โข Updated โข 25k โข 177 โข 1
This repository contains a pre-trained TensorFlow/Keras model:
InceptionV3_Dogs_and_Cats_Classification.h5 Architecture: Transfer Learning using InceptionV3 (pre-trained on ImageNet)
Custom Classification Head:
Input: Images resized to 256 ร 256 pixels
Output: Probability of "Dog" class (values close to 1 indicate dog, close to 0 indicate cat)
from tensorflow.keras.models import load_model
from PIL import Image
import numpy as np
# Load the model
model = load_model("InceptionV3_Dogs_and_Cats_Classification.h5")
# Preprocess an image
img = Image.open("cat_or_dog.jpg").resize((256, 256))
img_array = np.expand_dims(np.array(img)/255.0, axis=0)
# Predict
prediction = model.predict(img_array)
print("Dog" if prediction[0][0] > 0.5 else "Cat")