Classifying Brain Tumor Using CNN
Abstract
In recent times, we have been seeing a massive rise in brain stroke cases all over the world. Stroke is one of the leading causes of death worldwide these days. About 1/5th of patients with an acute stroke die within a month of the event and at least 1/2 of those who survive are left with a physical disability. So, we have developed a classifying brain tumor model to predict whether a person is affected by a brain stroke or not. so, on top of this, we have also created a Front-End framework with Tkinter GUI where we can input the image and the model will try to predict the output and display it on the window.
Code Description & Execution
Algorithm Description
So, we have used Convolutional Neural Networks to identify whether a person has a brain tumor or not, as we all know, how sophisticated CNNs are and how they can learn almost anything as the brain does, this can help us save a lot of time and also give almost accurate classifying brain tumor predictions for the disease. As we discussed convolutional neural networks are very sophisticated and more advanced versions of neural networks, these are very superior to other neural networks which work better with images and audio/speech input signals. A CNN network comprises 3 important layers such as a convolutional layer, a pooling layer, and a fully connected layer. we can have as many layers as possible depending on the domain and project we are working on.
Reference: https://www.ibm.com/cloud/learn/convolutional-neural-networks
How to Execute?
So, before execution we have some pre-requisites that we need to download or install i.e., anaconda environment, python and a code editor.
Anaconda: Anaconda is like a package of libraries and offers a great deal of information which allows a data engineer to create multiple environments and install required libraries easy and neat.
Refer to this link, if you are just starting and want to know how to install anaconda.
If you already have anaconda and want to check on how to create anaconda environment, refer to this article set up jupyter notebook. You can skip the article if you have knowledge of installing anaconda, setting up environment and installing requirements.txt
Steps to execute given code :
.py Execution
1. Install the prerequisites mentioned above.
2. open the anaconda prompt and create a new environment.
- conda create -n “env_name”
- conda activate “env_name”
3. Install necessary libraries from the requirements.txt file provided.
4. Run pip install -r requirements.txt or conda install requirements.txt
(Requirements.txt is a text file consisting of all the necessary libraries required for executing this python file. If it gives any error while installing libraries, you might need to install them individually.)
5. Run main.py in the anaconda terminal after all the above steps.
.ipynb Execution
1. Open the anaconda prompt (type anaconda prompt in the search bar)
2. type cd “path where you have saved your executable files”, eg: cd C:/Datasets/projec1
3. Type “jupyter notebook” and press enter
4. It will redirect to the web page where you have to select the file which you have to select the file you have to execute.
5. click on it and run the code cells one by one by pressing shift+enter.
6. In this case the file to run is main.ipynb to see how the process flow works and main_gui.ipynb to run the final file.
(Requirements.txt is a text file consisting of all the necessary libraries required for executing this python file. If it gives any error while installing libraries, you might need to install them individually.)
Data Description
The classifying brain tumor model is trained on MRI scanned brain
tumor images collected from kaggle data repository, Before training the model,
the images have gone through some preprocessing, such as Data augmentation and
Images have being resized to fit to the model.
Final Results
Issues you may face while executing the code
1. Install each library if you face any issue installing them through requirements.txt
2. Adding path to environment variables in order to run python files and to use anaconda environment in code editor, specifically in visual studio code.
Evaluation metrics
Evaluation metrics are considered one of the most important steps in any machine learning and deep learning project, where it will allow us to evaluate how good our model is performing on the new data or on unseen data. There are a lot of evaluation metrics such as confusion matrix, roc_auc curve, f1_score, recall, and precision, and each of which works for the specific problem we deal with. So, for our project, we have gone with confusion matrix the OG of every evaluation matric were using it, we have calculated the accuracy and another metric, which has given a conclusion that the model is performing very well on new data.