Fawazzx commited on
Commit
5fbe189
1 Parent(s): 0ad4fdc

Create README

Browse files
Files changed (1) hide show
  1. content/README +70 -0
content/README ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Fine-Tuning ResNet50 for Alzheimer's MRI Classification
2
+
3
+ This repository contains a Jupyter Notebook for fine-tuning a ResNet50 model to classify Alzheimer's disease stages from MRI images. The notebook uses PyTorch and the dataset is loaded from the Hugging Face Datasets library.
4
+
5
+ ## Table of Contents
6
+ - [Introduction](#introduction)
7
+ - [Dataset](#dataset)
8
+ - [Model Architecture](#model-architecture)
9
+ - [Setup](#setup)
10
+ - [Training](#training)
11
+ - [Evaluation](#evaluation)
12
+ - [Usage](#usage)
13
+ - [Results](#results)
14
+ - [Contributing](#contributing)
15
+ - [License](#license)
16
+
17
+ ## Introduction
18
+ This notebook fine-tunes a pre-trained ResNet50 model to classify MRI images into one of four stages of Alzheimer's disease:
19
+ - Mild Demented
20
+ - Moderate Demented
21
+ - Non-Demented
22
+ - Very Mild Demented
23
+
24
+ ## Dataset
25
+ The dataset used is [Falah/Alzheimer_MRI](https://huggingface.co/datasets/Falah/Alzheimer_MRI) from the Hugging Face Datasets library. It consists of MRI images categorized into the four stages of Alzheimer's disease.
26
+
27
+ ## Model Architecture
28
+ The model architecture is based on ResNet50. The final fully connected layer is modified to output predictions for 4 classes.
29
+
30
+ ## Setup
31
+ To run the notebook locally, follow these steps:
32
+
33
+ 1. Clone the repository:
34
+ ```bash
35
+ git clone https://github.com/your_username/alzheimer_mri_classification.git
36
+ cd alzheimer_mri_classification
37
+ ```
38
+ 2. Install the required dependencies:
39
+ ```bash
40
+ pip install -r requirements.txt
41
+ ```
42
+ 3. Open the notebook:
43
+ ```bash
44
+ jupyter notebook fine-tuning.ipynb
45
+ ```
46
+ ## Training
47
+ The notebook includes sections for:
48
+ - Loading and preprocessing the dataset
49
+ - Defining the model architecture
50
+ - Setting up the training loop with a learning rate scheduler and optimizer
51
+ - Training the model for a specified number of epochs
52
+ - Saving the trained model weights
53
+
54
+ ## Evaluation
55
+ The notebook includes a section for evaluating the trained model on the validation set. It calculates and prints the validation loss and accuracy.
56
+
57
+ ## Usage
58
+ Once trained, the model can be saved and used for inference on new MRI images. The trained model weights are saved as alzheimer_model_resnet50.pth.
59
+
60
+ ## Load the model architecture and weights
61
+ ```python
62
+ model = models.resnet50(weights=None)
63
+ model.fc = nn.Linear(model.fc.in_features, 4)
64
+ model.load_state_dict(torch.load("alzheimer_model_resnet50.pth", map_location=torch.device('cpu')))
65
+ model.eval()
66
+ ```
67
+ ## Results
68
+ The model achieved an accuracy of 95.9375% on the validation set.
69
+ ## Contributing
70
+ Contributions are welcome! If you have any suggestions, bug reports, or feature requests, please open an issue or submit a pull request.