Update README.md
Browse files
README.md
CHANGED
|
@@ -61,39 +61,6 @@ The model serves as a preliminary screening tool to help patients understand pot
|
|
| 61 |
- **Space Demo:** https://huggingface.co/spaces/datdevsteve/nivra-dinov2-medical
|
| 62 |
- **Parent Model:** https://huggingface.co/facebook/dinov2-base
|
| 63 |
|
| 64 |
-
## Uses
|
| 65 |
-
|
| 66 |
-
### Direct Use
|
| 67 |
-
|
| 68 |
-
This model can be directly used for:
|
| 69 |
-
|
| 70 |
-
- **Medical Image Screening**: Preliminary classification of skin conditions and visible medical issues
|
| 71 |
-
- **Healthcare Triage Apps**: Assist patients in determining severity and urgency of visible conditions
|
| 72 |
-
- **Telemedicine Platforms**: Support remote healthcare consultations with automated image analysis
|
| 73 |
-
- **Health Education**: Help patients learn about common dermatological conditions
|
| 74 |
-
- **Medical Research**: Analyze patterns in dermatological conditions in Indian populations
|
| 75 |
-
|
| 76 |
-
### Downstream Use
|
| 77 |
-
|
| 78 |
-
The model can be integrated into:
|
| 79 |
-
|
| 80 |
-
- **Mobile Healthcare Applications**: Patient-facing symptom checker apps
|
| 81 |
-
- **Healthcare Chatbots**: Combined with text-based symptom analysis for comprehensive assessment
|
| 82 |
-
- **Clinical Decision Support**: Assist healthcare providers with preliminary image analysis
|
| 83 |
-
- **Public Health Monitoring**: Track prevalence of visible medical conditions
|
| 84 |
-
- **Medical Education Tools**: Training platforms for medical students
|
| 85 |
-
|
| 86 |
-
### Out-of-Scope Use
|
| 87 |
-
|
| 88 |
-
❌ **This model should NOT be used for:**
|
| 89 |
-
|
| 90 |
-
- **Medical Diagnosis**: This is NOT a diagnostic tool and cannot replace professional medical evaluation
|
| 91 |
-
- **Emergency Medical Decisions**: Not suitable for acute or life-threatening situations
|
| 92 |
-
- **Prescription or Treatment Recommendations**: Cannot prescribe medications or treatments
|
| 93 |
-
- **Legal or Insurance Decisions**: Not validated for medicolegal purposes
|
| 94 |
-
- **Surveillance or Non-Medical Purposes**: Not intended for identifying individuals or non-medical use
|
| 95 |
-
- **Conditions Requiring Laboratory Tests**: Cannot detect internal conditions or diseases requiring lab analysis
|
| 96 |
-
|
| 97 |
## Key Performance Metrics
|
| 98 |
|
| 99 |
### Test Set Results
|
|
@@ -147,163 +114,7 @@ Users should:
|
|
| 147 |
- Include emergency contact information for critical cases
|
| 148 |
- Log all predictions for quality monitoring and improvement
|
| 149 |
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
### Using Transformers Library
|
| 153 |
-
|
| 154 |
-
```python
|
| 155 |
-
from transformers import AutoImageProcessor, AutoModelForImageClassification
|
| 156 |
-
from PIL import Image
|
| 157 |
-
import torch
|
| 158 |
-
|
| 159 |
-
# Load model and processor
|
| 160 |
-
model_name = "datdevsteve/nivra-dinov2-finetuned"
|
| 161 |
-
processor = AutoImageProcessor.from_pretrained(model_name)
|
| 162 |
-
model = AutoModelForImageClassification.from_pretrained(model_name)
|
| 163 |
-
|
| 164 |
-
# Load and process image
|
| 165 |
-
image = Image.open("medical_image.jpg")
|
| 166 |
-
inputs = processor(images=image, return_tensors="pt")
|
| 167 |
-
|
| 168 |
-
# Get prediction
|
| 169 |
-
with torch.no_grad():
|
| 170 |
-
outputs = model(**inputs)
|
| 171 |
-
logits = outputs.logits
|
| 172 |
-
probabilities = torch.softmax(logits, dim=-1)
|
| 173 |
-
predicted_class = probabilities.argmax(-1).item()
|
| 174 |
-
confidence = probabilities[predicted_class].item()
|
| 175 |
-
|
| 176 |
-
# Get label
|
| 177 |
-
label = model.config.id2label[predicted_class]
|
| 178 |
-
print(f"Condition: {label}")
|
| 179 |
-
print(f"Confidence: {confidence:.2%}")
|
| 180 |
-
```
|
| 181 |
-
|
| 182 |
-
### Using Pipeline
|
| 183 |
-
|
| 184 |
-
```python
|
| 185 |
-
from transformers import pipeline
|
| 186 |
-
from PIL import Image
|
| 187 |
-
|
| 188 |
-
classifier = pipeline("image-classification", model="datdevsteve/nivra-dinov2-finetuned")
|
| 189 |
-
|
| 190 |
-
image = Image.open("medical_image.jpg")
|
| 191 |
-
results = classifier(image, top_k=3)
|
| 192 |
-
|
| 193 |
-
for result in results:
|
| 194 |
-
print(f"{result['label']}: {result['score']:.2%}")
|
| 195 |
-
```
|
| 196 |
-
|
| 197 |
-
### Via Gradio Space API
|
| 198 |
-
|
| 199 |
-
```python
|
| 200 |
-
import requests
|
| 201 |
-
import base64
|
| 202 |
-
|
| 203 |
-
# Read and encode image
|
| 204 |
-
with open("medical_image.jpg", "rb") as f:
|
| 205 |
-
image_b64 = base64.b64encode(f.read()).decode()
|
| 206 |
-
|
| 207 |
-
# Call API
|
| 208 |
-
url = "https://datdevsteve-nivra-dinov2-medical.hf.space/api/predict"
|
| 209 |
-
response = requests.post(url, json={"data": [image_b64]})
|
| 210 |
-
|
| 211 |
-
print(response.json())
|
| 212 |
-
```
|
| 213 |
-
|
| 214 |
-
## Training Details
|
| 215 |
-
|
| 216 |
-
### Training Data
|
| 217 |
-
|
| 218 |
-
- **Dataset Size**: ~12,000 labeled medical images
|
| 219 |
-
- **Image Sources**:
|
| 220 |
-
- Curated Indian dermatology databases
|
| 221 |
-
- Public medical image repositories (DermNet, ISIC Archive - with proper licensing)
|
| 222 |
-
- Synthetic data augmentation
|
| 223 |
-
- **Conditions Covered**: 40+ common dermatological and visible medical conditions
|
| 224 |
-
- **Image Specifications**:
|
| 225 |
-
- Resolution: 224x224 pixels (resized)
|
| 226 |
-
- Format: RGB images
|
| 227 |
-
- Diverse lighting and quality conditions
|
| 228 |
-
- **Data Split**: 75% train, 15% validation, 10% test
|
| 229 |
-
- **Demographics**: Balanced across different skin tones common in Indian population
|
| 230 |
-
|
| 231 |
-
### Training Procedure
|
| 232 |
-
|
| 233 |
-
**Preprocessing:**
|
| 234 |
-
- Image resizing and normalization
|
| 235 |
-
- Data augmentation: rotation, flip, color jitter, brightness adjustment
|
| 236 |
-
- Removal of personally identifiable features (faces blurred when not relevant)
|
| 237 |
-
- Quality filtering (removing blurry or unusable images)
|
| 238 |
-
|
| 239 |
-
**Training Hyperparameters:**
|
| 240 |
-
|
| 241 |
-
```python
|
| 242 |
-
{
|
| 243 |
-
"learning_rate": 5e-5,
|
| 244 |
-
"batch_size": 32,
|
| 245 |
-
"num_epochs": 20,
|
| 246 |
-
"warmup_steps": 500,
|
| 247 |
-
"weight_decay": 0.01,
|
| 248 |
-
"optimizer": "AdamW",
|
| 249 |
-
"lr_scheduler": "cosine",
|
| 250 |
-
"image_size": 224,
|
| 251 |
-
"gradient_accumulation_steps": 2
|
| 252 |
-
}
|
| 253 |
-
```
|
| 254 |
-
|
| 255 |
-
**Training Regime:** Mixed precision (fp16)
|
| 256 |
-
|
| 257 |
-
**Hardware:**
|
| 258 |
-
- Training Time: ~8 hours
|
| 259 |
-
- GPU: NVIDIA A100 40GB
|
| 260 |
-
- Cloud Provider: Google Cloud Platform
|
| 261 |
-
- Compute Region: asia-south1 (Mumbai)
|
| 262 |
-
|
| 263 |
-
**Fine-tuning Strategy:**
|
| 264 |
-
- Froze first 6 transformer blocks
|
| 265 |
-
- Fine-tuned last 6 blocks + classification head
|
| 266 |
-
- Classification head: Linear layer (768 → num_classes)
|
| 267 |
-
- Loss function: Cross-entropy with label smoothing (0.1)
|
| 268 |
-
- Early stopping: Patience of 5 epochs
|
| 269 |
-
|
| 270 |
-
### Evaluation
|
| 271 |
-
|
| 272 |
-
**Testing Data:**
|
| 273 |
-
- 1,200 held-out medical images
|
| 274 |
-
- Balanced across condition categories
|
| 275 |
-
- Includes challenging cases (multiple conditions, poor lighting)
|
| 276 |
-
|
| 277 |
-
**Metrics:**
|
| 278 |
-
- Accuracy: Overall correctness
|
| 279 |
-
- Precision/Recall/F1: Per-class and macro-averaged
|
| 280 |
-
- Confusion Matrix: Analyze misclassification patterns
|
| 281 |
-
- Top-3 Accuracy: 96.4% (correct label in top 3 predictions)
|
| 282 |
-
|
| 283 |
-
## Label Classes
|
| 284 |
-
|
| 285 |
-
The model classifies medical images into the following categories:
|
| 286 |
-
|
| 287 |
-
```python
|
| 288 |
-
LABELS = [
|
| 289 |
-
"Fungal Infection (Ringworm/Tinea)",
|
| 290 |
-
"Bacterial Skin Infection (Impetigo/Cellulitis)",
|
| 291 |
-
"Allergic Rash/Contact Dermatitis",
|
| 292 |
-
"Eczema/Atopic Dermatitis",
|
| 293 |
-
"Psoriasis",
|
| 294 |
-
"Acne Vulgaris",
|
| 295 |
-
"Viral Skin Infection (Warts/Herpes)",
|
| 296 |
-
"Insect Bite/Sting",
|
| 297 |
-
"Burn Injury (1st/2nd Degree)",
|
| 298 |
-
"Wound/Cut/Abrasion",
|
| 299 |
-
"Urticaria (Hives)",
|
| 300 |
-
"Seborrheic Dermatitis",
|
| 301 |
-
"Rosacea",
|
| 302 |
-
"Vitiligo",
|
| 303 |
-
"Melanoma (Requires Immediate Medical Attention)",
|
| 304 |
-
# ... (40+ conditions total)
|
| 305 |
-
]
|
| 306 |
-
```
|
| 307 |
|
| 308 |
## Model Architecture and Objective
|
| 309 |
|
|
@@ -334,27 +145,10 @@ Carbon emissions estimated using the [Machine Learning Impact calculator](https:
|
|
| 334 |
|
| 335 |
If you use this model in your research or application, please cite:
|
| 336 |
|
| 337 |
-
**BibTeX:**
|
| 338 |
-
|
| 339 |
-
```bibtex
|
| 340 |
-
@misc{dinov2-indian-medical-2026,
|
| 341 |
-
author = {Nivra Healthcare Team},
|
| 342 |
-
title = {DinoV2 for Indian Healthcare Medical Image Classification},
|
| 343 |
-
year = {2026},
|
| 344 |
-
publisher = {HuggingFace},
|
| 345 |
-
journal = {HuggingFace Model Hub},
|
| 346 |
-
howpublished = {\url{https://huggingface.co/datdevsteve/nivra-dinov2-finetuned}}
|
| 347 |
-
}
|
| 348 |
-
```
|
| 349 |
-
|
| 350 |
-
**APA:**
|
| 351 |
-
|
| 352 |
-
Nivra Healthcare Team. (2026). *DinoV2 for Indian Healthcare Medical Image Classification*. HuggingFace Model Hub. https://huggingface.co/datdevsteve/nivra-dinov2-finetuned
|
| 353 |
|
| 354 |
## Model Card Authors
|
| 355 |
|
| 356 |
- **datdevsteve** - Model development and fine-tuning
|
| 357 |
-
- **Nivra Team** - Dataset curation, validation, and medical expertise consultation
|
| 358 |
|
| 359 |
## Model Card Contact
|
| 360 |
|
|
@@ -368,11 +162,6 @@ For questions, issues, or collaboration inquiries:
|
|
| 368 |
|
| 369 |
### Version 1.0.0 (January 2026)
|
| 370 |
- Initial release
|
| 371 |
-
- 91.2% accuracy on test set
|
| 372 |
-
- Trained on 12,000+ medical images
|
| 373 |
-
- 40+ medical condition classes
|
| 374 |
-
- Optimized for Indian healthcare context
|
| 375 |
-
|
| 376 |
---
|
| 377 |
|
| 378 |
**Last Updated:** January 6, 2026
|
|
|
|
| 61 |
- **Space Demo:** https://huggingface.co/spaces/datdevsteve/nivra-dinov2-medical
|
| 62 |
- **Parent Model:** https://huggingface.co/facebook/dinov2-base
|
| 63 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
## Key Performance Metrics
|
| 65 |
|
| 66 |
### Test Set Results
|
|
|
|
| 114 |
- Include emergency contact information for critical cases
|
| 115 |
- Log all predictions for quality monitoring and improvement
|
| 116 |
|
| 117 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 118 |
|
| 119 |
## Model Architecture and Objective
|
| 120 |
|
|
|
|
| 145 |
|
| 146 |
If you use this model in your research or application, please cite:
|
| 147 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 148 |
|
| 149 |
## Model Card Authors
|
| 150 |
|
| 151 |
- **datdevsteve** - Model development and fine-tuning
|
|
|
|
| 152 |
|
| 153 |
## Model Card Contact
|
| 154 |
|
|
|
|
| 162 |
|
| 163 |
### Version 1.0.0 (January 2026)
|
| 164 |
- Initial release
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 165 |
---
|
| 166 |
|
| 167 |
**Last Updated:** January 6, 2026
|