File size: 1,347 Bytes
335afa3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a172fdb
335afa3
 
 
 
 
20443ad
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
from tensorflow.keras.models import load_model
import streamlit as st
import cv2
import numpy as np
from PIL import Image
# Load the ensemble model using tf.keras.models.load_model()
loaded_ensemble_model = load_model('ensemble_model.h5')

st.markdown('<h1 style="color:red;">Ensemble Image classification model for Alzheimer</h1>', unsafe_allow_html=True)
st.markdown('<h2 style="color:gray;">The image classification model classifies brain scan image into following categories:</h2>', unsafe_allow_html=True)
st.markdown('<h3 style="color:gray;"> Moderate,Mild,Very Mild, NonDemented</h3>', unsafe_allow_html=True)

upload= st.file_uploader('Insert image for classification', type=['png','jpg'])
c1, c2= st.columns(2)
if upload is not None:
    im= Image.open(upload)
    im = im.convert('RGB')
    img= np.asarray(im)
    image= cv2.resize(img,(150, 150))
    img_array = image.reshape(1,150,150,3)
    c1.header('Input Image')
    c1.image(im)

    loaded_ensemble_model = load_model('ensemble_model.h5')
    pred = loaded_ensemble_model.predict([img_array,img_array,img_array])
    labels = {0:'MildDemented',1:'ModerateDemented',2:'NonDemented',3:'VeryMildDemented'}
    c2.header('Output')
    c2.subheader('Predicted class :')
    c2.write(labels[pred.argmax()])
    c2.subheader('With :')
    c2.write(f'{int(pred.max()*100)}% assurity')