Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

46 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Deep Learning for Malaria Parasite Detection

Python Badge PyTorch Badge FastAPI Badge OpenCV Badge React Badge EfficientNet Badge XAI Badge

This deep learning model is designed to automate the identification of Malaria parasites in thin blood smear slides. Leveraging EfficientNet-B0 and Explainable AI (Grad-CAM), the system achieves state-of-the-art accuracy while providing clinicians with visual evidence for every diagnostic decision.

๐ŸŒ Live Demo: https://deep-learning-malaria-detection.vercel.app

๐ŸŒ ML Model API: https://deep-learning-malaria-detection.onrender.com

Live Preview & Explainability

Image

The Problem

  • Diagnostic Bottlenecks: Manual microscopy is time-intensive and requires highly trained pathologists who are scarce in endemic regions.
  • Human Error: Fatigue and low parasite density often lead to false negatives (missed diagnoses).
  • Lack of Trust: "Black box" AI models give answers without reasons, making doctors hesitant to adopt them.
  • Global Health Gap: Over 200 million malaria cases occur annually, requiring scalable, automated screening tools.

This platform addresses these challenges by providing a 97%+ accurate screening tool that not only flags infected cells but generates attention maps to pinpoint exactly where the parasite is located.


Core Features

1. AI-Powered Parasite Detection

  • High-Precision Classification: Distinguishes between "Parasitized" and "Uninfected" cells with 97.32% accuracy.
  • Confidence Scoring: Assigns a probability score (e.g., 98.4%) to help clinicians prioritize ambiguous cases.
  • Real-Time Inference: Process slide images in under 50ms using optimized PyTorch backbones.

2. Explainable AI (XAI)

  • Grad-CAM Visuals: Generates heatmaps highlighting the specific regions (trophozoites/schizonts) triggering the diagnosis.
  • Trust Verification: Ensures the model focuses on the parasite and not on staining artifacts or noise.
Image

AI Model Performance & Architecture

Model Performance Metrics for best model: EFFICIENTNET

  • Accuracy: 97.32% - State-of-the-art performance on NIH Dataset
  • Precision: 97.34% - Minimizes false positives
  • F1-Score: 97.32% - Perfect balance between precision and recall
  • ROC-AUC: 0.9948 - Exceptional discriminative ability
Image

Model Architecture Details

  • Base Model: EfficientNet-B0 (Transfer Learning from ImageNet)
  • Custom Head: Dropout(0.5) -> Linear(512) -> ReLU -> Linear(2)
  • Training Strategy: Adam Optimizer with ReduceLROnPlateau Scheduler
  • Data Augmentation: Random Rotations, Flips, and Color Jittering
  • Loss Function: CrossEntropyLoss

Technical Specifications

  • Input Resolution: 224x224 pixels (Resized from NIH standard)
  • Output Classes: 2 (Parasitized, Uninfected)
  • Inference Time: ~15ms on GPU / ~120ms on CPU
  • Model Size: 4.6M Parameters (Lightweight compared to ResNet-50's 25M)

Performance Validation

  • Test Dataset: 2,755 unseen images (10% split)
  • Cross-Validation: Validated against VGG16 (94.89%) and ResNet-50 (95.83%)
  • Early Stopping: Training halted at Epoch 18 to prevent overfitting
  • Robustness: Tested on varied cell staining intensities

Tech Stack

ComponentTechnologies Used
Frontend InterfaceReact.js, Bootstrap, JavaScript, Plotly.js
Backend APIPython, FastAPI, Uvicorn, Pydantic
Deep LearningPyTorch, Torchvision, EfficientNet, Transfer Learning
ExplainabilityGrad-CAM, Captum, Matplotlib, Seaborn
Image ProcessingOpenCV, PIL (Pillow), NumPy, Albumentations
DeploymentDocker, Render (Backend), Vercel (Frontend)
Version ControlGit, GitHub

Project Structure

Repository Organization

  • ml-model/ - Jupyter notebooks for training, evaluation, and XAI generation
  • backend-api/ - FastAPI server implementation and route logic
  • frontend-dashboard/ - React interface for slide upload and visualization

Key Components

  • training.ipynb: Complete research pipeline from data loading to Grad-CAM export
  • main.py: FastAPI entry point handling prediction requests
  • gradcam.py: Utility module for generating attention heatmaps
  • model_utils.py: Helper functions for image preprocessing and tensor conversion

Getting Started Locally

Prerequisites

  • Node.js (v16+)
  • Python 3.8+
  • PyTorch 2.0+
  • FastAPI & Uvicorn
  • Git

Backend API Setup

  1. Navigate to backend directory:
    cd backend-api
    pip install -r requirements.txt
  2. Start the FastAPI server:
    uvicorn main:app --reload
  3. API will be available at http://localhost:8000

Frontend Dashboard Setup

  1. Navigate to frontend directory:
    cd frontend-dashboard
    npm install
  2. Start the development server:
    npm start
  3. Open http://localhost:3000 in your browser

API Endpoints

Health & Status

  • GET /health - System status check and model readiness

Inference & Explainability

  • POST /api/v1/predict - Submit an image and get label + confidence score
  • POST /api/v1/predict-cam - Get prediction + Base64 Grad-CAM heatmap string

Future Enhancements

  • Edge Deployment: Quantize model to TFLite for offline use on mobile phones in rural clinics.
  • Species Identification: Expand dataset to classify P. falciparum vs. P. vivax.
  • Adversarial Defense: Train on noisy/blurred images to simulate poor microscope quality.
  • Federated Learning: Enable multi-hospital training without sharing patient data.
  • Report Generation: Auto-generate PDF diagnostic reports for patient records.

Contributing

We welcome contributions to this project. Please feel free to submit issues, feature requests, or pull requests to help improve the diagnostic accuracy or platform usability.

About

Deep learning model for malaria parasite detection from blood smear images using CNNs with confidence scoring for clinical support

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages