Update README.md
Browse files
README.md
CHANGED
|
@@ -6,6 +6,7 @@ tags:
|
|
| 6 |
- generated_from_trainer
|
| 7 |
datasets:
|
| 8 |
- imagefolder
|
|
|
|
| 9 |
model-index:
|
| 10 |
- name: emotion_classification
|
| 11 |
results: []
|
|
@@ -16,19 +17,69 @@ should probably proofread and complete it, then remove this comment. -->
|
|
| 16 |
|
| 17 |
# emotion_classification
|
| 18 |
|
| 19 |
-
This model is a fine-tuned version of [google/paligemma-3b-pt-224](https://huggingface.co/google/paligemma-3b-pt-224) on the
|
| 20 |
|
| 21 |
-
## Model description
|
| 22 |
-
|
| 23 |
-
More information needed
|
| 24 |
|
| 25 |
## Intended uses & limitations
|
| 26 |
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
|
| 33 |
## Training procedure
|
| 34 |
|
|
@@ -47,7 +98,16 @@ The following hyperparameters were used during training:
|
|
| 47 |
- num_epochs: 5
|
| 48 |
|
| 49 |
### Training results
|
| 50 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
|
| 52 |
|
| 53 |
### Framework versions
|
|
|
|
| 6 |
- generated_from_trainer
|
| 7 |
datasets:
|
| 8 |
- imagefolder
|
| 9 |
+
- FastJobs/Visual_Emotional_Analysis
|
| 10 |
model-index:
|
| 11 |
- name: emotion_classification
|
| 12 |
results: []
|
|
|
|
| 17 |
|
| 18 |
# emotion_classification
|
| 19 |
|
| 20 |
+
This model is a fine-tuned version of [google/paligemma-3b-pt-224](https://huggingface.co/google/paligemma-3b-pt-224) on the [FastJobs/Visual_Emotional_Analysis](https://huggingface.co/datasets/FastJobs/Visual_Emotional_Analysis) dataset.
|
| 21 |
|
|
|
|
|
|
|
|
|
|
| 22 |
|
| 23 |
## Intended uses & limitations
|
| 24 |
|
| 25 |
+
### Intended Uses
|
| 26 |
+
- Emotion classification from visual inputs (images).
|
| 27 |
+
|
| 28 |
+
### Limitations
|
| 29 |
+
- May reflect biases from the training dataset.
|
| 30 |
+
- Performance may degrade in domains outside the training data.
|
| 31 |
+
- Not suitable for critical or sensitive decision-making tasks.
|
| 32 |
+
|
| 33 |
+
## How to use this model
|
| 34 |
+
```python
|
| 35 |
+
from transformers import (PaliGemmaProcessor,PaliGemmaForConditionalGeneration,)
|
| 36 |
+
from transformers.image_utils import load_image
|
| 37 |
+
import torch
|
| 38 |
+
from transformers import BitsAndBytesConfig
|
| 39 |
+
from peft import get_peft_model
|
| 40 |
+
from huggingface_hub import login
|
| 41 |
+
from PIL import Image
|
| 42 |
+
login(api_key)
|
| 43 |
+
|
| 44 |
+
device = "cuda" if torch.cuda.is_available() else "CPU"
|
| 45 |
+
|
| 46 |
+
bnb_config = BitsAndBytesConfig(
|
| 47 |
+
load_in_4bit=True,
|
| 48 |
+
bnb_4bit_quant_type="nf4",
|
| 49 |
+
bnb_4bit_compute_type=torch.bfloat16
|
| 50 |
+
)
|
| 51 |
+
|
| 52 |
+
# Load base model
|
| 53 |
+
model_id = "google/paligemma-3b-pt-224"
|
| 54 |
+
model = PaliGemmaForConditionalGeneration.from_pretrained(model_id, quantization_config=bnb_config, device_map="auto")
|
| 55 |
+
processor = PaliGemmaProcessor.from_pretrained(model_id)
|
| 56 |
+
|
| 57 |
+
# Load adapter
|
| 58 |
+
adapter_path = "digo-prayudha/emotion_classification"
|
| 59 |
+
model = PeftModel.from_pretrained(model, adapter_path)
|
| 60 |
+
|
| 61 |
+
image = Image.open("image.jpg").convert("RGB")
|
| 62 |
+
|
| 63 |
+
prompt = (
|
| 64 |
+
"Classify the emotion expressed in this image."
|
| 65 |
+
)
|
| 66 |
+
|
| 67 |
+
inputs = processor(
|
| 68 |
+
text=prompt,
|
| 69 |
+
images=image,
|
| 70 |
+
return_tensors="pt",
|
| 71 |
+
padding="longest",
|
| 72 |
+
tokenize_newline_separately=False
|
| 73 |
+
).to(model.device)
|
| 74 |
+
|
| 75 |
+
model.eval()
|
| 76 |
+
with torch.no_grad():
|
| 77 |
+
outputs = model.generate(**inputs)
|
| 78 |
+
|
| 79 |
+
decoded_output = processor.decode(outputs[0], skip_special_tokens=True)
|
| 80 |
+
|
| 81 |
+
print("Predicted Emotion:", decoded_output)
|
| 82 |
+
```
|
| 83 |
|
| 84 |
## Training procedure
|
| 85 |
|
|
|
|
| 98 |
- num_epochs: 5
|
| 99 |
|
| 100 |
### Training results
|
| 101 |
+
| Step | Validation Loss |
|
| 102 |
+
|:----:|:---------------:|
|
| 103 |
+
| 100 | 2.684700 |
|
| 104 |
+
| 200 | 1.282700 |
|
| 105 |
+
| 300 | 1.085600 |
|
| 106 |
+
| 400 | 0.984500 |
|
| 107 |
+
| 500 | 0.861300 |
|
| 108 |
+
| 600 | 0.822900 |
|
| 109 |
+
| 700 | 0.807100 |
|
| 110 |
+
| 800 | 0.753300 |
|
| 111 |
|
| 112 |
|
| 113 |
### Framework versions
|