File size: 1,235 Bytes
3982870
 
24bab8a
 
 
343c9a4
e645000
a90efc8
3982870
5c7c640
3982870
ac8451b
 
 
 
3982870
 
 
 
 
86f5b35
 
e645000
9d76973
e645000
a9ea4ad
e645000
f6ad381
8904fa3
 
 
 
 
 
 
76ac1d3
fa7aca9
f6ad381
 
 
 
8904fa3
 
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
36
37
38
39
40
41
42
43
import streamlit as st
import tensorflow as tf
import cv2
import numpy as np
from PIL import Image, ImageOps
import imageio.v3 as iio

@st.cache_resource()
def load_model():
    model=tf.keras.models.load_model('./hip_impant_model.h5')
    return model
    
st.title(":blue[Nishant Guvvada's] :red[AI Journey]  The Hip-Implant X-ray Assistant")
image = Image.open('./title.jpg')
st.image(image)
st.write("""
         # Image Classification
         """
         )

file = st.file_uploader("Upload an X-ray image", type= ['png', 'jpg'])

def model_prediction(path):
    resize = tf.image.resize(path, (256,256))
    with st.spinner('Model is being loaded..'):
        model=load_model()
    yhat = model.predict(np.expand_dims(resize/255, 0))
    return yhat

def on_click():
    if file is None:
        st.text("Please upload an image file")
    else:
        image = Image.open(file)
        st.image(image, use_column_width=True)
        image = image.convert('RGB')
        predictions = model_prediction(np.array(image))
        if (predictions>0.5):
            st.write("""# Prediction : Implant is loose""")
        else:
            st.write("""# Prediction : Implant is in control""")

st.button('Predict', on_click=on_click)