Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 

Repository files navigation

#DermaMNIST Classification using Simple CNN Classical 2D CNN baseline trained on binary DermaMNIST (Actinic Keratoses vs Basal Cell Carcinoma), serving as the classical counterpart in a QCNN vs CNN comparative study on skin lesion classification.

DermaMNIST Binary Classification using Classical CNN

A classical Convolutional Neural Network (CNN) implementation for binary skin lesion classification on the DermaMNIST dataset, distinguishing Actinic Keratoses and Intraepithelial Carcinoma (AKIEC) from Basal Cell Carcinoma (BCC).

This repository serves as the classical baseline in a comparative study against a Quantum Convolutional Neural Network (QCNN).

📄 Companion repository (QCNN): [Link to your QCNN repo]


📋 Project Overview

Property Details
Task Binary classification — AKIEC (Class 0) vs BCC (Class 1)
Dataset DermaMNIST (MedMNIST v2)
Image size 28×28 pixels, grayscale
Framework TensorFlow 2 / Keras
Total parameters 420,610
Test accuracy ~55%
Training 60 epochs, batch size 64
Platform Google Colab

🗂️ Dataset

DermaMNIST is part of the MedMNIST v2 benchmark collection, derived from the HAM10000 dermoscopy dataset (Tschandl et al., 2018). Images are 28×28 pixels in RGB format, standardised across 7 lesion categories.

This project uses a binary subset of two classes:

Label Class Description
0 AKIEC Actinic Keratoses & Intraepithelial Carcinoma — precancerous lesion
1 BCC Basal Cell Carcinoma — most common skin cancer

The dataset is accessed via the medmnist Python package, which handles downloading, caching, and loading automatically.


🏗️ Model Architecture

Input (28×28×1) │ ▼ Conv2D (32 filters, 3×3, same padding) → ReLU → MaxPooling2D (2×2) │ ▼ Conv2D (64 filters, 3×3, same padding) → ReLU → MaxPooling2D (2×2) │ ▼ Flatten (3136 units) │ ▼ Dense (128 units, ReLU) → Dropout (0.3) │ ▼ Dense (2 units, Softmax) → [P(AKIEC), P(BCC)]

Layer-wise parameter count

Layer Output Shape Parameters
Conv2D (32 filters) (28, 28, 32) 320
MaxPooling2D (14, 14, 32) 0
Conv2D (64 filters) (14, 14, 64) 18,496
MaxPooling2D (7, 7, 64) 0
Flatten (3136,) 0
Dense (128) (128,) 401,536
Dropout (0.3) (128,) 0
Dense (2, softmax) (2,) 258
Total 420,610

⚙️ Training Configuration

Parameter Value
Loss function Categorical cross-entropy
Optimiser Adam (lr=0.001, weight_decay=0.0001)
Epochs 60
Batch size 64
Train/Val split 80% / 20%
Class imbalance sklearn compute_class_weight('balanced')
Gradient method Backpropagation

Data Augmentation

Applied online during training only via Keras ImageDataGenerator:

Augmentation Setting
Rotation ±10°
Horizontal flip Enabled (50% probability)
Zoom ±10%

📊 Results

Metric Value
Test Accuracy ~55%
Chance baseline 50%
Above chance +5 percentage points

The model correctly learns discriminative features from DermaMNIST dermoscopy images, exceeding the 50% chance baseline. The modest accuracy reflects the inherent difficulty of distinguishing AKIEC from BCC on 28×28 pixel grayscale images with a small training set (~670 samples).


🔁 How to Run

Option 1 — Google Colab (Recommended)

Click the badge below to open directly in Colab:

Open In Colab

Option 2 — Run Locally

Step 1 — Clone the repository

git clone https://github.com/your-username/your-repo-name.git
cd your-repo-name

Step 2 — Install dependencies

pip install tensorflow medmnist scikit-learn numpy matplotlib

Step 3 — Run the notebook

jupyter notebook MSc_simple_CNN_dermaMNIST.ipynb

📦 Requirements

tensorflow>=2.0 keras medmnist scikit-learn numpy matplotlib

📁 Repository Structure

├── MSc_simple_CNN_dermaMNIST.ipynb # Main Colab notebook ├── README.md # This file


🔬 Preprocessing Pipeline

Raw DermaMNIST images (uint8, [0, 255]) │ ▼ Load as grayscale (as_rgb=False) → shape: (N, 28, 28, 1) │ ▼ Normalise to [0.0, 1.0] → divide by 255.0 │ ▼ Filter for AKIEC (0) and BCC (1) only │ ▼ One-hot encode labels → [1,0] for AKIEC, [0,1] for BCC │ ▼ 80/20 train/validation split │ ▼ Apply class-weight balancing │ ▼ Online augmentation via ImageDataGenerator (training only) │ ▼ Feed to CNN → train for 60 epochs


📈 Comparison with QCNN

This repository is the classical baseline in a QCNN vs CNN comparative study:

Property CNN (This repo) QCNN (Companion repo)
Framework TensorFlow / Keras PennyLane + PyTorch
Input Raw 28×28×1 image 16-dim autoencoder latent vector
Trainable parameters 420,610 51
Test accuracy ~55% ~60%
Gradient method Backpropagation Parameter-shift rule
Training duration 60 epochs 200 steps
Hardware GPU (Colab) CPU (Colab)

The QCNN achieves ~5 percentage points higher accuracy with 8,247× fewer parameters, demonstrating competitive quantum representational capacity in a low-data medical imaging regime.


About

Classical CNN baseline for binary skin lesion classification on DermaMNIST (AKIEC vs BCC) implemented in TensorFlow/Keras with data augmentation, class-weight balancing, and Adam optimisation. Achieves 55% test accuracy with 420,610 trainable parameters. Companion repository to the QCNN benchmark study.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages