Views
No views yet
1import tensorflow as tf
2import numpy as np
3from PIL import Image
4
5# Load the model
6model = tf.keras.models.load_model('model.keras', compile=False)
7
8# Preprocess image
9def preprocess_image(image_path):
10 image = Image.open(image_path).convert('RGB')
11 image = image.resize((256, 256))
12 img_array = np.array(image) / 255.0
13 img_array = np.expand_dims(img_array, axis=0)
14 return img_array
15
16# Make prediction
17image_array = preprocess_image('your_image.jpg')
18prediction = model.predict(image_array)