|
import streamlit as st
|
|
import pickle
|
|
from Prediction import Prediction
|
|
from transformers import TFAutoModel
|
|
|
|
|
|
|
|
|
|
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")
|
|
|
|
|
|
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...")
|
|
|