Upload folder using huggingface_hub
Browse files- README.md +47 -317
- checkpoint-96/config.json +53 -0
- checkpoint-96/model.safetensors +3 -0
- checkpoint-96/optimizer.pt +3 -0
- checkpoint-96/rng_state.pth +3 -0
- checkpoint-96/scheduler.pt +3 -0
- checkpoint-96/trainer_state.json +118 -0
- checkpoint-96/training_args.bin +3 -0
- config.json +22 -6
- model.safetensors +2 -2
- training_args.bin +1 -1
- training_results.json +5 -5
README.md
CHANGED
|
@@ -1,351 +1,81 @@
|
|
| 1 |
---
|
| 2 |
license: apache-2.0
|
|
|
|
| 3 |
tags:
|
| 4 |
-
- computer-vision
|
| 5 |
- image-classification
|
| 6 |
-
- vision
|
| 7 |
-
|
|
|
|
| 8 |
datasets:
|
| 9 |
- custom
|
| 10 |
metrics:
|
| 11 |
- accuracy
|
| 12 |
- f1
|
| 13 |
-
|
| 14 |
-
- name: skincare-detection
|
| 15 |
-
results: []
|
| 16 |
-
inference: true
|
| 17 |
-
widget:
|
| 18 |
-
- src: >-
|
| 19 |
-
https://huggingface.co/0xnu/skincare-detection/resolve/main/joe.jpeg
|
| 20 |
-
example_title: "Sample Skin Image"
|
| 21 |
---
|
| 22 |
|
| 23 |
-
|
| 24 |
|
| 25 |
-
|
| 26 |
|
| 27 |
-
|
| 28 |
|
| 29 |
-
|
| 30 |
-
+ athlete-foot
|
| 31 |
-
+ cellulitis
|
| 32 |
-
+ chickenpox
|
| 33 |
-
+ cutaneous-larva-migrans
|
| 34 |
-
+ eczema
|
| 35 |
-
+ impetigo
|
| 36 |
-
+ nail-fungus
|
| 37 |
-
+ normal
|
| 38 |
-
+ ringworm
|
| 39 |
-
+ rosacea
|
| 40 |
-
+ shingles
|
| 41 |
|
| 42 |
-
|
|
|
|
|
|
|
|
|
|
| 43 |
|
| 44 |
-
|
| 45 |
-
eval_loss: 0.2097
|
| 46 |
-
eval_accuracy: 0.9779
|
| 47 |
-
eval_f1: 0.9778
|
| 48 |
-
eval_precision: 0.9794
|
| 49 |
-
eval_recall: 0.9779
|
| 50 |
-
eval_runtime: 14.2159
|
| 51 |
-
eval_samples_per_second: 19.1340
|
| 52 |
-
eval_steps_per_second: 0.6330
|
| 53 |
-
epoch: 12.0000
|
| 54 |
-
```
|
| 55 |
|
| 56 |
-
###
|
|
|
|
| 57 |
|
| 58 |
-
|
| 59 |
|
| 60 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
|
| 62 |
-
|
| 63 |
-
|
| 64 |
|
| 65 |
-
|
|
|
|
|
|
|
| 66 |
from transformers import ViTImageProcessor, ViTForImageClassification
|
| 67 |
from PIL import Image
|
| 68 |
-
import
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
def __init__(self, model_name: str = '0xnu/skincare-detection'):
|
| 78 |
-
"""Initialize the classifier with model loading."""
|
| 79 |
-
print(f"🔄 Loading model: {model_name}")
|
| 80 |
-
|
| 81 |
-
try:
|
| 82 |
-
self.processor = ViTImageProcessor.from_pretrained(model_name)
|
| 83 |
-
self.model = ViTForImageClassification.from_pretrained(model_name)
|
| 84 |
-
self.model.eval()
|
| 85 |
-
|
| 86 |
-
# Get class information
|
| 87 |
-
self.id2label = self.model.config.id2label
|
| 88 |
-
self.label2id = self.model.config.label2id
|
| 89 |
-
self.num_classes = len(self.id2label)
|
| 90 |
-
|
| 91 |
-
print(f"✅ Model loaded successfully!")
|
| 92 |
-
print(f"📊 Classes ({self.num_classes}): {list(self.id2label.values())}")
|
| 93 |
-
|
| 94 |
-
except Exception as e:
|
| 95 |
-
print(f"❌ Error loading model: {e}")
|
| 96 |
-
raise e
|
| 97 |
-
|
| 98 |
-
def classify_single_image(self, image_path: Union[str, Path],
|
| 99 |
-
show_all_scores: bool = True,
|
| 100 |
-
min_confidence: float = 0.01) -> Dict:
|
| 101 |
-
"""
|
| 102 |
-
Classify a single image and return detailed results.
|
| 103 |
-
|
| 104 |
-
Args:
|
| 105 |
-
image_path: Path to the image file
|
| 106 |
-
show_all_scores: Whether to show all class scores
|
| 107 |
-
min_confidence: Minimum confidence to display (0.0 to 1.0)
|
| 108 |
-
|
| 109 |
-
Returns:
|
| 110 |
-
Dictionary with classification results
|
| 111 |
-
"""
|
| 112 |
-
|
| 113 |
-
try:
|
| 114 |
-
# Load and process image
|
| 115 |
-
image = Image.open(image_path).convert('RGB')
|
| 116 |
-
inputs = self.processor(images=image, return_tensors="pt")
|
| 117 |
-
|
| 118 |
-
# Make prediction
|
| 119 |
-
with torch.no_grad():
|
| 120 |
-
outputs = self.model(**inputs)
|
| 121 |
-
logits = outputs.logits
|
| 122 |
-
probabilities = torch.softmax(logits, dim=-1)[0]
|
| 123 |
-
|
| 124 |
-
# Get top prediction
|
| 125 |
-
predicted_class_id = logits.argmax().item()
|
| 126 |
-
predicted_label = self.id2label[predicted_class_id]
|
| 127 |
-
predicted_confidence = float(probabilities[predicted_class_id])
|
| 128 |
-
|
| 129 |
-
# Prepare all scores
|
| 130 |
-
all_scores = {}
|
| 131 |
-
for class_id, class_name in self.id2label.items():
|
| 132 |
-
confidence = float(probabilities[class_id])
|
| 133 |
-
if confidence >= min_confidence:
|
| 134 |
-
all_scores[class_name] = confidence
|
| 135 |
-
|
| 136 |
-
# Sort by confidence
|
| 137 |
-
sorted_scores = dict(sorted(all_scores.items(),
|
| 138 |
-
key=lambda x: x[1], reverse=True))
|
| 139 |
-
|
| 140 |
-
result = {
|
| 141 |
-
'image_path': str(image_path),
|
| 142 |
-
'image_name': Path(image_path).name,
|
| 143 |
-
'predicted_class': predicted_label,
|
| 144 |
-
'predicted_confidence': predicted_confidence,
|
| 145 |
-
'all_scores': sorted_scores if show_all_scores else None,
|
| 146 |
-
'image_size': image.size,
|
| 147 |
-
'num_classes': self.num_classes
|
| 148 |
-
}
|
| 149 |
-
|
| 150 |
-
return result
|
| 151 |
-
|
| 152 |
-
except Exception as e:
|
| 153 |
-
return {
|
| 154 |
-
'image_path': str(image_path),
|
| 155 |
-
'error': str(e)
|
| 156 |
-
}
|
| 157 |
-
|
| 158 |
-
def classify_multiple_images(self, image_paths: List[Union[str, Path]],
|
| 159 |
-
**kwargs) -> List[Dict]:
|
| 160 |
-
"""Classify multiple images and return results."""
|
| 161 |
-
|
| 162 |
-
results = []
|
| 163 |
-
total_images = len(image_paths)
|
| 164 |
-
|
| 165 |
-
print(f"🔄 Processing {total_images} images...")
|
| 166 |
-
|
| 167 |
-
for i, image_path in enumerate(image_paths, 1):
|
| 168 |
-
print(f" Processing {i}/{total_images}: {Path(image_path).name}")
|
| 169 |
-
result = self.classify_single_image(image_path, **kwargs)
|
| 170 |
-
results.append(result)
|
| 171 |
-
|
| 172 |
-
return results
|
| 173 |
-
|
| 174 |
-
def classify_directory(self, directory_path: Union[str, Path],
|
| 175 |
-
**kwargs) -> List[Dict]:
|
| 176 |
-
"""Classify all images in a directory."""
|
| 177 |
-
|
| 178 |
-
directory_path = Path(directory_path)
|
| 179 |
-
|
| 180 |
-
# Find all image files
|
| 181 |
-
image_extensions = {'.jpg', '.jpeg', '.png', '.bmp', '.tiff', '.webp'}
|
| 182 |
-
image_paths = [
|
| 183 |
-
p for p in directory_path.rglob('*')
|
| 184 |
-
if p.suffix.lower() in image_extensions
|
| 185 |
-
]
|
| 186 |
-
|
| 187 |
-
if not image_paths:
|
| 188 |
-
print(f"❌ No images found in {directory_path}")
|
| 189 |
-
return []
|
| 190 |
-
|
| 191 |
-
print(f"📁 Found {len(image_paths)} images in {directory_path}")
|
| 192 |
-
return self.classify_multiple_images(image_paths, **kwargs)
|
| 193 |
-
|
| 194 |
-
def print_results(self, results: Union[Dict, List[Dict]],
|
| 195 |
-
detailed: bool = True):
|
| 196 |
-
"""Print classification results in a nice format."""
|
| 197 |
-
|
| 198 |
-
if isinstance(results, dict):
|
| 199 |
-
results = [results]
|
| 200 |
-
|
| 201 |
-
print(f"\n🔍 CLASSIFICATION RESULTS")
|
| 202 |
-
print("=" * 60)
|
| 203 |
-
|
| 204 |
-
successful_results = [r for r in results if 'error' not in r]
|
| 205 |
-
failed_results = [r for r in results if 'error' in r]
|
| 206 |
-
|
| 207 |
-
# Print successful classifications
|
| 208 |
-
for i, result in enumerate(successful_results, 1):
|
| 209 |
-
print(f"\n📸 Image {i}: {result['image_name']}")
|
| 210 |
-
print(f" Size: {result['image_size'][0]}x{result['image_size'][1]} pixels")
|
| 211 |
-
|
| 212 |
-
# Top prediction
|
| 213 |
-
pred_class = result['predicted_class']
|
| 214 |
-
pred_conf = result['predicted_confidence']
|
| 215 |
-
print(f"\n🎯 TOP PREDICTION:")
|
| 216 |
-
print(f" {pred_class.upper()}: {pred_conf:.1%}")
|
| 217 |
-
|
| 218 |
-
# All scores if detailed
|
| 219 |
-
if detailed and result.get('all_scores'):
|
| 220 |
-
print(f"\n📊 ALL SCORES:")
|
| 221 |
-
for class_name, confidence in result['all_scores'].items():
|
| 222 |
-
# Create progress bar
|
| 223 |
-
bar_length = int(confidence * 40) # Scale to 40 chars
|
| 224 |
-
bar = "█" * bar_length + "░" * (40 - bar_length)
|
| 225 |
-
|
| 226 |
-
print(f" {class_name:>8}: {confidence:.1%} {bar}")
|
| 227 |
-
|
| 228 |
-
print(f" {'-' * 50}")
|
| 229 |
-
|
| 230 |
-
# Print failed classifications
|
| 231 |
-
if failed_results:
|
| 232 |
-
print(f"\n❌ FAILED CLASSIFICATIONS ({len(failed_results)}):")
|
| 233 |
-
for result in failed_results:
|
| 234 |
-
print(f" {result['image_path']}: {result['error']}")
|
| 235 |
-
|
| 236 |
-
# Summary
|
| 237 |
-
if len(successful_results) > 1:
|
| 238 |
-
print(f"\n📈 SUMMARY:")
|
| 239 |
-
print(f" Successfully processed: {len(successful_results)} images")
|
| 240 |
-
print(f" Failed: {len(failed_results)} images")
|
| 241 |
-
|
| 242 |
-
# Class distribution
|
| 243 |
-
class_counts = {}
|
| 244 |
-
for result in successful_results:
|
| 245 |
-
pred_class = result['predicted_class']
|
| 246 |
-
class_counts[pred_class] = class_counts.get(pred_class, 0) + 1
|
| 247 |
-
|
| 248 |
-
print(f"\n📊 CLASS DISTRIBUTION:")
|
| 249 |
-
for class_name, count in sorted(class_counts.items()):
|
| 250 |
-
percentage = (count / len(successful_results)) * 100
|
| 251 |
-
print(f" {class_name:>8}: {count:>3} images ({percentage:.1f}%)")
|
| 252 |
-
|
| 253 |
-
def save_results(self, results: List[Dict], output_file: str):
|
| 254 |
-
"""Save results to JSON file."""
|
| 255 |
-
|
| 256 |
-
try:
|
| 257 |
-
with open(output_file, 'w') as f:
|
| 258 |
-
json.dump(results, f, indent=2, default=str)
|
| 259 |
-
print(f"💾 Results saved to: {output_file}")
|
| 260 |
-
except Exception as e:
|
| 261 |
-
print(f"❌ Error saving results: {e}")
|
| 262 |
|
| 263 |
-
|
| 264 |
-
|
| 265 |
-
|
| 266 |
-
|
| 267 |
-
|
| 268 |
-
|
| 269 |
-
help='HuggingFace model name')
|
| 270 |
-
parser.add_argument('--output', help='Output JSON file for results')
|
| 271 |
-
parser.add_argument('--min-confidence', type=float, default=0.01,
|
| 272 |
-
help='Minimum confidence to display (0.0-1.0)')
|
| 273 |
-
parser.add_argument('--brief', action='store_true',
|
| 274 |
-
help='Show only top prediction')
|
| 275 |
-
parser.add_argument('--batch-size', type=int, default=1,
|
| 276 |
-
help='Batch size for processing (not implemented yet)')
|
| 277 |
-
|
| 278 |
-
args = parser.parse_args()
|
| 279 |
-
|
| 280 |
-
try:
|
| 281 |
-
# Initialize classifier
|
| 282 |
-
classifier = SkincareClassifier(args.model)
|
| 283 |
-
|
| 284 |
-
input_path = Path(args.input)
|
| 285 |
-
|
| 286 |
-
if input_path.is_file():
|
| 287 |
-
# Single image
|
| 288 |
-
result = classifier.classify_single_image(
|
| 289 |
-
input_path,
|
| 290 |
-
show_all_scores=not args.brief,
|
| 291 |
-
min_confidence=args.min_confidence
|
| 292 |
-
)
|
| 293 |
-
classifier.print_results(result, detailed=not args.brief)
|
| 294 |
-
|
| 295 |
-
if args.output:
|
| 296 |
-
classifier.save_results([result], args.output)
|
| 297 |
-
|
| 298 |
-
elif input_path.is_dir():
|
| 299 |
-
# Directory of images
|
| 300 |
-
results = classifier.classify_directory(
|
| 301 |
-
input_path,
|
| 302 |
-
show_all_scores=not args.brief,
|
| 303 |
-
min_confidence=args.min_confidence
|
| 304 |
-
)
|
| 305 |
-
classifier.print_results(results, detailed=not args.brief)
|
| 306 |
-
|
| 307 |
-
if args.output:
|
| 308 |
-
classifier.save_results(results, args.output)
|
| 309 |
-
|
| 310 |
-
else:
|
| 311 |
-
print(f"❌ Error: {input_path} is not a valid file or directory")
|
| 312 |
-
|
| 313 |
-
except Exception as e:
|
| 314 |
-
print(f"❌ Error: {e}")
|
| 315 |
|
| 316 |
-
|
| 317 |
-
# If run directly, you can also use it programmatically
|
| 318 |
-
import sys
|
| 319 |
-
|
| 320 |
-
if len(sys.argv) == 1:
|
| 321 |
-
print("🔬 Skincare Classification")
|
| 322 |
-
print("=" * 40)
|
| 323 |
-
|
| 324 |
-
# Initialize classifier
|
| 325 |
-
classifier = SkincareClassifier('0xnu/skincare-detection')
|
| 326 |
-
|
| 327 |
-
# Example with your image
|
| 328 |
-
image_path = 'joe.jpeg' # Your image
|
| 329 |
-
|
| 330 |
-
if Path(image_path).exists():
|
| 331 |
-
result = classifier.classify_single_image(image_path)
|
| 332 |
-
classifier.print_results(result)
|
| 333 |
-
else:
|
| 334 |
-
print(f"❌ Image not found: {image_path}")
|
| 335 |
-
print("\n💡 Usage examples:")
|
| 336 |
-
print("python skincare.py joe.jpeg")
|
| 337 |
-
print("python skincare.py image_directory/")
|
| 338 |
-
print("python skincare.py joe.jpeg --output results.json")
|
| 339 |
-
else:
|
| 340 |
-
main()
|
| 341 |
```
|
| 342 |
|
| 343 |
-
|
| 344 |
|
| 345 |
- The model performance depends on the quality and diversity of training data
|
| 346 |
- May not generalise well to skincare images significantly different from training distribution
|
| 347 |
- Evaluate model performance on your specific use case before deployment
|
| 348 |
|
| 349 |
-
|
| 350 |
|
| 351 |
-
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
license: apache-2.0
|
| 3 |
+
base_model: google/vit-base-patch16-224-in21k
|
| 4 |
tags:
|
|
|
|
| 5 |
- image-classification
|
| 6 |
+
- computer-vision
|
| 7 |
+
- skincare
|
| 8 |
+
- vision-transformer
|
| 9 |
datasets:
|
| 10 |
- custom
|
| 11 |
metrics:
|
| 12 |
- accuracy
|
| 13 |
- f1
|
| 14 |
+
pipeline_tag: image-classification
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
---
|
| 16 |
|
| 17 |
+
# skincare-detection
|
| 18 |
|
| 19 |
+
## Model Description
|
| 20 |
|
| 21 |
+
This model is a fine-tuned version of [google/vit-base-patch16-224-in21k](https://huggingface.co/google/vit-base-patch16-224-in21k) for skincare image classification.
|
| 22 |
|
| 23 |
+
## Model Performance
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
|
| 25 |
+
- **Accuracy**: N/A
|
| 26 |
+
- **F1 Score**: N/A
|
| 27 |
+
- **Precision**: N/A
|
| 28 |
+
- **Recall**: N/A
|
| 29 |
|
| 30 |
+
## Training Details
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
|
| 32 |
+
### Training Data
|
| 33 |
+
Custom dataset with 1009 training samples
|
| 34 |
|
| 35 |
+
### Training Hyperparameters
|
| 36 |
|
| 37 |
+
- Learning rate: 2e-4
|
| 38 |
+
- Batch size: 32
|
| 39 |
+
- Number of epochs: 12
|
| 40 |
+
- Optimizer: Adam
|
| 41 |
+
- Scheduler: Linear with warmup
|
| 42 |
|
| 43 |
+
### Classes
|
| 44 |
+
Classes: acne, athlete-foot, cellulitis, chickenpox, cutaneous-larva-migrans, eczema, impetigo, nail-fungus, normal, ringworm, rosacea, shingles
|
| 45 |
|
| 46 |
+
## Usage
|
| 47 |
+
|
| 48 |
+
```python
|
| 49 |
from transformers import ViTImageProcessor, ViTForImageClassification
|
| 50 |
from PIL import Image
|
| 51 |
+
import torch
|
| 52 |
+
|
| 53 |
+
# Load model and processor
|
| 54 |
+
processor = ViTImageProcessor.from_pretrained('0xnu/skincare-detection')
|
| 55 |
+
model = ViTForImageClassification.from_pretrained('0xnu/skincare-detection')
|
| 56 |
|
| 57 |
+
# Process image
|
| 58 |
+
image = Image.open('path_to_your_image.jpg')
|
| 59 |
+
inputs = processor(images=image, return_tensors="pt")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
|
| 61 |
+
# Make prediction
|
| 62 |
+
with torch.no_grad():
|
| 63 |
+
outputs = model(**inputs)
|
| 64 |
+
logits = outputs.logits
|
| 65 |
+
predicted_class_id = logits.argmax().item()
|
| 66 |
+
predicted_label = model.config.id2label[predicted_class_id]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
|
| 68 |
+
print(f"Predicted class: {predicted_label}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
```
|
| 70 |
|
| 71 |
+
## Limitations and Bias
|
| 72 |
|
| 73 |
- The model performance depends on the quality and diversity of training data
|
| 74 |
- May not generalise well to skincare images significantly different from training distribution
|
| 75 |
- Evaluate model performance on your specific use case before deployment
|
| 76 |
|
| 77 |
+
## Training Environment
|
| 78 |
|
| 79 |
+
- Framework: Transformers 4.38.2
|
| 80 |
+
- PyTorch: 2.1.2
|
| 81 |
+
- Hardware: GPU/CPU
|
checkpoint-96/config.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"architectures": [
|
| 3 |
+
"ViTForImageClassification"
|
| 4 |
+
],
|
| 5 |
+
"attention_probs_dropout_prob": 0.0,
|
| 6 |
+
"encoder_stride": 16,
|
| 7 |
+
"hidden_act": "gelu",
|
| 8 |
+
"hidden_dropout_prob": 0.0,
|
| 9 |
+
"hidden_size": 768,
|
| 10 |
+
"id2label": {
|
| 11 |
+
"0": "acne",
|
| 12 |
+
"1": "athlete-foot",
|
| 13 |
+
"2": "cellulitis",
|
| 14 |
+
"3": "chickenpox",
|
| 15 |
+
"4": "cutaneous-larva-migrans",
|
| 16 |
+
"5": "eczema",
|
| 17 |
+
"6": "impetigo",
|
| 18 |
+
"7": "nail-fungus",
|
| 19 |
+
"8": "normal",
|
| 20 |
+
"9": "ringworm",
|
| 21 |
+
"10": "rosacea",
|
| 22 |
+
"11": "shingles"
|
| 23 |
+
},
|
| 24 |
+
"image_size": 224,
|
| 25 |
+
"initializer_range": 0.02,
|
| 26 |
+
"intermediate_size": 3072,
|
| 27 |
+
"label2id": {
|
| 28 |
+
"acne": 0,
|
| 29 |
+
"athlete-foot": 1,
|
| 30 |
+
"cellulitis": 2,
|
| 31 |
+
"chickenpox": 3,
|
| 32 |
+
"cutaneous-larva-migrans": 4,
|
| 33 |
+
"eczema": 5,
|
| 34 |
+
"impetigo": 6,
|
| 35 |
+
"nail-fungus": 7,
|
| 36 |
+
"normal": 8,
|
| 37 |
+
"ringworm": 9,
|
| 38 |
+
"rosacea": 10,
|
| 39 |
+
"shingles": 11
|
| 40 |
+
},
|
| 41 |
+
"layer_norm_eps": 1e-12,
|
| 42 |
+
"model_type": "vit",
|
| 43 |
+
"num_attention_heads": 12,
|
| 44 |
+
"num_channels": 3,
|
| 45 |
+
"num_hidden_layers": 12,
|
| 46 |
+
"patch_size": 16,
|
| 47 |
+
"pooler_act": "tanh",
|
| 48 |
+
"pooler_output_size": 768,
|
| 49 |
+
"problem_type": "single_label_classification",
|
| 50 |
+
"qkv_bias": true,
|
| 51 |
+
"torch_dtype": "float32",
|
| 52 |
+
"transformers_version": "4.55.0"
|
| 53 |
+
}
|
checkpoint-96/model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e51135ac7635a9a36723c23064bb400884097037a64fef2c237d15f684f8ac5c
|
| 3 |
+
size 343254736
|
checkpoint-96/optimizer.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:75195dfc056576c97ec408c2e5619d84ca1761708fe0ae84298e8cf2a025ed68
|
| 3 |
+
size 686625163
|
checkpoint-96/rng_state.pth
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:342c1c2c9306c2498166b1198dc92573ed6004340483f7127a523f44dc5357e3
|
| 3 |
+
size 14455
|
checkpoint-96/scheduler.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:0d662548105d154c69cb09b7573114d7306e20a33033e46030546b0ed5239be6
|
| 3 |
+
size 1465
|
checkpoint-96/trainer_state.json
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"best_global_step": 50,
|
| 3 |
+
"best_metric": 0.9785714285714285,
|
| 4 |
+
"best_model_checkpoint": null,
|
| 5 |
+
"epoch": 12.0,
|
| 6 |
+
"eval_steps": 50,
|
| 7 |
+
"global_step": 96,
|
| 8 |
+
"is_hyper_param_search": false,
|
| 9 |
+
"is_local_process_zero": true,
|
| 10 |
+
"is_world_process_zero": true,
|
| 11 |
+
"log_history": [
|
| 12 |
+
{
|
| 13 |
+
"epoch": 1.25,
|
| 14 |
+
"grad_norm": 1.411300778388977,
|
| 15 |
+
"learning_rate": 0.00018,
|
| 16 |
+
"loss": 2.2387,
|
| 17 |
+
"step": 10
|
| 18 |
+
},
|
| 19 |
+
{
|
| 20 |
+
"epoch": 2.5,
|
| 21 |
+
"grad_norm": 1.0807230472564697,
|
| 22 |
+
"learning_rate": 0.00017906976744186048,
|
| 23 |
+
"loss": 1.2121,
|
| 24 |
+
"step": 20
|
| 25 |
+
},
|
| 26 |
+
{
|
| 27 |
+
"epoch": 3.75,
|
| 28 |
+
"grad_norm": 0.6904317736625671,
|
| 29 |
+
"learning_rate": 0.0001558139534883721,
|
| 30 |
+
"loss": 0.5672,
|
| 31 |
+
"step": 30
|
| 32 |
+
},
|
| 33 |
+
{
|
| 34 |
+
"epoch": 5.0,
|
| 35 |
+
"grad_norm": 0.5183396935462952,
|
| 36 |
+
"learning_rate": 0.00013255813953488372,
|
| 37 |
+
"loss": 0.3326,
|
| 38 |
+
"step": 40
|
| 39 |
+
},
|
| 40 |
+
{
|
| 41 |
+
"epoch": 6.25,
|
| 42 |
+
"grad_norm": 0.4176619052886963,
|
| 43 |
+
"learning_rate": 0.00010930232558139534,
|
| 44 |
+
"loss": 0.2472,
|
| 45 |
+
"step": 50
|
| 46 |
+
},
|
| 47 |
+
{
|
| 48 |
+
"epoch": 6.25,
|
| 49 |
+
"eval_accuracy": 0.9785714285714285,
|
| 50 |
+
"eval_f1": 0.9781596849266023,
|
| 51 |
+
"eval_loss": 0.27442124485969543,
|
| 52 |
+
"eval_precision": 0.9790764790764791,
|
| 53 |
+
"eval_recall": 0.9785714285714285,
|
| 54 |
+
"eval_runtime": 8.6568,
|
| 55 |
+
"eval_samples_per_second": 16.172,
|
| 56 |
+
"eval_steps_per_second": 0.578,
|
| 57 |
+
"step": 50
|
| 58 |
+
},
|
| 59 |
+
{
|
| 60 |
+
"epoch": 7.5,
|
| 61 |
+
"grad_norm": 0.3670105040073395,
|
| 62 |
+
"learning_rate": 8.604651162790697e-05,
|
| 63 |
+
"loss": 0.2062,
|
| 64 |
+
"step": 60
|
| 65 |
+
},
|
| 66 |
+
{
|
| 67 |
+
"epoch": 8.75,
|
| 68 |
+
"grad_norm": 0.34629565477371216,
|
| 69 |
+
"learning_rate": 6.27906976744186e-05,
|
| 70 |
+
"loss": 0.1832,
|
| 71 |
+
"step": 70
|
| 72 |
+
},
|
| 73 |
+
{
|
| 74 |
+
"epoch": 10.0,
|
| 75 |
+
"grad_norm": 0.3259499967098236,
|
| 76 |
+
"learning_rate": 3.953488372093023e-05,
|
| 77 |
+
"loss": 0.1699,
|
| 78 |
+
"step": 80
|
| 79 |
+
},
|
| 80 |
+
{
|
| 81 |
+
"epoch": 11.25,
|
| 82 |
+
"grad_norm": 0.3109147548675537,
|
| 83 |
+
"learning_rate": 1.6279069767441862e-05,
|
| 84 |
+
"loss": 0.1625,
|
| 85 |
+
"step": 90
|
| 86 |
+
}
|
| 87 |
+
],
|
| 88 |
+
"logging_steps": 10,
|
| 89 |
+
"max_steps": 96,
|
| 90 |
+
"num_input_tokens_seen": 0,
|
| 91 |
+
"num_train_epochs": 12,
|
| 92 |
+
"save_steps": 100,
|
| 93 |
+
"stateful_callbacks": {
|
| 94 |
+
"EarlyStoppingCallback": {
|
| 95 |
+
"args": {
|
| 96 |
+
"early_stopping_patience": 3,
|
| 97 |
+
"early_stopping_threshold": 0.0
|
| 98 |
+
},
|
| 99 |
+
"attributes": {
|
| 100 |
+
"early_stopping_patience_counter": 0
|
| 101 |
+
}
|
| 102 |
+
},
|
| 103 |
+
"TrainerControl": {
|
| 104 |
+
"args": {
|
| 105 |
+
"should_epoch_stop": false,
|
| 106 |
+
"should_evaluate": false,
|
| 107 |
+
"should_log": false,
|
| 108 |
+
"should_save": true,
|
| 109 |
+
"should_training_stop": true
|
| 110 |
+
},
|
| 111 |
+
"attributes": {}
|
| 112 |
+
}
|
| 113 |
+
},
|
| 114 |
+
"total_flos": 9.383571046956073e+17,
|
| 115 |
+
"train_batch_size": 32,
|
| 116 |
+
"trial_name": null,
|
| 117 |
+
"trial_params": null
|
| 118 |
+
}
|
checkpoint-96/training_args.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:5c1fad4ba54b504a5110180cd6b64009b07e6b350131fe6cf05a4712d39c1b9f
|
| 3 |
+
size 5713
|
config.json
CHANGED
|
@@ -9,18 +9,34 @@
|
|
| 9 |
"hidden_size": 768,
|
| 10 |
"id2label": {
|
| 11 |
"0": "acne",
|
| 12 |
-
"1": "
|
| 13 |
-
"2": "
|
| 14 |
-
"3": "
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
},
|
| 16 |
"image_size": 224,
|
| 17 |
"initializer_range": 0.02,
|
| 18 |
"intermediate_size": 3072,
|
| 19 |
"label2id": {
|
| 20 |
"acne": 0,
|
| 21 |
-
"
|
| 22 |
-
"
|
| 23 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
},
|
| 25 |
"layer_norm_eps": 1e-12,
|
| 26 |
"model_type": "vit",
|
|
|
|
| 9 |
"hidden_size": 768,
|
| 10 |
"id2label": {
|
| 11 |
"0": "acne",
|
| 12 |
+
"1": "athlete-foot",
|
| 13 |
+
"2": "cellulitis",
|
| 14 |
+
"3": "chickenpox",
|
| 15 |
+
"4": "cutaneous-larva-migrans",
|
| 16 |
+
"5": "eczema",
|
| 17 |
+
"6": "impetigo",
|
| 18 |
+
"7": "nail-fungus",
|
| 19 |
+
"8": "normal",
|
| 20 |
+
"9": "ringworm",
|
| 21 |
+
"10": "rosacea",
|
| 22 |
+
"11": "shingles"
|
| 23 |
},
|
| 24 |
"image_size": 224,
|
| 25 |
"initializer_range": 0.02,
|
| 26 |
"intermediate_size": 3072,
|
| 27 |
"label2id": {
|
| 28 |
"acne": 0,
|
| 29 |
+
"athlete-foot": 1,
|
| 30 |
+
"cellulitis": 2,
|
| 31 |
+
"chickenpox": 3,
|
| 32 |
+
"cutaneous-larva-migrans": 4,
|
| 33 |
+
"eczema": 5,
|
| 34 |
+
"impetigo": 6,
|
| 35 |
+
"nail-fungus": 7,
|
| 36 |
+
"normal": 8,
|
| 37 |
+
"ringworm": 9,
|
| 38 |
+
"rosacea": 10,
|
| 39 |
+
"shingles": 11
|
| 40 |
},
|
| 41 |
"layer_norm_eps": 1e-12,
|
| 42 |
"model_type": "vit",
|
model.safetensors
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e51135ac7635a9a36723c23064bb400884097037a64fef2c237d15f684f8ac5c
|
| 3 |
+
size 343254736
|
training_args.bin
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 5713
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:5c1fad4ba54b504a5110180cd6b64009b07e6b350131fe6cf05a4712d39c1b9f
|
| 3 |
size 5713
|
training_results.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
| 1 |
{
|
| 2 |
-
"train_runtime":
|
| 3 |
-
"train_samples_per_second":
|
| 4 |
-
"train_steps_per_second": 0.
|
| 5 |
-
"total_flos":
|
| 6 |
-
"train_loss": 0.
|
| 7 |
"epoch": 12.0
|
| 8 |
}
|
|
|
|
| 1 |
{
|
| 2 |
+
"train_runtime": 1232.5529,
|
| 3 |
+
"train_samples_per_second": 9.824,
|
| 4 |
+
"train_steps_per_second": 0.078,
|
| 5 |
+
"total_flos": 9.383571046956073e+17,
|
| 6 |
+
"train_loss": 0.5641234858582417,
|
| 7 |
"epoch": 12.0
|
| 8 |
}
|