SA
sanskarsri26/ML-model-skin-disease
disease detection model using ML model and transfer learning
README for Skin Disease Classification Model Training Script
Overview
This script trains a deep learning model for skin disease classification on a dataset of categorized skin disease images. The model is built on MobileNetV2, an efficient and lightweight architecture ideal for resource-limited environments. Key features include data augmentation, mixed precision training, and multiple callbacks to enhance performance.
You can find the model and code here:
Kaggle - Skin Disease Model
The dataset used is available at:
Kaggle - Skin Diseases Image Dataset
Key Components
-
Data Augmentation:
- Utilizes
ImageDataGeneratorwith augmentations (shear, zoom, flip, rotation, brightness adjustment) to improve generalization and reduce overfitting. - Includes a validation split of 20%.
- Utilizes
-
MobileNetV2 Base Model:
- MobileNetV2 is used for transfer learning with pretrained weights, omitting the top layer (
include_top=False). - The base model is initially frozen for early training epochs.
- MobileNetV2 is used for transfer learning with pretrained weights, omitting the top layer (
-
Model Architecture:
- Sequential architecture includes MobileNetV2 followed by a global average pooling layer, a dense layer with 128 units, dropout, and a softmax layer for class probabilities.
-
Training Configuration:
- Optimizer: Adam with a learning rate of 1e-4.
- Loss function:
categorical_crossentropy. - Metrics:
accuracy.
-
Callbacks:
- EarlyStopping to halt training if
val_lossshows no improvement. - ReduceLROnPlateau to lower the learning rate when
val_lossstagnates. - ModelCheckpoint to save the best-performing model based on
val_loss.
- EarlyStopping to halt training if
-
Mixed Precision Training:
mixed_float16precision accelerates training by optimizing GPU memory usage on Kaggle.
Usage Instructions
- Adjust dataset paths to match your Kaggle setup.
- Ensure MobileNetV2 weights are available in the specified path.
- Running the script in a Kaggle notebook will:
- Load and preprocess data.
- Train the model with callbacks.
- Save the model as
skin_disease_model_mobilenet.h5for later use.
Expected Output
Outputs include:
- Training and validation accuracy and loss per epoch.
- Saved model file
skin_disease_model_mobilenet.h5. - Intermediate checkpoints saved as
best_model.keras.
Notes
- Modify
batch_sizeandepochsas needed based on resources and training time. - For higher accuracy, consider unfreezing additional layers for fine-tuning.