Run this model with HF Jobs
Run Jayanth2002/dinov2-base-finetuned-SkinDisease on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs to fine-tune https://huggingface.co/Jayanth2002/dinov2-base-finetuned-SkinDisease. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/Jayanth2002/dinov2-base-finetuned-SkinDisease on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Instructions to use Jayanth2002/dinov2-base-finetuned-SkinDisease with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Jayanth2002/dinov2-base-finetuned-SkinDisease with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-classification", model="Jayanth2002/dinov2-base-finetuned-SkinDisease") pipe("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/hub/parrots.png")# pip install -U transformers accelerate # Load model directly from transformers import AutoImageProcessor, AutoModelForImageClassification processor = AutoImageProcessor.from_pretrained("Jayanth2002/dinov2-base-finetuned-SkinDisease") model = AutoModelForImageClassification.from_pretrained("Jayanth2002/dinov2-base-finetuned-SkinDisease", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Download README.md from Jayanth2002/dinov2-base-finetuned-SkinDisease: direct link, hf CLI and curl.
- Browser
- Download file 4.9 kB
-
https://huggingface.co/Jayanth2002/dinov2-base-finetuned-SkinDisease/resolve/main/README.md
- Command line
-
hf download hf://Jayanth2002/dinov2-base-finetuned-SkinDisease/README.md
-
curl -L -o README.md https://huggingface.co/Jayanth2002/dinov2-base-finetuned-SkinDisease/resolve/main/README.md
license: apache-2.0
base_model: facebook/dinov2-base
metrics:
- accuracy
model-index:
- name: dinov2-base-finetuned-SkinDisease
results:
- task:
name: Image Classification
type: Skin_Disease-classification
dataset:
name: ISIC 2018+Atlas Dermatology
type: Local
config: default
split: train
args: default
metrics:
- name: Accuracy
type: accuracy
value: 0.9556772908366534
dinov2-base-finetuned-SkinDisease
This model is a fine-tuned version of facebook/dinov2-base on the Custom dataset. It achieves the following results on the evaluation set:
- Loss: 0.1321
- Accuracy: 0.9557
Model description
The Vision Transformer (ViT) is a transformer encoder model (BERT-like) pre-trained on a large collection of images in a self-supervised fashion.
Images are presented to the model as a sequence of fixed-size patches, which are linearly embedded. One also adds a [CLS] token to the beginning of a sequence to use it for classification tasks. One also adds absolute position embeddings before feeding the sequence to the layers of the Transformer encoder.
Note that this model does not include any fine-tuned heads.
By pre-training the model, it learns an inner representation of images that can then be used to extract features useful for downstream tasks: if you have a dataset of labeled images for instance, you can train a standard classifier by placing a linear layer on top of the pre-trained encoder. One typically places a linear layer on top of the [CLS] token, as the last hidden state of this token can be seen as a representation of an entire image.
How to use
import torch
from transformers import AutoModelForImageClassification, AutoImageProcessor
repo_name = "Jayanth2002/dinov2-base-finetuned-SkinDisease"
image_processor = AutoImageProcessor.from_pretrained(repo_name)
model = AutoModelForImageClassification.from_pretrained(repo_name)
# Load and preprocess the test image
image_path = "/content/img_416.jpg"
image = Image.open(image_path)
encoding = image_processor(image.convert("RGB"), return_tensors="pt")
# Make a prediction
with torch.no_grad():
outputs = model(**encoding)
logits = outputs.logits
predicted_class_idx = logits.argmax(-1).item()
# Get the class name
class_names = ['Basal Cell Carcinoma', 'Darier_s Disease', 'Epidermolysis Bullosa Pruriginosa', 'Hailey-Hailey Disease', 'Herpes Simplex', 'Impetigo', 'Larva Migrans', 'Leprosy Borderline', 'Leprosy Lepromatous', 'Leprosy Tuberculoid', 'Lichen Planus', 'Lupus Erythematosus Chronicus Discoides', 'Melanoma', 'Molluscum Contagiosum', 'Mycosis Fungoides', 'Neurofibromatosis', 'Papilomatosis Confluentes And Reticulate', 'Pediculosis Capitis', 'Pityriasis Rosea', 'Porokeratosis Actinic', 'Psoriasis', 'Tinea Corporis', 'Tinea Nigra', 'Tungiasis', 'actinic keratosis', 'dermatofibroma', 'nevus', 'pigmented benign keratosis', 'seborrheic keratosis', 'squamous cell carcinoma', 'vascular lesion']
predicted_class_name = class_names[predicted_class_idx]
print(predicted_class_name)
Training hyperparameters
The following hyperparameters were used during training:
- learning_rate: 5e-05
- train_batch_size: 32
- eval_batch_size: 32
- seed: 42
- gradient_accumulation_steps: 4
- total_train_batch_size: 128
- optimizer: Adam with betas=(0.9,0.999) and epsilon=1e-08
- lr_scheduler_type: linear
- lr_scheduler_warmup_ratio: 0.1
- num_epochs: 10
Training results
| Training Loss | Epoch | Step | Validation Loss | Accuracy |
|---|---|---|---|---|
| 0.9599 | 1.0 | 282 | 0.6866 | 0.7811 |
| 0.6176 | 2.0 | 565 | 0.4806 | 0.8399 |
| 0.4614 | 3.0 | 847 | 0.3092 | 0.8934 |
| 0.3976 | 4.0 | 1130 | 0.2620 | 0.9141 |
| 0.3606 | 5.0 | 1412 | 0.2514 | 0.9208 |
| 0.3075 | 6.0 | 1695 | 0.1968 | 0.9320 |
| 0.2152 | 7.0 | 1977 | 0.2004 | 0.9377 |
| 0.2194 | 8.0 | 2260 | 0.1627 | 0.9442 |
| 0.1706 | 9.0 | 2542 | 0.1449 | 0.9500 |
| 0.172 | 9.98 | 2820 | 0.1321 | 0.9557 |
Framework versions
- Transformers 4.33.2
- Pytorch 2.0.0
- Datasets 2.1.0
- Tokenizers 0.13.3
Kindly Cite Our Work
@article{mohan2024enhancing,
title={Enhancing skin disease classification leveraging transformer-based deep learning architectures and explainable ai},
author={Mohan, Jayanth and Sivasubramanian, Arrun and Sowmya, V and Vinayakumar, Ravi},
journal={arXiv preprint arXiv:2407.14757},
year={2024}
}