-
-
Notifications
You must be signed in to change notification settings - Fork 357
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #561 from aindree-2005/web
Web Application for Alzheimers Detection
- Loading branch information
Showing
10 changed files
with
90 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import streamlit as st | ||
from PIL import Image | ||
import numpy as np | ||
import os | ||
import tempfile | ||
import tensorflow as tf | ||
|
||
# Function to load the model | ||
@st.cache_resource | ||
def load_model(): | ||
script_dir = os.path.dirname(__file__) | ||
rel_path = 'model.h5' | ||
abs_model_path = os.path.join(script_dir, rel_path) | ||
model = tf.keras.models.load_model(abs_model_path) | ||
return model | ||
|
||
|
||
model = load_model() | ||
|
||
st.title("Alzheimer's Detection") | ||
|
||
st.header("About Alzheimer's Disease") | ||
st.write(""" | ||
Alzheimer's disease is a progressive neurologic disorder that causes the brain to shrink (atrophy) and brain cells to die. | ||
Alzheimer's disease is the most common cause of dementia — a continuous decline in thinking, behavioral and social skills | ||
that affects a person's ability to function independently. | ||
The disease is classified into different stages based on the severity of symptoms: Mild Demented, Moderate Demented, | ||
Non Demented, and Very Mild Demented. | ||
""") | ||
|
||
st.header("Sample Image") | ||
script_dir = os.path.dirname(__file__) | ||
rel_path = "../Images/image.jpg" | ||
abs_file_path = os.path.join(script_dir, rel_path) | ||
try: | ||
image = Image.open(abs_file_path) | ||
st.image(image, caption='Sample Brain Scan Image') | ||
except Exception as e: | ||
st.write(f"Error loading image: {e}") | ||
|
||
st.header("Upload Your MRI Scan") | ||
scan = st.file_uploader("Choose an image...", type=["jpg", "jpeg", "png"]) | ||
|
||
def preprocess_image(image, target_size): | ||
image = image.convert("RGB") | ||
image = image.resize(target_size) | ||
image_array = tf.keras.preprocessing.image.img_to_array(image) | ||
image_array = np.expand_dims(image_array, axis=0) | ||
return image_array | ||
|
||
if scan is not None: | ||
if st.button('Upload'): | ||
try: | ||
with tempfile.NamedTemporaryFile(delete=False) as tmp_file: | ||
tmp_file.write(scan.read()) | ||
tmp_path = tmp_file.name | ||
|
||
img = Image.open(tmp_path) | ||
st.image(img, caption='Uploaded Brain Scan Image') | ||
img_array = preprocess_image(img, target_size=(176, 176)) | ||
predictions = model.predict(img_array) | ||
predicted_class = np.argmax(predictions, axis=1) | ||
class_labels = ['MildDemented', 'ModerateDemented', 'NonDemented', 'VeryMildDemented'] | ||
result = class_labels[predicted_class[0]] | ||
st.markdown(f'<h3 style="color: red;">Prediction: {result}</h3>', unsafe_allow_html=True) | ||
|
||
os.remove(tmp_path) | ||
except Exception as e: | ||
st.write(f"Error processing uploaded image: {e}") |
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Alzheimer's Detection Web Application | ||
|
||
## Goal 🎯 | ||
The main goal of this project is to provide a user-friendly web application for the detection of Alzheimer's disease using deep learning models. The application aims to assist healthcare professionals in accurately diagnosing Alzheimer's disease in patients based on brain scan images. | ||
|
||
## Model Used for the Web App 🧮 | ||
The web application utilizes a deep learning model trained for Alzheimer's detection. The model architecture includes convolutional, separable convolutional, batch normalization, max pooling, dropout, and dense layers. It is trained on a dataset of brain MRI images representing different stages of Alzheimer's disease. | ||
|
||
|
||
## Features of the Web App 🌐 | ||
- **Sample Image Display**: Displays a sample brain scan image for reference. | ||
- **Upload MRI Scan**: Allows users to upload their MRI scan images for Alzheimer's detection. | ||
- **Prediction Display**: Provides predictions for Alzheimer's disease based on the uploaded MRI scan images. | ||
- **About Alzheimer's Disease**: Offers information about Alzheimer's disease, including its causes, symptoms, and stages. | ||
|
||
## Video Demo📽️ | ||
![alt text](thumbnaill.png) | ||
<video controls src="demo.mp4" title="Title"></video> | ||
[Watch Video Demo](https://github.com/aindree-2005/DL-Simplified/blob/09981913e1373a30b62b5acd3ce79301f5900041/Alzheimers%20Detection/Web-App/demo.mp4) | ||
## Signature ✒️ | ||
Aindree |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.