prithivMLmods commited on
Commit
cbb5e23
·
verified ·
1 Parent(s): 7b7def8

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +78 -0
README.md CHANGED
@@ -18,6 +18,10 @@ tags:
18
  ---
19
  ![AAAAAAAA.png](https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/hWrRztXlZ0j87BEajVNtA.png)
20
 
 
 
 
 
21
  ```py
22
  Classification Report:
23
  precision recall f1-score support
@@ -34,3 +38,77 @@ Middle Age 45-64 0.9059 0.8317 0.8672 3785
34
  ```
35
 
36
  ![download (1).png](https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/rgfZs4duAb09vRvFmO3Qy.png)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
  ---
19
  ![AAAAAAAA.png](https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/hWrRztXlZ0j87BEajVNtA.png)
20
 
21
+ # **Age-Classification-SigLIP2**
22
+
23
+ > **Age-Classification-SigLIP2** 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 predict the age group of a person from an image using the **SiglipForImageClassification** architecture.
24
+
25
  ```py
26
  Classification Report:
27
  precision recall f1-score support
 
38
  ```
39
 
40
  ![download (1).png](https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/rgfZs4duAb09vRvFmO3Qy.png)
41
+
42
+
43
+
44
+ The model categorizes images into five age groups:
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
+ # **Run with Transformers🤗**
52
+
53
+ ```python
54
+ !pip install -q transformers torch pillow gradio
55
+ ```
56
+
57
+ ```python
58
+ import gradio as gr
59
+ from transformers import AutoImageProcessor
60
+ from transformers import SiglipForImageClassification
61
+ from transformers.image_utils import load_image
62
+ from PIL import Image
63
+ import torch
64
+
65
+ # Load model and processor
66
+ model_name = "prithivMLmods/Age-Classification-SigLIP2"
67
+ model = SiglipForImageClassification.from_pretrained(model_name)
68
+ processor = AutoImageProcessor.from_pretrained(model_name)
69
+
70
+ def age_classification(image):
71
+ """Predicts the age group of a person from an image."""
72
+ image = Image.fromarray(image).convert("RGB")
73
+ inputs = processor(images=image, return_tensors="pt")
74
+
75
+ with torch.no_grad():
76
+ outputs = model(**inputs)
77
+ logits = outputs.logits
78
+ probs = torch.nn.functional.softmax(logits, dim=1).squeeze().tolist()
79
+
80
+ labels = {
81
+ "0": "Child 0-12",
82
+ "1": "Teenager 13-20",
83
+ "2": "Adult 21-44",
84
+ "3": "Middle Age 45-64",
85
+ "4": "Aged 65+"
86
+ }
87
+ predictions = {labels[str(i)]: round(probs[i], 3) for i in range(len(probs))}
88
+
89
+ return predictions
90
+
91
+ # Create Gradio interface
92
+ iface = gr.Interface(
93
+ fn=age_classification,
94
+ inputs=gr.Image(type="numpy"),
95
+ outputs=gr.Label(label="Prediction Scores"),
96
+ title="Age Group Classification",
97
+ description="Upload an image to predict the person's age group."
98
+ )
99
+
100
+ # Launch the app
101
+ if __name__ == "__main__":
102
+ iface.launch()
103
+ ```
104
+
105
+
106
+ # **Intended Use:**
107
+
108
+ The **Age-Classification-SigLIP2** model is designed to classify images into five age categories. Potential use cases include:
109
+
110
+ - **Demographic Analysis:** Helping businesses and researchers analyze age distribution.
111
+ - **Health & Fitness Applications:** Assisting in age-based health recommendations.
112
+ - **Security & Access Control:** Implementing age verification in digital systems.
113
+ - **Retail & Marketing:** Enhancing personalized customer experiences.
114
+ - **Forensics & Surveillance:** Aiding in age estimation for security purposes.