Upload folder using huggingface_hub
Browse files- README.md +81 -3
- checkpoint-24/config.json +37 -0
- checkpoint-24/model.safetensors +3 -0
- checkpoint-24/optimizer.pt +3 -0
- checkpoint-24/rng_state.pth +3 -0
- checkpoint-24/scheduler.pt +3 -0
- checkpoint-24/trainer_state.json +57 -0
- checkpoint-24/training_args.bin +3 -0
- config.json +37 -0
- confusion_matrix.png +0 -0
- model.safetensors +3 -0
- preprocessor_config.json +23 -0
- training_args.bin +3 -0
- training_results.json +8 -0
README.md
CHANGED
|
@@ -1,3 +1,81 @@
|
|
| 1 |
-
---
|
| 2 |
-
license: apache-2.0
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 200 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, eczema, normal, rosacea
|
| 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-24/config.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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": "eczema",
|
| 13 |
+
"2": "normal",
|
| 14 |
+
"3": "rosacea"
|
| 15 |
+
},
|
| 16 |
+
"image_size": 224,
|
| 17 |
+
"initializer_range": 0.02,
|
| 18 |
+
"intermediate_size": 3072,
|
| 19 |
+
"label2id": {
|
| 20 |
+
"acne": 0,
|
| 21 |
+
"eczema": 1,
|
| 22 |
+
"normal": 2,
|
| 23 |
+
"rosacea": 3
|
| 24 |
+
},
|
| 25 |
+
"layer_norm_eps": 1e-12,
|
| 26 |
+
"model_type": "vit",
|
| 27 |
+
"num_attention_heads": 12,
|
| 28 |
+
"num_channels": 3,
|
| 29 |
+
"num_hidden_layers": 12,
|
| 30 |
+
"patch_size": 16,
|
| 31 |
+
"pooler_act": "tanh",
|
| 32 |
+
"pooler_output_size": 768,
|
| 33 |
+
"problem_type": "single_label_classification",
|
| 34 |
+
"qkv_bias": true,
|
| 35 |
+
"torch_dtype": "float32",
|
| 36 |
+
"transformers_version": "4.55.0"
|
| 37 |
+
}
|
checkpoint-24/model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:5823126bb2dcf845e0d5b5a9ef85febfef7bd6461e0fcda29ed0adfee64c79ef
|
| 3 |
+
size 343230128
|
checkpoint-24/optimizer.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ca47e9e34386883c7e0568a3b50479626f4ad9ee2a0d96efa8e34d04ca1537d4
|
| 3 |
+
size 686576011
|
checkpoint-24/rng_state.pth
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e38e4bded6fa666a78b369223010c84f8eafdd4ce4069224aa6f2854b4222440
|
| 3 |
+
size 14455
|
checkpoint-24/scheduler.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:02366c6584197b626fb76cdc3670f43abab526eee56710041f674a166cf81a4b
|
| 3 |
+
size 1465
|
checkpoint-24/trainer_state.json
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"best_global_step": null,
|
| 3 |
+
"best_metric": null,
|
| 4 |
+
"best_model_checkpoint": null,
|
| 5 |
+
"epoch": 12.0,
|
| 6 |
+
"eval_steps": 50,
|
| 7 |
+
"global_step": 24,
|
| 8 |
+
"is_hyper_param_search": false,
|
| 9 |
+
"is_local_process_zero": true,
|
| 10 |
+
"is_world_process_zero": true,
|
| 11 |
+
"log_history": [
|
| 12 |
+
{
|
| 13 |
+
"epoch": 5.0,
|
| 14 |
+
"grad_norm": 0.9926398992538452,
|
| 15 |
+
"learning_rate": 0.00014285714285714287,
|
| 16 |
+
"loss": 0.8337,
|
| 17 |
+
"step": 10
|
| 18 |
+
},
|
| 19 |
+
{
|
| 20 |
+
"epoch": 10.0,
|
| 21 |
+
"grad_norm": 0.41569486260414124,
|
| 22 |
+
"learning_rate": 4.761904761904762e-05,
|
| 23 |
+
"loss": 0.1567,
|
| 24 |
+
"step": 20
|
| 25 |
+
}
|
| 26 |
+
],
|
| 27 |
+
"logging_steps": 10,
|
| 28 |
+
"max_steps": 24,
|
| 29 |
+
"num_input_tokens_seen": 0,
|
| 30 |
+
"num_train_epochs": 12,
|
| 31 |
+
"save_steps": 100,
|
| 32 |
+
"stateful_callbacks": {
|
| 33 |
+
"EarlyStoppingCallback": {
|
| 34 |
+
"args": {
|
| 35 |
+
"early_stopping_patience": 3,
|
| 36 |
+
"early_stopping_threshold": 0.0
|
| 37 |
+
},
|
| 38 |
+
"attributes": {
|
| 39 |
+
"early_stopping_patience_counter": 0
|
| 40 |
+
}
|
| 41 |
+
},
|
| 42 |
+
"TrainerControl": {
|
| 43 |
+
"args": {
|
| 44 |
+
"should_epoch_stop": false,
|
| 45 |
+
"should_evaluate": false,
|
| 46 |
+
"should_log": false,
|
| 47 |
+
"should_save": true,
|
| 48 |
+
"should_training_stop": true
|
| 49 |
+
},
|
| 50 |
+
"attributes": {}
|
| 51 |
+
}
|
| 52 |
+
},
|
| 53 |
+
"total_flos": 1.859841088487424e+17,
|
| 54 |
+
"train_batch_size": 32,
|
| 55 |
+
"trial_name": null,
|
| 56 |
+
"trial_params": null
|
| 57 |
+
}
|
checkpoint-24/training_args.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:4aed3420e473a8800e471f723bc84c39200216f80b1882c067e8e9691f167105
|
| 3 |
+
size 5713
|
config.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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": "eczema",
|
| 13 |
+
"2": "normal",
|
| 14 |
+
"3": "rosacea"
|
| 15 |
+
},
|
| 16 |
+
"image_size": 224,
|
| 17 |
+
"initializer_range": 0.02,
|
| 18 |
+
"intermediate_size": 3072,
|
| 19 |
+
"label2id": {
|
| 20 |
+
"acne": 0,
|
| 21 |
+
"eczema": 1,
|
| 22 |
+
"normal": 2,
|
| 23 |
+
"rosacea": 3
|
| 24 |
+
},
|
| 25 |
+
"layer_norm_eps": 1e-12,
|
| 26 |
+
"model_type": "vit",
|
| 27 |
+
"num_attention_heads": 12,
|
| 28 |
+
"num_channels": 3,
|
| 29 |
+
"num_hidden_layers": 12,
|
| 30 |
+
"patch_size": 16,
|
| 31 |
+
"pooler_act": "tanh",
|
| 32 |
+
"pooler_output_size": 768,
|
| 33 |
+
"problem_type": "single_label_classification",
|
| 34 |
+
"qkv_bias": true,
|
| 35 |
+
"torch_dtype": "float32",
|
| 36 |
+
"transformers_version": "4.55.0"
|
| 37 |
+
}
|
confusion_matrix.png
ADDED
|
model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:5823126bb2dcf845e0d5b5a9ef85febfef7bd6461e0fcda29ed0adfee64c79ef
|
| 3 |
+
size 343230128
|
preprocessor_config.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"do_convert_rgb": null,
|
| 3 |
+
"do_normalize": true,
|
| 4 |
+
"do_rescale": true,
|
| 5 |
+
"do_resize": true,
|
| 6 |
+
"image_mean": [
|
| 7 |
+
0.5,
|
| 8 |
+
0.5,
|
| 9 |
+
0.5
|
| 10 |
+
],
|
| 11 |
+
"image_processor_type": "ViTImageProcessor",
|
| 12 |
+
"image_std": [
|
| 13 |
+
0.5,
|
| 14 |
+
0.5,
|
| 15 |
+
0.5
|
| 16 |
+
],
|
| 17 |
+
"resample": 2,
|
| 18 |
+
"rescale_factor": 0.00392156862745098,
|
| 19 |
+
"size": {
|
| 20 |
+
"height": 224,
|
| 21 |
+
"width": 224
|
| 22 |
+
}
|
| 23 |
+
}
|
training_args.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:4aed3420e473a8800e471f723bc84c39200216f80b1882c067e8e9691f167105
|
| 3 |
+
size 5713
|
training_results.json
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"train_runtime": 211.1149,
|
| 3 |
+
"train_samples_per_second": 11.368,
|
| 4 |
+
"train_steps_per_second": 0.114,
|
| 5 |
+
"total_flos": 1.859841088487424e+17,
|
| 6 |
+
"train_loss": 0.4300013507405917,
|
| 7 |
+
"epoch": 12.0
|
| 8 |
+
}
|