|
import tensorflow as tf
|
|
from tensorflow.keras.preprocessing import image
|
|
import numpy as np
|
|
import json
|
|
|
|
def predict_breed(img_path):
|
|
model = tf.keras.models.load_model("dog_breed_classifier.h5")
|
|
with open("class_indices.json", "r") as f:
|
|
class_indices = json.load(f)
|
|
class_names = {v: k for k, v in class_indices.items()}
|
|
|
|
img = image.load_img(img_path, target_size=(224, 224))
|
|
img_array = image.img_to_array(img) / 255.0
|
|
img_array = np.expand_dims(img_array, axis=0)
|
|
|
|
prediction = model.predict(img_array)
|
|
predicted_class = class_names[np.argmax(prediction)]
|
|
print(f"Predicted Dog Breed: {predicted_class}")
|
|
|
|
predict_breed(r"E:\Dog_Breed_Classification_model\dataset\Akita_Inu\Akita_Inu1.jpg") |