This repository implements EfficientNet-B0 for skin lesion classification using three different fine-tuning methods:
- Base Model Training
- Adapter Fine-Tuning
- LoRA Fine-Tuning
The objective is to classify skin lesion images into 8 disease categories while improving accuracy and efficiency using advanced fine-tuning techniques.
- Model: EfficientNet-B0 pre-trained on ImageNet.
- Classifier: Fully connected layers added to support 8 disease categories.
- Validation Accuracy: 74%
- Training Time: ~4 hours on a MacBook Pro M1 GPU.
- Description: The base model was trained with all layers unfrozen to fine-tune for skin lesion classification. It serves as the foundation for further improvements using Adapter and LoRA fine-tuning.
- What Are Adapters?
- Small, lightweight layers added to the model's classifier for task-specific fine-tuning.
- Parameters outside these adapters remain frozen, reducing computational cost.
- Validation Accuracy: 76%
- Training Time: ~1 hour.
- Description: Adapter fine-tuning improves resource efficiency while achieving better accuracy than the base model.
- What Is LoRA?
- Low-Rank Adaptation (LoRA) introduces task-specific low-rank matrices into the model's classifier.
- Significantly reduces memory usage while maintaining high accuracy.
- Validation Accuracy: 80%
- Training Time: ~45 minutes.
- LoRA Configuration:
- Rank (
r
): 8 - Scaling Factor (
alpha
): 32
- Rank (
- Description: LoRA fine-tuning yielded the highest validation accuracy with minimal computational cost.
The model classifies skin lesions into the following 8 categories:
- Melanoma: High-risk skin cancer with irregular moles.
- Basal Cell Carcinoma: Pearly or waxy bumps on the skin.
- Squamous Cell Carcinoma: Firm, red nodules with scaly, crusted surfaces.
- Actinic Keratosis: Rough, scaly patches commonly found on sun-exposed skin.
- Benign Keratosis: Non-cancerous skin growths appearing as brown or black patches.
- Dermatofibroma: Small, firm nodules caused by minor injuries like insect bites.
- Vascular Lesion: Marks or growths caused by abnormal blood vessels.
- Melanocytic Nevus: Common moles that are small and pigmented.
- Download the Repository:
Clone or download the repository files:
git clone <repository-url>
- Prepare Required Files:
- Download the application folder and the saved model folder.
- Update the saved_model_path in app.py to the path of your downloaded model.
- Install Dependencies: Install the required Python libraries:
- pip install -r requirements.txt
- Run the Application: Start the Flask server by running:
- python app.py
- Access the Application: Open your browser and navigate to:
- Upload an Image: Use the upload form to submit a skin lesion image and view the predictions.
Install all dependencies using the following command:
- pip install -r requirements.txt
- Flask
- PyTorch
- torchvision
- Pillow
- scikit-learn
- Support for larger models (e.g., EfficientNet-B3 or ViT) for higher accuracy.
- Provide a live API for disease prediction.
- Enhance the UI with interactive features and visualization tools.