prithivMLmods commited on
Commit
ceb5703
Β·
verified Β·
1 Parent(s): 2c8fbc2

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +110 -0
README.md CHANGED
@@ -2,8 +2,28 @@
2
  license: apache-2.0
3
  datasets:
4
  - prithivMLmods/Face-Age-10K
 
 
 
 
 
 
 
 
 
 
5
  ---
6
 
 
 
 
 
 
 
 
 
 
 
7
  ```py
8
  Classification Report:
9
  precision recall f1-score support
@@ -23,3 +43,93 @@ weighted avg 0.8226 0.8225 0.8223 9165
23
  ```
24
 
25
  ![download (1).png](https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/E_8ykSA-ZqEK0_Jtch5dD.png)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  license: apache-2.0
3
  datasets:
4
  - prithivMLmods/Face-Age-10K
5
+ language:
6
+ - en
7
+ base_model:
8
+ - google/siglip2-base-patch16-512
9
+ pipeline_tag: image-classification
10
+ library_name: transformers
11
+ tags:
12
+ - age-detection
13
+ - SigLIP2
14
+ - biology
15
  ---
16
 
17
+ ![467.png](https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/LA6do4hgVi-zNarLEhVGR.png)
18
+
19
+ # facial-age-detection
20
+
21
+ > facial-age-detection is a vision-language encoder model fine-tuned from `google/siglip2-base-patch16-512` for **multi-class image classification**. It is trained to detect and classify human faces into **age groups** ranging from early childhood to elderly adults. The model uses the `SiglipForImageClassification` architecture.
22
+
23
+ > \[!note]
24
+ > SigLIP 2: Multilingual Vision-Language Encoders with Improved Semantic Understanding, Localization, and Dense Features
25
+ > [https://arxiv.org/pdf/2502.14786](https://arxiv.org/pdf/2502.14786)
26
+
27
  ```py
28
  Classification Report:
29
  precision recall f1-score support
 
43
  ```
44
 
45
  ![download (1).png](https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/E_8ykSA-ZqEK0_Jtch5dD.png)
46
+
47
+ ---
48
+
49
+ ## Label Space: 8 Classes
50
+
51
+ ```
52
+ Class 0: age 01-10
53
+ Class 1: age 11-20
54
+ Class 2: age 21-30
55
+ Class 3: age 31-40
56
+ Class 4: age 41-55
57
+ Class 5: age 56-65
58
+ Class 6: age 66-80
59
+ Class 7: age 80 +
60
+ ```
61
+
62
+ ---
63
+
64
+ ## Install Dependencies
65
+
66
+ ```bash
67
+ pip install -q transformers torch pillow gradio hf_xet
68
+ ```
69
+
70
+ ---
71
+
72
+ ## Inference Code
73
+
74
+ ```python
75
+ import gradio as gr
76
+ from transformers import AutoImageProcessor, SiglipForImageClassification
77
+ from PIL import Image
78
+ import torch
79
+
80
+ # Load model and processor
81
+ model_name = "prithivMLmods/facial-age-detection" # Update with actual model name on Hugging Face
82
+ model = SiglipForImageClassification.from_pretrained(model_name)
83
+ processor = AutoImageProcessor.from_pretrained(model_name)
84
+
85
+ # Updated label mapping
86
+ id2label = {
87
+ "0": "age 01-10",
88
+ "1": "age 11-20",
89
+ "2": "age 21-30",
90
+ "3": "age 31-40",
91
+ "4": "age 41-55",
92
+ "5": "age 56-65",
93
+ "6": "age 66-80",
94
+ "7": "age 80 +"
95
+ }
96
+
97
+ def classify_image(image):
98
+ image = Image.fromarray(image).convert("RGB")
99
+ inputs = processor(images=image, return_tensors="pt")
100
+
101
+ with torch.no_grad():
102
+ outputs = model(**inputs)
103
+ logits = outputs.logits
104
+ probs = torch.nn.functional.softmax(logits, dim=1).squeeze().tolist()
105
+
106
+ prediction = {
107
+ id2label[str(i)]: round(probs[i], 3) for i in range(len(probs))
108
+ }
109
+
110
+ return prediction
111
+
112
+ # Gradio Interface
113
+ iface = gr.Interface(
114
+ fn=classify_image,
115
+ inputs=gr.Image(type="numpy"),
116
+ outputs=gr.Label(num_top_classes=8, label="Age Group Classification"),
117
+ title="Facial Age Detection",
118
+ description="Upload a face image to estimate the age group: 01–10, 11–20, 21–30, 31–40, 41–55, 56–65, 66–80, or 80+."
119
+ )
120
+
121
+ if __name__ == "__main__":
122
+ iface.launch()
123
+ ```
124
+
125
+ ---
126
+
127
+ ## Intended Use
128
+
129
+ `facial-age-detection` is designed for:
130
+
131
+ * **Demographic Analytics** – Estimate age distributions in image datasets for research and commercial analysis.
132
+ * **Access Control & Verification** – Enforce age-based access in digital or physical environments.
133
+ * **Retail & Marketing** – Understand customer demographics in retail spaces through camera-based analytics.
134
+ * **Surveillance & Security** – Enhance people classification systems by integrating age detection.
135
+ * **Human-Computer Interaction** – Adapt experiences and interfaces based on user age.