Downloads · 30 days
640
2% of all-time downloads
Jayanth2002/dinov2-base-finetuned-SkinDisease
dinov2-base-finetuned-SkinDisease is a image classification model from Jayanth2002. Use it when you need a label for an image. It is set up for transformers. The card lists the license as apache-2.0.
should probably proofread and complete it, then remove this comment. --
Downloads · 30 days
640
2% of all-time downloads
All-time downloads
29.1K
Public
Repo size
3.8 GB
Likes
13
Public
Click a slice to open those files.
.bin347 MB · 100%
From the Hugging Face model README
This model is a fine-tuned version of facebook/dinov2-base on the Custom dataset. It achieves the following results on the evaluation set:
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.
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)
The following hyperparameters were used during training:
| 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 |
@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}
}