CoolFace
Apppublic

scholar-2001/Image_Classify

sourceHugging Faceupdated 3y agoView on Hugging Face
0likes
app.py32 linesDownload Raw Back to root
1from tensorflow.keras.models import load_model2import streamlit as st3import cv24import numpy as np5from PIL import Image6# Load the ensemble model using tf.keras.models.load_model()7loaded_ensemble_model = load_model('ensemble_model.h5')8 9st.markdown('<h1 style="color:red;">Ensemble Image classification model for Alzheimer</h1>', unsafe_allow_html=True)10st.markdown('<h2 style="color:gray;">The image classification model classifies brain scan image into following categories:</h2>', unsafe_allow_html=True)11st.markdown('<h3 style="color:gray;"> Moderate,Mild,Very Mild, NonDemented</h3>', unsafe_allow_html=True)12 13upload= st.file_uploader('Insert image for classification', type=['png','jpg'])14c1, c2= st.columns(2)15if 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,img_array])26    labels = {0:'MildDemented',1:'ModerateDemented',2:'NonDemented',3:'VeryMildDemented'}27    c2.header('Output')28    c2.subheader('Predicted class :')29    c2.write(labels[pred.argmax()])30    c2.subheader('With :')31    c2.write(f'{int(pred.max()*100)}% assurity')32