Inspiration

I built BreastNow Detector after seeing how doctors struggle with "black box" AI. My aunt had a false negative during screening, and I realized accuracy means nothing if doctors can't trust the AI. I wanted to build something that doesn't just predict cancer, but shows why it decided.

What I Learned

  1. Explainable AI: GradCAM taught me that model transparency is as important as accuracy. A 92% accurate model is useless if doctors can't verify it.
  2. Medical AI Challenges: Medical datasets are imbalanced and messy. I learned data preprocessing + augmentation is 70% of the work.
  3. PyTorch Deep Learning: Built CNNs with ResNet backbone, handled GPU/CPU training, and optimized inference for CPU-only laptops.

How I Built It

  1. Data: Loaded mammogram/ultrasound dataset and split 80/20 for train/test
  2. Model: Fine-tuned ResNet18 using PyTorch for binary classification: benign vs malignant
  3. Explainability: Integrated GradCAM to generate heatmaps that highlight tumor regions in red/yellow
  4. Interface: Built simple CLI tool detect.py - input image → output prediction + heatmap overlay
  5. Offline: Made it run 100% local so hospitals don't need internet or API keys

Challenges Faced

  1. Package Hell: ModuleNotFoundError: pytorch_grad_cam + cv2 timeouts. Fixed with correct pip names + --timeout 300 flag
  2. No GPU on Windows: Training was 8x slower on CPU. Used smaller batch sizes + pretrained weights to compensate
  3. File Paths: Windows backslash vs Linux forward slash broke image loading. Fixed with os.path.join() and raw strings r""
  4. Model Trust: Initial heatmaps focused on wrong areas. Fixed by tuning GradCAM target layers to last conv layer

Math Behind It

GradCAM uses gradients to find important regions: $L_{GradCAM}^c = ReLU\left(\sum_k \alpha_k^c A^k\right)$ Where $\alpha_k^c$ are gradient weights for class $c$ and $A^k$ are feature maps. This creates the heatmap overlay.

Built With

Share this project:

Updates