swin tiny patch4 window7 224 finetuned skin cancer
gianlabIntroduction
The SWIN-TINY-PATCH4-WINDOW7-224-FINETUNED-SKIN-CANCER model is a fine-tuned image classification model based on Microsoft's SWIN-TINY-PATCH4-WINDOW7-224, designed to classify images of skin cancer. This model uses the Skin Cancer MNIST: HAM10000 dataset from Kaggle. It achieved an accuracy of 72.75% on its evaluation set.
Architecture
The model is built on the Swin Transformer architecture, which is known for its efficiency in handling image data. It utilizes a hierarchical design with shiftable windows, allowing for improved patch merging and attention mechanisms across different image regions.
Training
The model was trained using the following hyperparameters:
- Learning Rate: 5e-05
- Train Batch Size: 32
- Evaluation Batch Size: 32
- Seed: 42
- Gradient Accumulation Steps: 4
- Total Train Batch Size: 128
- Optimizer: Adam (betas=(0.9, 0.999), epsilon=1e-08)
- Learning Rate Scheduler: Linear
- Warmup Ratio: 0.1
- Number of Epochs: 1
The training achieved a validation loss of 0.7695 and an accuracy of 72.75%.
Guide: Running Locally
To run this model locally, follow these steps:
-
Environment Setup
- Ensure you have Python installed.
- Install required packages:
transformers
,torch
,datasets
, andtokenizers
.
-
Download the Model
- Use the Hugging Face Transformers library to load the model:
from transformers import AutoModelForImageClassification, AutoTokenizer model = AutoModelForImageClassification.from_pretrained("gianlab/swin-tiny-patch4-window7-224-finetuned-skin-cancer")
- Use the Hugging Face Transformers library to load the model:
-
Data Preparation
- Prepare your dataset using the same format as the training data (imagefolder).
-
Inference
- Run inference on your image dataset to classify skin cancer types.
Cloud GPUs
For better performance, consider using cloud GPUs from providers like AWS, GCP, or Azure to accelerate the inference process.
License
This project is licensed under the Apache License 2.0, allowing for commercial use, distribution, modification, and private use.