File size: 2,881 Bytes
4de9c2d
 
 
a7de3a4
4de9c2d
 
 
 
 
a7de3a4
 
 
 
 
999a71a
 
a7de3a4
 
 
 
 
 
 
999a71a
4de9c2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
999a71a
 
4de9c2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import streamlit as st
import pickle
from Prediction import  Prediction
from huggingface_hub import hf_hub_download


# resnet_model = pickle.load(open('models/ResNet01.pkl','rb'))
# cnn_model = pickle.load(open('models/CNNModel2.pkl','rb'))
# inc_model = pickle.load(open('models/Inception01.pkl','rb'))
# resnet_model = TFAutoModel.from_pretrained("yashpat85/ResNet01")

REPO_ID1 = "yashpat85/ResNet01"
MODEL_DIR1 = hf_hub_download(repo_id=REPO_ID1, filename="ResNet01.pkl", repo_type="model")

REPO_ID2= "yashpat85/Inception01"
MODEL_DIR2 = hf_hub_download(repo_id=REPO_ID2, filename="Inception01.pkl", repo_type="model")

REPO_ID3 = "yashpat85/CNNModel2"
MODEL_DIR3 = hf_hub_download(repo_id=REPO_ID3, filename="CNNModel2.pkl", repo_type="model")


resnet_model = pickle.load(open(MODEL_DIR1,'rb'))
cnn_model = pickle.load(open(MODEL_DIR3,'rb'))
inc_model = pickle.load(open(MODEL_DIR2,'rb'))

def show_error_popup(message):
    st.error(message, icon="🚨")

st.set_page_config(layout="wide")

st.title('Kidney Disease Classification using CNN')
st.markdown('By 22DCS079 & 22DCS085')

st.header('Add Ct Scan Image')

uploaded_file = st.file_uploader("Choose a ct scan image", type=["jpg", "png", "jpeg"])

st.header("Available Models")
option = st.selectbox(
    "Available Models",
    ("ResNet", "CNN","InceptionNet"),
)

pm = Prediction()

col1, col2= st.columns(2)

if uploaded_file is not None:
    with col1:
        image_data = uploaded_file.read()
        st.image(image_data, caption="Uploaded Image")
    with col2:
        if option=="CNN":
            p = pm.predict_image(cnn_model, image_data)
        elif option=="ResNet":
            p = pm.predict_image(resnet_model, image_data)
        elif option=="InceptionNet":
            p = pm.predict_image(inc_model, image_data)
        else:
            p = "Other Models are still under training due to overfitting"

        print(p)

        if p=='Normal':
            st.markdown("""
            <style>
            .big-font {
                display: flex;
                align-items:center;
                justify-content: center;
                font-size:50px !important;
                color:green;
                height: 50vh;
            }
            </style>
            """, unsafe_allow_html=True)

            st.markdown(f'<div class="big-font">{p}</div>', unsafe_allow_html=True)
        else:
            st.markdown("""
            <style>
            .big-font {
                display: flex;
                align-items:center;
                justify-content: center;
                font-size:50px !important;
                color:red;
                height: 50vh;
            }
            </style>
            """, unsafe_allow_html=True)

            st.markdown(f'<div class="big-font">{p}</div>', unsafe_allow_html=True)
else:
    show_error_popup("Please Upload Image...")