Skip to content

Commit 9c649fb

Browse files
committed
some proper documentation organisation
1 parent 903956d commit 9c649fb

File tree

19 files changed

+887
-647
lines changed

19 files changed

+887
-647
lines changed

01 Start/linear regression demo.ipynb

-255
This file was deleted.

01 Start/resources/a.png

-147 KB
Binary file not shown.
+123-12
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,126 @@
1-
# how to run this app.
2-
- clone the repo
3-
- move to folder BRAIN TUMOR DETECTION,
4-
- create a virtual env using `virtualenv 'envirnoment name'.`
5-
- Now type `. \Scripts\activate` to activate your virtualenv venv
6-
- install packages required by the app by running the command `pip install -r requirments.txt` if you found error of torch or torch-vision libraries so your can download it from below commands.
7-
<b><i>for windows cpu torch library command with conda</i></b>: conda install pytorch torchvision cpuonly -c pytorch
8-
<b><i>for windows cpu torch library command with pip</i></b>: pip install torch==1.6.0+cpu torchvision==0.7.0+cpu -f https://download.pytorch.org/whl/torch_stable.html
1+
# Brain Tumor Detection (End-to-End)
92

10-
For Linux, Mac,CUDA version for windows and much more you can visit <a href = "https://pytorch.org/">Link</a>
11-
- now run the app using `flask run`.
12-
- if all things works fine so you can view running web application in your browser at port 5000.
3+
## Introduction
134

5+
This project is a **Flask web application** for detecting brain tumors from MRI images using a deep learning model built with **PyTorch**. Users can upload MRI images through the app, and the model will classify them as either tumor or non-tumor. The goal of this project is to provide an intuitive interface for medical professionals to quickly identify potential brain tumors.
146

15-
# Download the model file from [https://drive.google.com/file/d/1LJG_ITCWWtriLC5NPrWxIDwekWbhU_Rj/view?usp=sharing](https://drive.google.com/file/d/1LJG_ITCWWtriLC5NPrWxIDwekWbhU_Rj/view?usp=sharing) and add to model directory in order to run the project.
7+
### Dataset:
8+
- The dataset contains MRI images, divided into two categories: **tumor** and **non-tumor**.
9+
- Preprocessing techniques are applied to the dataset to ensure optimal model performance.
10+
11+
## Project Overview
12+
13+
This end-to-end project consists of:
14+
1. **Data Loading**: Load MRI images for training, validation, and testing.
15+
2. **Data Preprocessing**: Apply normalization, resizing, and augmentation techniques.
16+
3. **Model Building**: Build a Convolutional Neural Network (CNN) using **PyTorch** to classify the MRI images.
17+
4. **Model Training**: Train the model on GPU (if available) to detect brain tumors.
18+
5. **Flask Web Application**: Develop a Flask app for user interaction, allowing image uploads for tumor detection.
19+
6. **Model Deployment**: Deploy the trained model within the Flask app.
20+
7. **Prediction**: Provide real-time predictions through the Flask web app.
21+
22+
## Model Download and Directory Structure
23+
24+
### Pretrained Model:
25+
You can download the pretrained model from the following link:
26+
[Brain Tumor Detection Model](https://drive.google.com/file/d/1LJG_ITCWWtriLC5NPrWxIDwekWbhU_Rj/view?usp=sharing)
27+
28+
### Directory Structure:
29+
```
30+
Brain-Tumor-Detection/
31+
32+
├── app/
33+
│ ├── static/ # CSS, JS, and images for the Flask web app
34+
│ ├── templates/ # HTML templates for the Flask app
35+
│ └── app.py # Main Flask application
36+
37+
├── model/
38+
│ └── brain_tumor_model.pth # Pretrained PyTorch model
39+
40+
├── data/
41+
│ ├── train/ # Training MRI images
42+
│ ├── test/ # Testing MRI images
43+
44+
├── src/
45+
│ ├── dataset.py # Script to load and preprocess the dataset
46+
│ ├── model.py # CNN model architecture using PyTorch
47+
│ └── train.py # Script to train the model
48+
49+
├── README.md # Project documentation
50+
└── requirements.txt # List of required Python packages
51+
```
52+
53+
## Setup Instructions
54+
55+
### Step 1: Create a Virtual Environment
56+
57+
Create a virtual environment to isolate the dependencies for this project.
58+
59+
```bash
60+
# For Windows
61+
python -m venv venv
62+
venv\Scripts\activate
63+
64+
# For macOS/Linux
65+
python3 -m venv venv
66+
source venv/bin/activate
67+
```
68+
69+
### Step 2: Install Required Libraries
70+
71+
Install the dependencies listed in `requirements.txt`:
72+
73+
```bash
74+
pip install -r requirements.txt
75+
```
76+
77+
### Step 3: Download the Pretrained Model
78+
79+
Download the pretrained model from [this link](https://drive.google.com/file/d/1LJG_ITCWWtriLC5NPrWxIDwekWbhU_Rj/view?usp=sharing) and place it in the `model/` directory as `brain_tumor_model.pth`.
80+
81+
### Step 4: Running the Flask App
82+
83+
To start the Flask web app, navigate to the `app/` directory and run the `app.py` file:
84+
85+
```bash
86+
cd app/
87+
python app.py
88+
```
89+
90+
The app will be hosted at `http://127.0.0.1:5000/`. You can open the URL in your browser and upload MRI images to receive predictions.
91+
92+
## Flask Web Application Features
93+
94+
- **Image Upload**: Users can upload MRI images through the web interface.
95+
- **Tumor Detection**: The uploaded image is fed into the model to predict whether a tumor is present.
96+
- **Result Display**: The result is displayed on the same page with either a "Tumor" or "Non-Tumor" label.
97+
98+
## Model Architecture
99+
100+
The model used in this project is a **Convolutional Neural Network (CNN)** built using **PyTorch**. The architecture has been optimized for image classification tasks and consists of several layers:
101+
102+
### Key Layers:
103+
- **Convolutional Layers**: For feature extraction from MRI images.
104+
- **Max Pooling Layers**: For downsampling and reducing spatial dimensions.
105+
- **Fully Connected Layers**: For classification.
106+
- **Softmax Activation**: To produce the output probability of each class (Tumor/Non-Tumor).
107+
108+
## Data Preprocessing
109+
110+
To ensure the CNN model performs optimally, the following preprocessing steps are applied:
111+
- **Grayscale Conversion**: All MRI images are converted to grayscale.
112+
- **Resizing**: Images are resized to 64x64 pixels for uniformity.
113+
- **Normalization**: Each pixel value is normalized to a range of [0, 1].
114+
- **Data Augmentation**: Techniques like random rotation, flipping, and zooming are applied to expand the dataset and prevent overfitting.
115+
116+
## Conclusion
117+
118+
This Flask web app provides an end-to-end solution for detecting brain tumors using MRI images. With a simple user interface and a powerful backend, it can serve as a diagnostic tool for medical professionals. The project can be further enhanced by incorporating additional data, improving model accuracy, or deploying the app to a cloud platform like Heroku.
119+
120+
## Future Enhancements
121+
122+
- **Integration with Cloud Platforms**: Deploy the app on Heroku or AWS for wider accessibility.
123+
- **Mobile Application**: Develop a mobile app to upload MRI images and get predictions on the go.
124+
- **Transfer Learning**: Incorporate pre-trained models like ResNet to further improve accuracy.
125+
126+
---
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,70 @@
11
# Project-Arrhythmia
22

3+
## Introduction
34

5+
This project focuses on predicting and classifying arrhythmias using various machine learning algorithms. The dataset used for this project is from the [UCI Machine Learning Repository](https://archive.ics.uci.edu/ml/datasets/Arrhythmia), which consists of 452 examples across 16 different classes. Among these, 245 examples are labeled as "normal," while the remaining represent 12 different types of arrhythmias, including "coronary artery disease" and "right bundle branch block."
46

5-
### Introduction
7+
### Dataset Overview:
8+
- **Number of Examples**: 452
9+
- **Number of Features**: 279 (including age, sex, weight, height, and various medical parameters)
10+
- **Classes**: 16 total (12 arrhythmia types + 1 normal group)
611

7-
The Dataset used in this project is available on the UCI machine learning Repository.
8-
It can be found at: [https://archive.ics.uci.edu/ml/datasets/Arrhythmia](https://archive.ics.uci.edu/ml/datasets/Arrhythmia).
9-
* It consists of 452 different examples spread over 16 classes. Of the 452 examples,245 are of "normal" people.
10-
* We also have 12 different types of arrhythmias. Among all these types of arrhythmias, the most representative are the "coronary artery disease" and "Rjgbt boundle branch block".
11-
* We have 279 features, which include age, sex, weight, height of patients and other related information.
12-
* We explicitly observe that the number of features is relatively high compared to the number of examples we are available.
13-
* Our goal was to predict if a person is suffering from arrhythmia or not, and if yes, classify it in to one of 12 available groups.
12+
**Objective**:
13+
The goal of this project is to predict whether a person is suffering from arrhythmia, and if so, classify the type of arrhythmia into one of the 12 available groups.
1414

15+
## Algorithms Used
1516

17+
To address the classification task, the following machine learning algorithms were employed:
1618

19+
1. **K-Nearest Neighbors (KNN) Classifier**
20+
2. **Logistic Regression**
21+
3. **Decision Tree Classifier**
22+
4. **Linear Support Vector Classifier (SVC)**
23+
5. **Kernelized Support Vector Classifier (SVC)**
24+
6. **Random Forest Classifier**
25+
7. **Principal Component Analysis (PCA)** (for dimensionality reduction)
1726

18-
### Algorithms Used
19-
1. KNN Classifier
20-
2. Logestic Regression
21-
3. Decision Tree Classifier
22-
4. Linear SVC
23-
5. Kernelized SVC
24-
6. Random Forest Classifier
25-
7. Principal Component analysis (PCA)
27+
## Project Workflow
2628

27-
### Result
29+
### Step 1: Data Exploration
30+
- Analyzed the 279 features to identify patterns and correlations that could help with prediction.
31+
- Addressed the challenge of the high number of features compared to the limited number of examples by employing PCA.
2832

29-
![](https://raw.githubusercontent.com/shsarv/Project-Arrhythmia/master/Image/result.png)
30-
33+
### Step 2: Data Preprocessing
34+
- Handled missing values, standardized data, and prepared it for machine learning models.
35+
- Applied **Principal Component Analysis (PCA)** to reduce the feature space and eliminate collinearity, improving both execution time and model performance.
36+
37+
### Step 3: Model Training and Evaluation
38+
- Trained various machine learning algorithms on the dataset.
39+
- Evaluated model performance using accuracy, recall, and other relevant metrics.
40+
41+
### Step 4: Model Tuning with PCA
42+
- PCA helped reduce the complexity of the dataset, leading to improved model accuracy and reduced overfitting.
43+
- After applying PCA, models were retrained, and significant improvements were observed.
44+
45+
## Results
46+
47+
![Results](https://raw.githubusercontent.com/shsarv/Project-Arrhythmia/master/Image/result.png)
3148

3249
### Conclusion
3350

34-
The models started performing better after we applied PCA on the resampled data. The reason behind this is, PCA reduces the complexity of the data. It creates components based on giving importance to variables with large variance and also the components which it creates are non collinear in nature which means it takes care of collinearity in large data set. PCA also improves the overall execution time and quality of the models and it is very beneficial when we are working with huge amount of variables.
51+
Applying **Principal Component Analysis (PCA)** to the resampled data significantly improved the performance of the models. PCA works by creating non-collinear components that prioritize variables with high variance, thus reducing dimensionality and collinearity, which are key issues in large datasets. PCA not only enhanced the overall execution time but also improved the quality of predictions.
52+
53+
- The **best-performing model** in terms of recall score is the **Kernelized Support Vector Machine (SVM)** with PCA, achieving an accuracy of **80.21%**.
54+
55+
## Future Work
56+
57+
- Experiment with more advanced models like **XGBoost** or **Neural Networks**.
58+
- Perform hyperparameter tuning to further improve model accuracy and recall.
59+
- Explore feature selection techniques alongside PCA to refine the feature set.
60+
61+
62+
## Acknowledgments
3563

36-
**The Best model in term of recall score is Kernalized SVM with PCA having accuracy of 80.21%.**
64+
- [UCI Machine Learning Repository](https://archive.ics.uci.edu/ml/datasets/Arrhythmia)
65+
- [Scikit-learn Documentation](https://scikit-learn.org/stable/)
66+
- [PCA Concepts](https://towardsdatascience.com/pca-using-python-scikit-learn-e653f8989e60)
3767

68+
---
3869

70+
This `README.md` offers clear documentation of the objectives, algorithms used, results, and the significance of PCA in your project. It also provides essential information on how to run the project and the prerequisites.

Colorize Black & white images [OPEN CV]/README.md

+1-12
Original file line numberDiff line numberDiff line change
@@ -383,15 +383,4 @@ root.mainloop()
383383

384384
</div>
385385

386-
</div>
387-
388-
<div class="cell markdown" id="siqSAr_aOrf0">
389-
390-
## Summary:
391-
392-
This Notebook build a deep learning project to colorize black and white
393-
images. It first introduces us to Lab color space and why it is
394-
favorable for our problem statement. Then step by step it describes how
395-
to implement black and white image colorizer.
396-
397-
</div>
386+
</div>
Binary file not shown.

0 commit comments

Comments
 (0)