scholar-2001 commited on
Commit
335afa3
·
1 Parent(s): e5c93ae

Added all dependencies

Browse files
Files changed (3) hide show
  1. app.py +34 -0
  2. ensemble_model.h5 +3 -0
  3. requirements.txt +2 -0
app.py ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from tensorflow.keras.models import load_model
2
+ import streamlit as st
3
+ import cv2
4
+ import numpy as np
5
+ from PIL import Image
6
+ # Load the ensemble model using tf.keras.models.load_model()
7
+ loaded_ensemble_model = load_model('ensemble_model.h5')
8
+
9
+ st.markdown('<h1 style="color:red;">Ensemble Image classification model for Alzheimer</h1>', unsafe_allow_html=True)
10
+ st.markdown('<h2 style="color:gray;">The image classification model classifies brain scan image into following categories:</h2>', unsafe_allow_html=True)
11
+ st.markdown('<h3 style="color:gray;"> Moderate,Mild,Very Mild, NonDemented</h3>', unsafe_allow_html=True)
12
+
13
+ upload= st.file_uploader('Insert image for classification', type=['png','jpg'])
14
+ c1, c2= st.columns(2)
15
+ if upload is not None:
16
+ im= Image.open(upload)
17
+ im = im.convert('RGB')
18
+ img= np.asarray(im)
19
+ image= cv2.resize(img,(150, 150))
20
+ img_array = image.reshape(1,150,150,3)
21
+ c1.header('Input Image')
22
+ c1.image(im)
23
+
24
+ loaded_ensemble_model = load_model('ensemble_model.h5')
25
+ pred = loaded_ensemble_model.predict([img_array, img_array])
26
+ labels = {0:'MildDemented',1:'ModerateDemented',2:'NonDemented',3:'VeryMildDemented'}
27
+ output_array = pred
28
+ normalized_array = output_array / np.sum(output_array)
29
+ percentage_array = normalized_array * 100
30
+ c2.header('Output')
31
+ c2.subheader('Predicted class :')
32
+ c2.write(labels[pred.argmax()])
33
+ c2.subheader('With :')
34
+ c2.write(f'{int(np.max(percentage_array))}% assurity')
ensemble_model.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b63610a2561116e46a83ad420065ee8e5c679d59b49ddb28e82b1cdf293174dc
3
+ size 193319800
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ tensorflow
2
+ opencv-python