🚀 dinov2-base-finetuned-SkinDisease
本模型是基於facebook/dinov2-base在自定義數據集上微調得到的版本。它在評估集上取得了出色的效果,能有效助力皮膚疾病的分類任務。
🚀 快速開始
本模型是 facebook/dinov2-base 在自定義數據集上的微調版本。它在評估集上取得了以下結果:
✨ 主要特性
視覺變換器(ViT)是一種以自監督方式在大量圖像上預訓練的Transformer編碼器模型(類似BERT)。
圖像以固定大小的塊序列形式呈現給模型,這些塊會進行線性嵌入。同時,會在序列開頭添加一個 [CLS] 標記,用於分類任務。在將序列輸入到Transformer編碼器層之前,還會添加絕對位置嵌入。
請注意,此模型不包含任何微調的頭部。
通過預訓練模型,它學習到圖像的內部表示,可用於提取對下游任務有用的特徵:例如,如果您有一個帶標籤的圖像數據集,可以在預訓練編碼器之上放置一個線性層來訓練一個標準分類器。通常會在 [CLS] 標記之上放置一個線性層,因為該標記的最後隱藏狀態可視為整個圖像的表示。
💻 使用示例
基礎用法
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)
image_path = "/content/img_416.jpg"
image = Image.open(image_path)
encoding = image_processor(image.convert("RGB"), return_tensors="pt")
with torch.no_grad():
outputs = model(**encoding)
logits = outputs.logits
predicted_class_idx = logits.argmax(-1).item()
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)
📚 詳細文檔
訓練超參數
訓練過程中使用了以下超參數:
- 學習率:5e-05
- 訓練批次大小:32
- 評估批次大小:32
- 隨機種子:42
- 梯度累積步數:4
- 總訓練批次大小:128
- 優化器:Adam(β1=0.9,β2=0.999,ε=1e-08)
- 學習率調度器類型:線性
- 學習率調度器預熱比例:0.1
- 訓練輪數:10
訓練結果
訓練損失 |
輪數 |
步數 |
驗證損失 |
準確率 |
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 |
框架版本
- Transformers 4.33.2
- Pytorch 2.0.0
- Datasets 2.1.0
- Tokenizers 0.13.3
📄 許可證
本項目採用 Apache-2.0 許可證。
📚 引用說明
如果您使用了本模型,請引用以下論文:
@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}
}