Views
No views yet
1import tensorflow as tf
2from preprocessing import preprocess_image
3
4# Load the model
5model = tf.keras.models.load_model("model.keras")
6
7# Preprocess an image
8img = preprocess_image("path/to/chest_xray.jpg")
9
10# Make prediction
11prediction = model.predict(img)
12probability = prediction[0][0]
13
14# Interpret results
15if probability > 0.5:
16 result = "PNEUMONIA"
17 confidence = probability
18else:
19 result = "NORMAL"
20 confidence = 1 - probability
21
22print(f"Prediction: {result} with {confidence:.2%} confidence")