DEV Community

Buono
Buono

Posted on

Exploring the World of Medical Imaging: Building an App to Identify Brain Tumors from MRI Scans

Important Notes

This project is a personal application created for learning machine learning. Please note that the content has not been thoroughly validated, so refrain from using it in actual business or medical practices.

1. Introduction

I have recently been fascinated by the field of machine learning and data science, constantly pondering on how to apply it to hack industries and businesses. To start with a common theme, I decided to create an app that uses machine learning to diagnose medical images, specifically detecting tumors in brain MRI images.

4_no.jpg

The app I created can be found here, and the code is available on GitHub.

2. Development Environment

  • MacBook Pro M1 Max
  • macOS 13.2.1
  • Google Colaboratory (GPU Tesla T4, 525.105.17, 15360 MiB)
  • Python (Ver 3.11.3)

3. Used Libraries

  • TensorFlow: Version 2.12.0
    A machine learning library developed by Google.

  • OpenCV: Version 4.8.0
    Open Source Computer Vision Library used for image processing and analysis.

  • Numpy: Version 1.23.5
    A library for numerical computations in Python.

  • Flask: Version 2.0.1
    A library for creating web applications in Python. You can specify the deployment version in the Requirements.txt file.

4. Preparation of Training Data

The brain MRI image dataset used for training was obtained from Kaggle:
"Brain MRI Images for Brain Tumor Detection"

Download the zip file, extract it, and save it in the same directory as your working files.

5. Building the Training Model

Next, create the model on Google Colaboratory. The key steps involve mounting Google Drive, importing relevant libraries, setting file paths, and preparing the data for training.

Data Processing

Resize and rearrange the images for ease of machine learning.

Model Construction

Use transfer learning with the VGG16 model for feature extraction. The model is fine-tuned for tumor detection using brain MRI images.

Model Compilation

Compile the model by setting parameters for loss function, optimization algorithm, and metrics.

6. Model Training and Evaluation

Train the model using the prepared data and evaluate its performance. Save the trained model for later use.

7. Verification

Check if the model correctly predicts the presence or absence of tumors in images.

8. Deployment on Render

Deploy the created model in a web application using Render. The structure of the project includes code files, model file, stylesheets, HTML templates, and an upload directory.

9. Conclusion

Reflection

Despite the limited size of the brain MRI image dataset on Kaggle, achieving around 80% accuracy is a promising result. Continuous improvement could be explored by increasing the dataset size and trying different hyperparameters.

Future Outlook

Future improvements may involve data augmentation techniques and exploring different models, loss functions, and optimization algorithms for potentially higher accuracy.

Personal Impression

This project, aimed at exploring how machine learning can be applied to industries, delivered a prototype with satisfactory accuracy. The potential of machine learning remains high, and it is expected to continue making significant impacts in the future.

However, challenges in achieving higher accuracy, the importance of human oversight, and the coexistence of human and machine capabilities have become evident. For applications involving human lives, the role of human judgment remains crucial.

Please note that this project is a personal app created for learning machine learning and has not undergone thorough validation. Exercise caution when considering its use in real-world scenarios.

The primary goal of exploring the application of machine learning to industries has been achieved through this project.

Feel free to explore the code on GitHub if you are interested.

This concludes the verification for this project.

Top comments (0)