Update README.md
Browse files
README.md
CHANGED
@@ -1,6 +1,10 @@
|
|
1 |
---
|
2 |
license: apache-2.0
|
3 |
---
|
|
|
|
|
|
|
|
|
4 |
```py
|
5 |
Accuracy: 0.9720
|
6 |
F1 Score: 0.9720
|
@@ -17,3 +21,64 @@ weighted avg 0.9721 0.9720 0.9720 5000
|
|
17 |
```
|
18 |
|
19 |

|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
license: apache-2.0
|
3 |
---
|
4 |
+
# **Gender-Classifier-Mini**
|
5 |
+
|
6 |
+
> **Gender-Classifier-Mini** is an image classification vision-language encoder model fine-tuned from **google/siglip2-base-patch16-224** for a single-label classification task. It is designed to classify images based on gender using the **SiglipForImageClassification** architecture.
|
7 |
+
|
8 |
```py
|
9 |
Accuracy: 0.9720
|
10 |
F1 Score: 0.9720
|
|
|
21 |
```
|
22 |
|
23 |

|
24 |
+
|
25 |
+
The model categorizes images into two classes:
|
26 |
+
- **Class 0:** "Female ♀"
|
27 |
+
- **Class 1:** "Male ♂"
|
28 |
+
|
29 |
+
# **Run with Transformers🤗**
|
30 |
+
|
31 |
+
```python
|
32 |
+
!pip install -q transformers torch pillow gradio
|
33 |
+
```
|
34 |
+
|
35 |
+
```python
|
36 |
+
import gradio as gr
|
37 |
+
from transformers import AutoImageProcessor
|
38 |
+
from transformers import SiglipForImageClassification
|
39 |
+
from transformers.image_utils import load_image
|
40 |
+
from PIL import Image
|
41 |
+
import torch
|
42 |
+
|
43 |
+
# Load model and processor
|
44 |
+
model_name = "prithivMLmods/Gender-Classifier-Mini"
|
45 |
+
model = SiglipForImageClassification.from_pretrained(model_name)
|
46 |
+
processor = AutoImageProcessor.from_pretrained(model_name)
|
47 |
+
|
48 |
+
def gender_classification(image):
|
49 |
+
"""Predicts gender category for an image."""
|
50 |
+
image = Image.fromarray(image).convert("RGB")
|
51 |
+
inputs = processor(images=image, return_tensors="pt")
|
52 |
+
|
53 |
+
with torch.no_grad():
|
54 |
+
outputs = model(**inputs)
|
55 |
+
logits = outputs.logits
|
56 |
+
probs = torch.nn.functional.softmax(logits, dim=1).squeeze().tolist()
|
57 |
+
|
58 |
+
labels = {"0": "Female ♀", "1": "Male ♂"}
|
59 |
+
predictions = {labels[str(i)]: round(probs[i], 3) for i in range(len(probs))}
|
60 |
+
|
61 |
+
return predictions
|
62 |
+
|
63 |
+
# Create Gradio interface
|
64 |
+
iface = gr.Interface(
|
65 |
+
fn=gender_classification,
|
66 |
+
inputs=gr.Image(type="numpy"),
|
67 |
+
outputs=gr.Label(label="Prediction Scores"),
|
68 |
+
title="Gender Classification",
|
69 |
+
description="Upload an image to classify its gender."
|
70 |
+
)
|
71 |
+
|
72 |
+
# Launch the app
|
73 |
+
if __name__ == "__main__":
|
74 |
+
iface.launch()
|
75 |
+
```
|
76 |
+
|
77 |
+
# **Intended Use:**
|
78 |
+
|
79 |
+
The **Gender-Classifier-Mini** model is designed to classify images into gender categories. Potential use cases include:
|
80 |
+
|
81 |
+
- **Demographic Analysis:** Assisting in understanding gender distribution in datasets.
|
82 |
+
- **Face Recognition Systems:** Enhancing identity verification processes.
|
83 |
+
- **Marketing & Advertising:** Personalizing content based on demographic insights.
|
84 |
+
- **Healthcare & Research:** Supporting gender-based analysis in medical imaging.
|