-
Notifications
You must be signed in to change notification settings - Fork 0
/
webApp.py
97 lines (83 loc) · 1.99 KB
/
webApp.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
from PIL import Image
import numpy as np
import streamlit as st
from keras.models import load_model
from tensorflow.keras.utils import img_to_array
from tensorflow.keras.preprocessing import image
import keras.backend as K
model = load_model('../Downloads/TrioCNNBM.h5')
classes = {
0:'No DR',
1:'Mild',
2:'Moderate',
3:'Severe',
4:' Proliferative DR'
}
st.markdown(
"""
<style>
.header-style {
font-size:25px;
font-family:sans-serif;
position:absolute;
text-align: center;
color: 032131;
}
</style>
""",
unsafe_allow_html=True
)
st.markdown(
"""
<style>
.font-style {
font-size:20px;
font-family:sans-serif;
}
</style>
""",
unsafe_allow_html=True
)
st.markdown(
"""
<style>
.footer-style {
font-size: 15px;
font-family: sans-serif;
position: fixed;
position: fixed;
left: 0;
bottom: 0;
width: 100%;
background-color: #262339;
color: white;
text-align: center;
}
</style>
""",
unsafe_allow_html=True
)
st.header('')
st.markdown(
'<p class="header-style">Automated System of Diabetic Ratinopathy Detection</p>',
unsafe_allow_html=True
)
def load_image(img):
test_image = image.load_img(img,target_size=(224,224,3))
test_image = np.array(test_image)
return test_image
def classify(img):
K.clear_session()
test_image = np.expand_dims(img,axis=0)
prediction_result = model.predict(test_image)
status = np.argmax(prediction_result,axis=1)[0]
column_1, column_2 = st.columns(2)
column_1.write("Patient Status : ")
column_2.write(f"{classes[status]}")
uploadFile = st.file_uploader(label="Upload image", type=['jpg', 'png','jpeg'],accept_multiple_files = False)
if uploadFile is not None:
img = load_image(uploadFile)
st.image(img)
st.write("Image Uploaded Successfully")
if st.button('Classify Image'):
classify(img)