prithivMLmods commited on
Commit
3cce231
·
verified ·
1 Parent(s): dab6b73

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +77 -0
README.md CHANGED
@@ -18,6 +18,9 @@ tags:
18
  - Female
19
  - SigLIP2
20
  ---
 
 
 
21
 
22
  ```py
23
  Classification Report:
@@ -32,3 +35,77 @@ female portrait 0.9754 0.9656 0.9705 1600
32
  ```
33
 
34
  ![download.png](https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/Hl1qDGrIIZyiSOzOX8K8t.png)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
  - Female
19
  - SigLIP2
20
  ---
21
+ # **Realistic-Gender-Classification**
22
+
23
+ > **Realistic-Gender-Classification** is a binary image classification model based on `google/siglip2-base-patch16-224`, designed to classify **gender** from realistic human portrait images. It can be used in **demographic analysis**, **personalization systems**, and **automated tagging** in large-scale image datasets.
24
 
25
  ```py
26
  Classification Report:
 
35
  ```
36
 
37
  ![download.png](https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/Hl1qDGrIIZyiSOzOX8K8t.png)
38
+
39
+ ---
40
+
41
+ ## **Label Classes**
42
+
43
+ The model distinguishes between the following portrait gender categories:
44
+
45
+ ```
46
+ 0: female portrait
47
+ 1: male portrait
48
+ ```
49
+
50
+ ---
51
+
52
+ ## **Installation**
53
+
54
+ ```bash
55
+ pip install transformers torch pillow gradio
56
+ ```
57
+
58
+ ---
59
+
60
+ ## **Example Inference Code**
61
+
62
+ ```python
63
+ import gradio as gr
64
+ from transformers import AutoImageProcessor, SiglipForImageClassification
65
+ from PIL import Image
66
+ import torch
67
+
68
+ # Load model and processor
69
+ model_name = "prithivMLmods/Realistic-Gender-Classification"
70
+ model = SiglipForImageClassification.from_pretrained(model_name)
71
+ processor = AutoImageProcessor.from_pretrained(model_name)
72
+
73
+ # ID to label mapping
74
+ id2label = {
75
+ "0": "female portrait",
76
+ "1": "male portrait"
77
+ }
78
+
79
+ def classify_gender(image):
80
+ image = Image.fromarray(image).convert("RGB")
81
+ inputs = processor(images=image, return_tensors="pt")
82
+
83
+ with torch.no_grad():
84
+ outputs = model(**inputs)
85
+ logits = outputs.logits
86
+ probs = torch.nn.functional.softmax(logits, dim=1).squeeze().tolist()
87
+
88
+ prediction = {id2label[str(i)]: round(probs[i], 3) for i in range(len(probs))}
89
+ return prediction
90
+
91
+ # Gradio Interface
92
+ iface = gr.Interface(
93
+ fn=classify_gender,
94
+ inputs=gr.Image(type="numpy"),
95
+ outputs=gr.Label(num_top_classes=2, label="Gender Classification"),
96
+ title="Realistic-Gender-Classification",
97
+ description="Upload a realistic portrait image to classify it as 'female portrait' or 'male portrait'."
98
+ )
99
+
100
+ if __name__ == "__main__":
101
+ iface.launch()
102
+ ```
103
+
104
+ ---
105
+
106
+ ## **Applications**
107
+
108
+ * **Demographic Insights in Visual Data**
109
+ * **Dataset Curation & Tagging**
110
+ * **Media Analytics**
111
+ * **Audience Profiling for Marketing**