Spaces:
Runtime error
Runtime error
File size: 1,089 Bytes
385062b 7518ba5 385062b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
import streamlit as st
import tensorflow as tf
from tensorflow.keras.preprocessing import image
import numpy as np
# Load the pre-trained model
model = tf.keras.models.load_model('model.h5')
# Define class labels
class_labels = ['Fractured', ' Not Fractured']
# Streamlit app
st.title('Bone Fracture Detection App')
# Upload an image for prediction
uploaded_image = st.file_uploader("Choose an image...", type=["jpg", "png", "jpeg"])
if uploaded_image is not None:
# Display the uploaded image
st.image(uploaded_image, caption='Uploaded Image', use_column_width=True)
# Preprocess the image for model prediction
img = image.load_img(uploaded_image, target_size=(224, 224))
img_array = image.img_to_array(img)
img_array = np.expand_dims(img_array, axis=0)
img_array /= 255.0
# Make prediction
prediction = model.predict(img_array)
predicted_class = int(np.round(prediction)[0][0])
# Display the prediction result
st.write(f"Predicted class: {class_labels[predicted_class]}")
st.write(f"Confidence: {prediction[0][0] * 100:.2f}%")
|