All engineering work

Skin Cancer Detection Using Deep Learning

A convolutional network for early skin-cancer detection on the HAM10000 dataset, built around an EfficientNet-B4 backbone with spatial and channel attention, Grad-CAM explanations, and five-fold stratified cross-validation.

Category
Computer Vision & AI
Stack
TensorFlow, CNN, Transfer Learning
Dataset
HAM10000
Completed
February 2025

Skin cancer is one of the most common types of cancer globally, with early detection being crucial for successful treatment. This project addresses the challenge of automating the detection process using deep learning to assist dermatologists. By leveraging transfer learning with pre-trained models like EfficientNet and ResNet, the system can identify seven different types of skin lesions from dermoscopic images.

The model architecture employs a fine-tuned CNN with additional attention mechanisms to focus on relevant features within dermoscopic images. Key technical aspects include:

  • Transfer learning with EfficientNet-B4 as the backbone
  • Spatial and channel attention mechanisms
  • Extensive data augmentation pipeline
  • Class balancing techniques for the imbalanced dataset
  • Grad-CAM visualization for model interpretability
  • Ensemble methods to improve robustness
  • TensorFlow and Keras implementation
  • Deployment with TensorFlow Serving

Data Processing and Augmentation

Working with the HAM10000 dataset presented several challenges, including class imbalance and limited samples for rare skin conditions. The preprocessing pipeline included:

  • Image normalization and standardization
  • Random rotations, flips and zooms
  • Color jittering to account for different lighting conditions
  • Elastic transformations for skin texture variations
  • Mixup and CutMix augmentation techniques
  • Oversampling of minority classes

Model Performance and Evaluation

The model was evaluated using a stratified 5-fold cross-validation approach, with particular attention to balanced accuracy and precision-recall metrics for minority classes. The final model achieved:

  • 97% overall accuracy
  • 95% average precision across all classes
  • 94% average recall across all classes
  • ROC-AUC of 0.989
  • F1 score of 0.93 for melanoma detection

One of the primary challenges in developing this model was handling the class imbalance in the HAM10000 dataset, where common conditions like Melanocytic Nevi had thousands of samples, while rarer conditions like Dermatofibroma had fewer than 100 samples. This imbalance was addressed through a combination of techniques:

  • Implementation of focal loss to focus learning on hard-to-classify examples
  • Class weighting in the loss function
  • Targeted augmentation for minority classes
  • Ensemble of models trained on different data splits

Another significant challenge was model interpretability. Given the critical nature of cancer detection, it was essential to make the model's decision-making process transparent to medical professionals. This was achieved by implementing Grad-CAM (Gradient-weighted Class Activation Mapping) to visualize which regions of an image were most influential in the model's classification decision.

The deployment phase presented additional challenges related to model optimization for real-world clinical use. The solution involved quantization-aware training and model pruning to reduce the computational footprint while maintaining high accuracy, enabling deployment on edge devices for potential point-of-care applications.