File size: 1,034 Bytes
ea5b7d5
59a2d05
ea5b7d5
 
 
 
 
 
 
1f85d6b
a702025
ea5b7d5
59a2d05
 
ea5b7d5
59a2d05
1f85d6b
ea5b7d5
1f85d6b
20213fc
 
 
 
 
 
 
 
 
 
 
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
#%%
import plotly.express as px
import numpy as np
import pandas as pd
import streamlit as st
import tensorflow as tf
from keras.preprocessing import image
#docker build -t streamlit
# docker compose up
image_file_prev = ""
model = tf.keras.models.load_model("cnnBoneFracRec.h5")
st.markdown("## Bone Fracture Recognition with TensorFlow")


image_file = st.file_uploader("Upload X-Ray Image", type=['png', 'jpg'])

if image_file_prev != image_file and image_file:
    st.image(image_file, caption=None, width=None, use_column_width=None, clamp=False, channels="RGB", output_format="auto")
    image_file_prev = image_file
    target_names = ['Non-Fractured', 'Fractured']
    temp_img = image.load_img(image_file, target_size=(100, 100))
    x = image.img_to_array(temp_img)
    x = np.expand_dims(x, axis=0)
    images = np.vstack([x])
    prediction = np.argmax(model.predict(images), axis=1)

    prediction_str = target_names[prediction.item()]

    if prediction_str:
        st.markdown(f"##### Prediction : {prediction_str}")