prithivMLmods commited on
Commit
1c26a44
Β·
verified Β·
1 Parent(s): 756209a

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +103 -1
README.md CHANGED
@@ -1,7 +1,25 @@
1
  ---
2
  license: apache-2.0
 
 
 
 
 
 
 
3
  ---
4
 
 
 
 
 
 
 
 
 
 
 
 
5
  ```py
6
  Classification Report:
7
  precision recall f1-score support
@@ -17,4 +35,88 @@ Middle Age 45-64 0.8532 0.7400 0.7926 3785
17
  weighted avg 0.8545 0.8583 0.8510 19016
18
  ```
19
 
20
- ![download (1).png](https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/W26dIY52YctE7r02CQL90.png)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: apache-2.0
3
+ datasets:
4
+ - prithivMLmods/Age-Classification-Set
5
+ language:
6
+ - en
7
+ base_model:
8
+ - google/siglip2-base-patch16-512
9
+ library_name: transformers
10
  ---
11
 
12
+ ![3.png](https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/oN-EYfwR1vvdgHkVKAOKP.png)
13
+
14
+ # open-age-detection
15
+
16
+ > `open-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 classify the estimated age group of a person from an image. The model uses the `SiglipForImageClassification` architecture.
17
+
18
+ > \[!note]
19
+ > *SigLIP 2: Multilingual Vision-Language Encoders with Improved Semantic Understanding, Localization, and Dense Features*
20
+ > [https://arxiv.org/pdf/2502.14786](https://arxiv.org/pdf/2502.14786)
21
+
22
+
23
  ```py
24
  Classification Report:
25
  precision recall f1-score support
 
35
  weighted avg 0.8545 0.8583 0.8510 19016
36
  ```
37
 
38
+ ![download (1).png](https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/W26dIY52YctE7r02CQL90.png)
39
+
40
+ ---
41
+
42
+ ## Label Space: 5 Age Groups
43
+
44
+ ```
45
+ Class 0: Child 0–12
46
+ Class 1: Teenager 13–20
47
+ Class 2: Adult 21–44
48
+ Class 3: Middle Age 45–64
49
+ Class 4: Aged 65+
50
+ ```
51
+
52
+ ---
53
+
54
+ ## Install Dependencies
55
+
56
+ ```bash
57
+ pip install -q transformers torch pillow gradio hf_xet
58
+ ```
59
+
60
+ ---
61
+
62
+ ## Inference Code
63
+
64
+ ```python
65
+ import gradio as gr
66
+ from transformers import AutoImageProcessor, SiglipForImageClassification
67
+ from PIL import Image
68
+ import torch
69
+
70
+ # Load model and processor
71
+ model_name = "prithivMLmods/open-age-detection" # Updated model name
72
+ model = SiglipForImageClassification.from_pretrained(model_name)
73
+ processor = AutoImageProcessor.from_pretrained(model_name)
74
+
75
+ # Updated label mapping
76
+ id2label = {
77
+ "0": "Child 0-12",
78
+ "1": "Teenager 13-20",
79
+ "2": "Adult 21-44",
80
+ "3": "Middle Age 45-64",
81
+ "4": "Aged 65+"
82
+ }
83
+
84
+ def classify_image(image):
85
+ image = Image.fromarray(image).convert("RGB")
86
+ inputs = processor(images=image, return_tensors="pt")
87
+
88
+ with torch.no_grad():
89
+ outputs = model(**inputs)
90
+ logits = outputs.logits
91
+ probs = torch.nn.functional.softmax(logits, dim=1).squeeze().tolist()
92
+
93
+ prediction = {
94
+ id2label[str(i)]: round(probs[i], 3) for i in range(len(probs))
95
+ }
96
+
97
+ return prediction
98
+
99
+ # Gradio Interface
100
+ iface = gr.Interface(
101
+ fn=classify_image,
102
+ inputs=gr.Image(type="numpy"),
103
+ outputs=gr.Label(num_top_classes=5, label="Age Group Detection"),
104
+ title="open-age-detection",
105
+ description="Upload a facial image to estimate the age group: Child, Teenager, Adult, Middle Age, or Aged."
106
+ )
107
+
108
+ if __name__ == "__main__":
109
+ iface.launch()
110
+ ```
111
+
112
+ ---
113
+
114
+ ## Intended Use
115
+
116
+ `open-age-detection` is designed for:
117
+
118
+ * **Demographic Analysis** – Estimate age groups for statistical or analytical applications.
119
+ * **Smart Personalization** – Age-based content or product recommendation.
120
+ * **Access Control** – Assist systems requiring age verification.
121
+ * **Social Research** – Study age-related trends in image datasets.
122
+ * **Surveillance and Security** – Profile age ranges in monitored environments.