Skip to content

Commit

Permalink
Merge pull request #561 from aindree-2005/web
Browse files Browse the repository at this point in the history
Web Application for Alzheimers Detection
  • Loading branch information
abhisheks008 authored May 16, 2024
2 parents a03d381 + a95a569 commit 498195f
Show file tree
Hide file tree
Showing 10 changed files with 90 additions and 0 deletions.
Binary file added Alzheimers Detection/Images/image.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Alzheimers Detection/Model/model.h5
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.
69 changes: 69 additions & 0 deletions Alzheimers Detection/Web-App/app.py
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 added Alzheimers Detection/Web-App/demo-1.mp4
Binary file not shown.
Binary file added Alzheimers Detection/Web-App/demo.mp4
Binary file not shown.
Binary file added Alzheimers Detection/Web-App/model.h5
Binary file not shown.
21 changes: 21 additions & 0 deletions Alzheimers Detection/Web-App/readme.md
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
Binary file added Alzheimers Detection/Web-App/thumbnail.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Alzheimers Detection/Web-App/thumbnaill.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 498195f

Please sign in to comment.