top of page
ProjectOverview

Project Overview

Project Type:
Role
Project Outcome
Methods
Deliverables
Tools

Malaria Detection using deep learning techniques.

Data Scientist / Machine Learning Engineer

1. Developed a malaria detection system using deep learning techniques to classify red blood cells (RBCs) as parasitized or uninfected.

2. Built an initial CNN model and iteratively improved it by adding layers, applying batch normalization, using data augmentation, and leveraging transfer learning with VGG16 for enhanced performance.

3. Achieved high accuracy in classifying malaria-infected cells, providing a scalable solution for assisting healthcare professionals with faster and more accurate diagnoses.

1. Data preprocessing and augmentation to ensure a robust and generalizable model.

2. Development and refinement of a CNN, followed by hyperparameter tuning and incremental improvements, culminating in the use of VGG16 for transfer learning.

3. Performance evaluation using accuracy, precision, recall, and F1-score.

1. A high-performing malaria detection model capable of accurately classifying parasitized and uninfected cells.

2. A detailed performance report showcasing the iterative improvements in model performance.

3. Recommendations for future improvements, including expanding the dataset and refining the model for even higher generalization across diverse populations.

Python, Pandas,Matplotlib, numpy, Keras, OpenCV, TensorFlow, Scikit-learn, Google Colab.

Context

Malaria Detection:

This project aims to address these limitations in diagnosing malaria by creating an automated malaria detection system using deep learning models, including CNN and VGG16, to detect parasitized RBCs from blood smear images. An automated system can help healthcare providers make faster and more accurate diagnoses, ultimately improving patient outcomes. Additionally, by leveraging transfer learning with VGG16, the project aims to further enhance the accuracy of detection without requiring large amounts of labeled data.

Objective

  • Develop and refine a deep learning model capable of detecting malaria-infected cells from blood smear images.

  • By iteratively improving a base CNN model through techniques such as adding layers, applying batch normalization, and utilizing data augmentation, the model will be fine-tuned for optimal performance.

  • Leverage transfer learning with VGG16 to enhance feature extraction and achieve even higher classification accuracy, ensuring that the model generalizes well across different populations.

 Key Research Questions

  • How effective are the CNN, VGG16, ResNet v2, and EfficientNet models in detecting and classifying facial emotions?

  • Which performance metrics (e.g., accuracy, precision, recall, F1-score) provide the most reliable evaluation of the system’s effectiveness in real-time emotion detection?

  • How can the model be optimized to detect subtle emotions and perform well under challenging conditions such as low lighting, occlusions, and varying facial angles?

PHASES OF PROJECT

This Malaria Detection System project progressed through six phases: Data Discovery, Data Preparation, Model Planning, Model Building, Communicating Results, and Operationalizing the system for real-world use. Each phase was crucial in developing and optimizing the recommendation model.

Data Discovery

Data Discovery

Goal:

Identify and gather relevant data to build the music recommendation system.

Data Preparation

Data Preparation

Goal:

Clean and prepare the data for further analysis.

Model Planning

Model Planning

Goal:

Decide on the most appropriate algorithm to build the recommendation system.

Model Building

Model Building

Goal:

Develop and train the recommendation model.

Communicating Results

Communicating Results

Goal:

Present the model’s performance and insights to stakeholders.

Operationalize

Operationalize

Goal:

Deploy the model in a real-world environment and monitor its performance.

view notebook

Data Discovery

Class Distribution in Training Set

Phase-1

1 / Datasets:
  • The dataset used for this project consists of colored images of red blood cells, which are categorized into two classes: parasitized (infected) and uninfected (healthy).

2 / Initial Data exploration
  • Each image was analyzed to understand the visual differences between parasitized and uninfected cells. Key features, such as the presence of parasites in infected cells, were noted.

  • An important part of data discovery was identifying the distribution of the images between the two classes, ensuring that there was no severe class imbalance.

Phase1

Key Insights

  • The dataset featured clear visual distinctions between infected and uninfected cells, making it suitable for image classification using deep learning techniques.

  • The barplots in both ways show that for both categories the counts are roughly equal. Therefore, the data is balanced.

  • Gaussian blurring was identified as a necessary preprocessing step to reduce noise and smooth out irrelevant features in the images, enhancing the model’s ability to focus on important details like the presence of the parasite.

Challenges

  • Some uninfected images contained impurities or other noise, which could potentially confuse the model. This was mitigated through the use of Gaussian blurring to enhance important features and reduce unnecessary noise.

view notebook

Data Preparation

Converting RGB to HSV of Images using OpenCV
variety of cell shapes and intances of infection.

Phase-2

1 / Image Resizing:
  • Images from the dataset were resized to a fixed dimension of 64x64 pixels. This ensured that all input images were of uniform size, reducing the computational complexity and memory usage during training.

2 / Normalizing
  • The pixel values were normalized to a scale of 0 to 1. Normalization is critical to ensure that the model converges faster during training and improves its performance by standardizing the inputs across a common range.

3 / RGB to HSV Conversion:
  • The images were converted from RGB to HSV color space using OpenCV. This conversion separated the color components from lighting intensity, helping the model focus on the hue variations, which are critical for identifying parasitized cells

4 / Gaussian Blurring
  • Applied Gaussian blurring as part of the preprocessing pipeline to smooth the images and reduce noise. This step helped the model focus on critical features related to parasitized cells by eliminating minor variations or noise that could otherwise interfere with classification.

Phase2

Key Insights

  • The RGB to HSV conversion improved the model’s ability to capture important color-related features while minimizing the effects of lighting variations.

  • Gaussian blurring, along with the HSV conversion, ensured that the model focused on relevant image features without being distracted by noise or unnecessary details.

Challenges

  • Blurring helps with removing noise and hence can benefit overfitting issue later on. The models should not be fitting the noise as well as the features, so the less high frequency noise we have the better. On the other hand, it dilutes the distinguishing feature of paraticized cells, viz. the colored blobs inside the cell body.

Phase-3

1 / Process:
  • Initially, a base Convolutional Neural Network (CNN) architecture was planned and built for the task of malaria detection. CNN was chosen due to its effectiveness in capturing spatial hierarchies in image data.

  • The plan also included iterative improvements to the base model to enhance performance, with key strategies involving adding layers, batch normalization, data augmentation, and eventually testing a pre-trained VGG16 model.

  • The intention behind using VGG16 was to leverage transfer learning to utilize pre-trained weights from large-scale datasets like ImageNet, which could help improve feature extraction.

view notebook

Model Planning

Phase3

Key Insights

  • CNN was the most logical starting point for handling the malaria detection task, given its strengths in image classification.

  • After building the base model, various enhancements were planned in an iterative approach:

  1.   Adding More Layers: Initially, the architecture was expanded by adding additional convolutional layers to allow the model to capture more complex patterns in the image data.

  2. Batch Normalization: Batch normalization layers were planned to stabilize and speed up the training process while improving generalization.

  3. Data Augmentation: Augmentation techniques were incorporated to artificially increase the dataset size and improve the model's ability to generalize.

  • Pre-trained VGG16: Finally, transfer learning with the VGG16 model was considered to further boost performance by utilizing a model trained on a large, diverse dataset.

view notebook

Model Building

Confusion Matrix & Train and Validation curve graphs of all the models.

5 / ​Pre-trained VGG16 Model:

Transfer learning was applied using a pre-trained VGG16 model. The earlier layers of VGG16 were frozen to retain pre-learned features from the ImageNet dataset, and the top layers were replaced and fine-tuned for the malaria classification task. This allowed the model to benefit from the rich feature extraction capabilities of VGG16 while being adapted for this specific use case.

4 / ​Data Augmentation:

Data augmentation techniques were then applied during training to artificially increase the variability in the dataset, enhancing the model’s ability to generalize to unseen data. Augmentations included random rotations, flips, and zooms.

Phase-4

1 / Base CNN Model:

A Three 32 filter layers, kernel size 2, ReLU activation, Max Pooling, and Dropout layers after each convolutional layer. The final layer is a fully connected dense 512 units layer with ReLU activation and a higher dropout that is fed to the dense classifier layer with 2 outputs and a softmax activation function.

2 / Adding Layers:

After observing the performance of the base CNN, the model was modified by adding additional convolutional layers(5 instead of 3). The deeper architecture aimed to improve classification accuracy by extracting finer details from the input images.

3 / ​Batch Normalization

The next improvement came from incorporating batch normalization after each convolutional layer. This helped in normalizing the inputs to each layer, leading to faster convergence, improved stability, and reduced overfitting.

Phase4

Key Insights

  • For Batch Normalization, training Accuracy is close to 1, whereas Validation accuracy is around .98, which is a very nice result. Batch Normalization has indeed helped. Secondly, unlike previous models, Validation accuracy is lower than training accuracy, as it normally should be.

  • For Data AugmentationI I checked with every option in ImageDataGenerator like shearing, shifts, flips, etc. I did not see a significant improvement. In fact, most of the time the results were worse.

  • After applying Pre-trained VGG16 we are back to validation accuracy being higher than training accuracy. This could be due to not having enough data augmentation. It is possible that if more variations in the data are incorporated, both accuracies maybe closer. It could also be that more fine tuning is required in the final layers. I also read that VGG16 is trained on images normalized by subtracting the mean. Our images are normalized differently and maybe they need to be normalized the same way.

Challenges

  • Balancing between adding more layers and preventing overfitting was critical, particularly when the dataset was augmented but still relatively small.

  • Fine-tuning the VGG16 model required careful adjustment to the learning rate and batch size to ensure that it adapted well to the malaria dataset without losing the benefits of its pre-trained weights.

Phase-5

1 / Process:
  • ​The model’s performance was evaluated using key metrics, including accuracy, precision, recall, and F1-score. These metrics provided insights into how well the model classified parasitized cells without introducing too many false positives or negatives.

  • A confusion matrix was generated to visualize the model’s performance across both classes, showing where the model made correct and incorrect classifications.

  • Based on both the accuracy numbers and the Confusion Matrix, the second model with five layers and batch normalization was the best. The third model with data augmentation is also close second. The accuracy numbers are very good but confusion matrix shows a bit higher instances of parasitized cases classified as uninfected.

view notebook

Communicating Results

Phase5

Key Insights

  • The second model not only had excellent training and validation accuracy, but it also had equally good Test Accuracy. Moreover, from Confusion Matrix, it had the least number of False negatives, meaning it had the lowest number of cases where a parasitized cell was identified as uninfected. This is highly desirable to prevent fatalities and the spread of infection.

Challenges

  • ​ We can try ResNet50 architecture as a pre-trained model. We can also employ image pre-processing steps like contrast  enhancement, histogram equalization, single channel processing etc.

 

  • Effectively communicating the model's limitations, such as handling noisy or impure uninfected cell images, was essential for setting realistic expectations for real-world deployment.​

Phase-6

1 / Process:
  • Optimization for deployment included reducing the model’s size and improving its inference speed, ensuring that it could be used efficiently in low-resource environments.

  • ​I plan to exeriment with not just HSV but also the LAB colormap images. They are particularly suitable for CLAHE and other contrast enhancing techniques.

view notebook

Operationalization

Phase6

Key Insights

  • It is indeed possible to automate the pocess of identifying infected cells in a relatively short time. It doesn't take too long to run on my machine.

Challenges

  • Ensuring the model can be deployed in real-time scenarios without sacrificing accuracy, especially in regions where computational resources may be limited.

Reflection

This project gave me valuable insights into building and refining deep learning models. I started with a CNN that had three convolutional layers, Max Pooling, and Dropout, which taught me how to balance model complexity while preventing overfitting. The fully connected 512-unit dense layer helped capture more intricate patterns, improving accuracy. I also experimented with data augmentation and integrated VGG16 transfer learning, which showed me how leveraging pre-trained models can enhance feature extraction. Overall, it was a hands-on experience in optimizing different model architectures to achieve better performance in image classification tasks.

Like what you see ? 

Let's chat!

© 2024 by Alvita Yathati. Powered and secured by Wix

bottom of page