GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - Mohd-Abdul-Rafay/swin-transformer-cancer-detection: Transformer-based medical image classification pipeline using a pretrained Swin Transformer (timm) for metastatic cancer detection on the PCam dataset, with controlled train/validation/test split and ROC–PR evaluation.

BranchesTags
Open more actions menu

Latest commit

 

History

31 Commits
31 Commits

Folders and files

NameName
Last commit message
Last commit date
notebooks
notebooks
 
 
results
results
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
requirements.txt
requirements.txt
 
 

Repository files navigation

Swin Transformer for Histopathologic Cancer Detection

Medical AI — Vision Transformers in Computational Pathology

This repository presents a transformer-based Medical AI pipeline for automated detection of metastatic cancer in histopathology image patches using the PCam (PatchCamelyon) dataset.

The project investigates the practical application of Vision Transformers in computational pathology, with emphasis on generalization robustness, calibration behavior, and clinically meaningful evaluation under class imbalance.

Key objectives:

  • Fine-tune a pretrained Swin Transformer for binary tumor classification
  • Establish a controlled 60/20/20 train–validation–test split
  • Evaluate performance using ROC-AUC, PR-AUC, sensitivity, specificity, and confusion matrix analysis
  • Analyze diagnostic trade-offs between false positives and false negatives in a medical setting

This work highlights how transformer architectures behave under limited-resolution medical patch constraints and real-world diagnostic performance requirements.


Problem Context

Histopathology cancer detection requires:

  • Robust classification under class imbalance
  • Sensitivity to metastatic patterns
  • Stability across tissue orientation and rotation
  • Reliable evaluation beyond simple accuracy

This project evaluates transformer-based modeling under these constraints.


Role & Contribution

This project was developed as part of a 5-member team.

I served as the primary model developer and was responsible for:

  • Designing and implementing the full Swin Transformer training pipeline
  • Building custom Dataset and DataLoader modules in PyTorch
  • Defining and enforcing the 60/20/20 train–validation–test split
  • Fine-tuning the pretrained swin_tiny_patch4_window7_224 model (timm)
  • Implementing augmentation strategies (rotations, affine transforms)
  • Developing evaluation pipeline (ROC-AUC, PR-AUC, confusion matrix, sensitivity/specificity)
  • Conducting model performance analysis and diagnostic interpretation

Team contributions included project coordination, feature engineering support, parallel model experimentation, and deployment assistance.


Dataset

This project uses the PatchCamelyon (PCam) dataset for binary classification of histopathology image patches (tumor vs. non-tumor tissue).

The dataset was originally released for the Kaggle Histopathologic Cancer Detection competition.

Source: https://www.kaggle.com/competitions/histopathologic-cancer-detection

The dataset is not redistributed in this repository and must be obtained directly from Kaggle.


Model Architecture

  • Backbone: Swin Transformer (swin_tiny_patch4_window7_224)
  • Source: timm pretrained weights
  • Adapted for binary classification
  • Fine-tuned end-to-end using PyTorch

Training Setup

  • Resolution: 32×32 center-cropped patches
  • Batch size: 32
  • Epochs: 25
  • Optimizer: Adam (lr=1e-4)
  • Loss: CrossEntropyLoss
  • Hardware: NVIDIA GPU
  • Framework: PyTorch

Applied strong spatial augmentation:

  • Random rotation (0–360°)
  • Random affine transformation (translation + shear)

Test Set Performance

Metric Value
ROC-AUC ≈ 0.955
PR-AUC ≈ 0.99
Accuracy 0.8570
Sensitivity (Recall) ≈ 83.4%
Specificity ≈ 93.6%

Evaluation includes ROC curves, Precision–Recall analysis, and confusion matrix transparency.


Results Structure

results/
├── validation/
│   ├── roc_val.png
│   ├── pr_val.png
│   └── confusion_matrix_val.png
└── test/
    ├── roc_test.png
    ├── pr_test.png
    └── confusion_matrix_test.png

Key Insights

  • Vision Transformers perform strongly on medical patch classification tasks.
  • PR-AUC is a more informative metric than accuracy under class imbalance.
  • Sensitivity–specificity trade-offs are critical for medical AI deployment.
  • Strong augmentation improves rotational invariance in histopathology imagery.

Repository Structure

swin-transformer-cancer-detection/
├── notebooks/
│   └── swin-transformers-version2.ipynb
├── results/
│   ├── validation/
│   └── test/
├── requirements.txt
├── LICENSE
└── README.md

Author

Abdul Rafay Mohd
Artificial Intelligence | Medical AI | Computer Vision


License

This project is licensed under the terms of the MIT License.


Project Context

This repository contains the Swin Transformer implementation developed by Abdul Rafay Mohd as part of a 5-member academic project.

Other team members contributed to project coordination, alternative model experimentation, feature engineering, and deployment infrastructure.

About

Transformer-based medical image classification pipeline using a pretrained Swin Transformer (timm) for metastatic cancer detection on the PCam dataset, with controlled train/validation/test split and ROC–PR evaluation.

Topics

cancer-detectioncomputer-visiondeep-learninghistopathologyimage-classificationimage-segmentationmedical-aimedical-imagingpytorchswin-transformertimmtransfer-learningvision-transformer

Resources

Readme
MIT license
Activity

Stars

0 stars

Watchers

1 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.