Dermaid: nine-class skin condition classifier

A MobileNetV2 transfer-learning classifier that sorts a photograph of a skin condition into one of nine classes. Built as my final year project for BSc Computer Engineering at KNUST, 2024.

This is not a diagnostic tool

It was trained on a small public dataset for an undergraduate project. It has not been clinically validated, it has not been reviewed by a dermatologist, and it must not be used to make a medical decision. If you are worried about something on your skin, see a clinician.

Classes

Condition Type
Cellulitis Bacterial
Impetigo Bacterial
Clear Skin Negative class
Athlete's Foot Fungal
Nail Fungus Fungal
Ringworm Fungal
Cutaneous Larva Migrans Parasitic
Chicken Pox Viral
Shingles Viral

Index order in class_names.txt matches the softmax output order.

Architecture

Base MobileNetV2, ImageNet weights, frozen
Head GlobalAveragePooling2D, Dense(128, ReLU), Dense(9, softmax)
Input 128 x 128 RGB, rescaled to [0, 1]
Loss Sparse categorical cross-entropy
Optimiser Adam
Training 20 epochs, 80/20 train and validation split

MobileNetV2 was chosen for size: the model has to load and run inference inside a Flask process on modest hardware, which rules out heavier backbones. The base is frozen, so only the classification head was trained.

Results, read honestly

Trained on 762 labelled images across nine classes, roughly 85 per class.

Metric Value
Best validation accuracy 95.2% (epoch 8)
Final validation accuracy ~94.5%
Final validation loss ~0.19
Training accuracy 100% from epoch 3 onward

Training and validation curves

Training accuracy reaches 1.0 by the third epoch and training loss falls to nearly zero, while validation loss flattens at 0.19 and stops improving. That is the model memorising the training set, not continuing to learn from it. The validation figure is real, but it sits on a validation split of a 762-image dataset, so a handful of images decide the last percentage point.

Treat 95% as "reasonable for this dataset size", not as a claim about performance in the wild.

Limitations

Skin tone. This is the most important one. Public dermatology datasets skew heavily toward lighter skin tones, and this model inherits that. It will underperform on darker skin, which is exactly the population the project was built for. That gap is the motivation for the companion repository GAN-FOR-SKIN-COLOUR, a StarGAN implementation that translates lesion images across skin-tone domains to augment the training set.

Also:

  • No data augmentation in the training pipeline.
  • Class balance across the nine conditions was not corrected.
  • The base model is frozen; no fine-tuning pass over the upper base layers was run.
  • Nine classes is a narrow slice of dermatology. Anything outside them will still be forced into one of the nine, confidently.
  • Trained and validated on curated dataset images, not on phone photographs taken in uncontrolled lighting.

Usage

The checkpoint is weights-only, so rebuild the architecture and load into it:

import numpy as np, tensorflow as tf
from tensorflow.keras import layers, models
from huggingface_hub import hf_hub_download

REPO = "Radubotchway/dermaid-skin-condition-classifier"

base = tf.keras.applications.MobileNetV2(
    input_shape=(128, 128, 3), include_top=False, weights="imagenet")
base.trainable = False
model = models.Sequential([
    base,
    layers.GlobalAveragePooling2D(),
    layers.Dense(128, activation="relu"),
    layers.Dense(9, activation="softmax"),
])
model.load_weights(hf_hub_download(REPO, "model.weights.h5"))

class_names = open(hf_hub_download(REPO, "class_names.txt")).read().split("\n")

img = tf.keras.utils.load_img("photo.jpg", target_size=(128, 128))
x = np.expand_dims(tf.keras.utils.img_to_array(img) / 255.0, axis=0)
probs = model.predict(x)[0]
print(class_names[int(np.argmax(probs))], float(probs.max()))

Preprocessing must match training: resize to 128 x 128 RGB and divide by 255.

Training data

The skin disease dataset as published on Kaggle. The dataset itself is not redistributed here; download it from the original source.

Links

License

MIT.

Downloads last month
-
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Space using Radubotchway/dermaid-skin-condition-classifier 1