from tensorflow.keras.models import load_model import streamlit as st import requests from streamlit_lottie import st_lottie 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') def load_lottieurl(url): r = requests.get(url) if r.status_code != 200: return None return r.json() # Use local CSS def local_css(file_name): with open(file_name) as f: st.markdown(f"", unsafe_allow_html=True) local_css("style/styles.css") # ---- LOAD ASSETS ---- lottie_coding = load_lottieurl("https://lottie.host/6b8742e7-e4f5-4403-8bc0-1d5c2fae6e55/ah80z8X1Hu.json") img_contact_form = Image.open("images/yt_contact_form.png") img_lottie_animation = Image.open("images/yt_lottie_animation.png") # ---- HEADER SECTION ---- with st.container(): st.subheader("Hi, Good Morning! :wave:") st.title("Welcome To Alzheimer Disease Detection Web App") st.write( "Alzheimer's disease is a progressive brain disorder that causes memory loss, cognitive decline, and changes in behavior." ) st.write("[Learn More >](https://en.wikipedia.org/wiki/Alzheimer%27s_disease)") # ---- FOUR TYPES OF CLASSES ---- with st.container(): st.write("---") left_column, right_column = st.columns(2) with left_column: st.header("Description:") st.write("##") st.write( """ We have devided the alzheimers disease into four stages namely: - Non-Demented: Individuals with no signs of dementia. - Mild Demented: Individuals with mild cognitive impairment. - Moderate Demented: Individuals with moderate cognitive impairment. - Very Mild Demented: Individuals with very mild cognitive impairment." We are aiming at providing the early detection of the disease using this web application, which will help the early diagnosis. """ ) # st.write("[aisa likh jo link ko specify kre](kuch bhi link daal de)") with right_column: st_lottie(lottie_coding, height=300, key="coding") # --- INPUT-OUTPUT --- st.header('Insert image for classification:') upload = st.file_uploader('', type=['png', 'jpg']) 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) # Resize the image to 176x208 pixels resized_im = im.resize((176, 208)) st.header('Input Image') # Display the resized image st.image(resized_im, use_column_width=False, width=176, caption='Uploaded Image') 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'} st.header('Output') col1, col2 = st.columns(2) with col1: st.subheader('Predicted class:') st.write(labels[pred.argmax()]) with col2: st.subheader('With:') st.write(f'{int(pred.max() * 100)}% assurity') # ---- CONTACT ---- with st.container(): st.write("---") st.header("For any queries or suggestions!") st.write("##") # Documention: https://formsubmit.co/ !!! CHANGE EMAIL ADDRESS !!! contact_form = """
""" left_column, right_column = st.columns(2) with left_column: st.markdown(contact_form, unsafe_allow_html=True) with right_column: st.empty()