-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
73 lines (42 loc) · 1.91 KB
/
app.py
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import numpy as np
import pandas as pd
import tensorflow as tf
import matplotlib.pyplot as plt
from PIL import Image
import streamlit as st
from tensorflow import keras
import plotly.express as px
def main():
st.title('Mammogram 2nd Opinion')
st.write('Upload Mammogram image that you need to classify')
file = st.file_uploader('please upload an image')
if file:
image = Image.open(file)
resized_image = image.resize((224,224))
image_tf = tf.constant(resized_image)
image_tf = tf.expand_dims( image_tf, axis =0)
st.write(image_tf.shape)
model = keras.models.load_model('E:\Mammogram_app\My_model.hdf5')
pred_proba = model.predict(image_tf)
prediction_classes = ['BIRAD_1' , 'BIRAD_3' , 'BIRAD_4' , 'BIRAD_5']
prediction = prediction_classes[pred_proba.argmax()]
with st.spinner('please wait..'):
#for i in range(101):
#st.progress(i)
#do_something_slow()
with st.container():
s1,s2 = st.columns([0.5,0.5])
with s1:
st.image(image , use_column_width=False , )
with s2:
df = pd.DataFrame(data = pred_proba , columns = prediction_classes)
st.dataframe(df)
#st.number_input( value = prediction , format = '%.1f')
st.text_input('Model prediction' , f'{prediction}')
#st.markdown(f"Model Prediction = *{prediction}*")
figure = px.bar(data_frame= df)
st.plotly_chart(figure)
else:
st.text('You have not uploaded an image')
if __name__ == '__main__':
main()