nisharg nargund commited on
Commit
385062b
·
1 Parent(s): 278ea7c

Create app.py

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