Views
No views yet
1import tensorflow as tf
2from PIL import Image
3import numpy as np
4
5# Load model
6model = tf.keras.models.load_model('model.keras')
7
8# Prepare image
9image = Image.open('your_image.jpg').resize((224, 224))
10image_array = np.array(image) / 255.0
11image_array = np.expand_dims(image_array, axis=0)
12
13# Predict
14predictions = model.predict(image_array)
15class_names = ['Esophagitis', 'GERD', 'Normal', 'Ulcer']
16predicted_class = class_names[np.argmax(predictions)]
17confidence = np.max(predictions)
18
19print(f"Predicted: {predicted_class} (Confidence: {confidence:.2%})")