Views
No views yet
1import tensorflow as tf
2from PIL import Image
3import numpy as np
4
5model = tf.keras.models.load_model("Sports_Balls_Classification.h5")
6
7img = Image.open("sports_ball.jpg").convert("RGB")
8img = img.resize((225, 225))
9img_array = np.array(img).astype("float32") / 255.0
10img_array = np.expand_dims(img_array, axis=0)
11
12predictions = model.predict(img_array)
13predicted_class = np.argmax(predictions[0])
14confidence = np.max(predictions[0])