yashpat85 commited on
Commit
4de9c2d
·
verified ·
1 Parent(s): a32da41

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +83 -83
app.py CHANGED
@@ -1,83 +1,83 @@
1
- import streamlit as st
2
- import pickle
3
- from Prediction import Prediction
4
- from transformers import TFAutoModel
5
-
6
-
7
-
8
- # resnet_model = pickle.load(open('models/ResNet01.pkl','rb'))
9
- cnn_model = pickle.load(open('models/CNNModel2.pkl','rb'))
10
- inc_model = pickle.load(open('models/Inception01.pkl','rb'))
11
- resnet_model = TFAutoModel.from_pretrained("yashpat85/ResNet01")
12
-
13
-
14
- def show_error_popup(message):
15
- st.error(message, icon="🚨")
16
-
17
- st.set_page_config(layout="wide")
18
-
19
- st.title('Kidney Disease Classification using CNN')
20
- st.markdown('By 22DCS079 & 22DCS085')
21
-
22
- st.header('Add Ct Scan Image')
23
-
24
- uploaded_file = st.file_uploader("Choose a ct scan image", type=["jpg", "png", "jpeg"])
25
-
26
- st.header("Available Models")
27
- option = st.selectbox(
28
- "Available Models",
29
- ("ResNet", "CNN","InceptionNet"),
30
- )
31
-
32
- pm = Prediction()
33
-
34
- col1, col2= st.columns(2)
35
-
36
- if uploaded_file is not None:
37
- with col1:
38
- image_data = uploaded_file.read()
39
- st.image(image_data, caption="Uploaded Image")
40
- with col2:
41
- if option=="CNN":
42
- p = pm.predict_image(cnn_model, image_data)
43
- elif option=="ResNet":
44
- p = pm.predict_image(resnet_model, image_data)
45
- elif option=="InceptionNet":
46
- p = pm.predict_image(inc_model, image_data)
47
- else:
48
- p = "Other Models are still under training due to overfitting"
49
-
50
- print(p)
51
-
52
- if p=='Normal':
53
- st.markdown("""
54
- <style>
55
- .big-font {
56
- display: flex;
57
- align-items:center;
58
- justify-content: center;
59
- font-size:50px !important;
60
- color:green;
61
- height: 50vh;
62
- }
63
- </style>
64
- """, unsafe_allow_html=True)
65
-
66
- st.markdown(f'<div class="big-font">{p}</div>', unsafe_allow_html=True)
67
- else:
68
- st.markdown("""
69
- <style>
70
- .big-font {
71
- display: flex;
72
- align-items:center;
73
- justify-content: center;
74
- font-size:50px !important;
75
- color:red;
76
- height: 50vh;
77
- }
78
- </style>
79
- """, unsafe_allow_html=True)
80
-
81
- st.markdown(f'<div class="big-font">{p}</div>', unsafe_allow_html=True)
82
- else:
83
- show_error_popup("Please Upload Image...")
 
1
+ import streamlit as st
2
+ import pickle
3
+ from Prediction import Prediction
4
+ from transformers import TFAutoModel
5
+
6
+
7
+
8
+ # resnet_model = pickle.load(open('models/ResNet01.pkl','rb'))
9
+ # cnn_model = pickle.load(open('models/CNNModel2.pkl','rb'))
10
+ # inc_model = pickle.load(open('models/Inception01.pkl','rb'))
11
+ resnet_model = TFAutoModel.from_pretrained("yashpat85/ResNet01")
12
+
13
+
14
+ def show_error_popup(message):
15
+ st.error(message, icon="🚨")
16
+
17
+ st.set_page_config(layout="wide")
18
+
19
+ st.title('Kidney Disease Classification using CNN')
20
+ st.markdown('By 22DCS079 & 22DCS085')
21
+
22
+ st.header('Add Ct Scan Image')
23
+
24
+ uploaded_file = st.file_uploader("Choose a ct scan image", type=["jpg", "png", "jpeg"])
25
+
26
+ st.header("Available Models")
27
+ option = st.selectbox(
28
+ "Available Models",
29
+ ("ResNet", "CNN","InceptionNet"),
30
+ )
31
+
32
+ pm = Prediction()
33
+
34
+ col1, col2= st.columns(2)
35
+
36
+ if uploaded_file is not None:
37
+ with col1:
38
+ image_data = uploaded_file.read()
39
+ st.image(image_data, caption="Uploaded Image")
40
+ with col2:
41
+ if option=="CNN":
42
+ p = pm.predict_image(cnn_model, image_data)
43
+ elif option=="ResNet":
44
+ p = pm.predict_image(resnet_model, image_data)
45
+ elif option=="InceptionNet":
46
+ p = pm.predict_image(inc_model, image_data)
47
+ else:
48
+ p = "Other Models are still under training due to overfitting"
49
+
50
+ print(p)
51
+
52
+ if p=='Normal':
53
+ st.markdown("""
54
+ <style>
55
+ .big-font {
56
+ display: flex;
57
+ align-items:center;
58
+ justify-content: center;
59
+ font-size:50px !important;
60
+ color:green;
61
+ height: 50vh;
62
+ }
63
+ </style>
64
+ """, unsafe_allow_html=True)
65
+
66
+ st.markdown(f'<div class="big-font">{p}</div>', unsafe_allow_html=True)
67
+ else:
68
+ st.markdown("""
69
+ <style>
70
+ .big-font {
71
+ display: flex;
72
+ align-items:center;
73
+ justify-content: center;
74
+ font-size:50px !important;
75
+ color:red;
76
+ height: 50vh;
77
+ }
78
+ </style>
79
+ """, unsafe_allow_html=True)
80
+
81
+ st.markdown(f'<div class="big-font">{p}</div>', unsafe_allow_html=True)
82
+ else:
83
+ show_error_popup("Please Upload Image...")