Sharris commited on
Commit
7ce865c
Β·
verified Β·
1 Parent(s): 288f547

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +339 -97
README.md CHANGED
@@ -1,246 +1,488 @@
1
- ------
2
 
3
- language: enlanguage: en
4
 
5
- license: mitlicense: mit
6
 
7
- library_name: tensorflowlibrary_name: tensorflow
8
 
9
- tags:tags:
10
 
11
- - computer-vision- computer-vision
12
 
13
- - image-classification- image-classification
14
 
15
- - age-estimation- age-estimation
16
 
17
- - face-analysis- face-analysis
18
 
19
- - resnet50v2- resnet50v2
20
 
21
- - tensorflow- tensorflow
22
 
23
- - keras- keras
24
 
25
- - utkface- utkface
26
 
27
- - bias-correction- bias-correction
28
 
29
- - age-groups- age-groups
30
 
31
- - classification- classification
32
 
33
- - deep-learning- deep-learning
34
 
35
- - facial-analysis- facial-analysis
36
 
37
- - demographic-estimation- demographic-estimation
38
 
39
- - transfer-learning- transfer-learning
40
 
41
- datasets:datasets:
42
 
43
- - UTKFace- UTKFace
44
 
45
- metrics:metrics:
46
 
47
- - accuracy- accuracy
48
 
49
- model-index:model-index:
50
 
51
- - name: age-group-classifier- name: age-group-classifier
52
 
53
- results: results:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
54
 
55
  - task: - task:
56
 
57
- type: image-classification type: image-classification
 
 
 
 
58
 
59
  name: Age Group Classification name: Age Group Classification
60
 
61
- dataset: dataset:
 
 
 
 
62
 
63
  type: UTKFace type: UTKFace
64
 
65
- name: UTKFace name: UTKFace
 
 
 
 
66
 
67
  metrics: metrics:
68
 
69
- - type: accuracy - type: accuracy
 
 
70
 
71
- value: 0.755 value: 0.755
72
 
73
- name: Validation Accuracy name: Validation Accuracy
 
 
74
 
75
- pipeline_tag: image-classification---
76
 
77
- base_model: tensorflow/resnet50v2
78
 
79
- widget:# Age Group Classification Model
 
 
 
 
 
 
 
 
 
 
 
80
 
81
  - src: https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/tasks/image-classification-input.jpg
82
 
83
- example_title: Sample Face Image## Model Description
84
 
85
- ---
 
 
 
 
 
 
86
 
87
  This model performs age group classification on facial images, predicting one of 5 age categories instead of exact ages. It was specifically designed to solve the common bias problem where older adults (70+) are incorrectly predicted as young adults (30s).
88
 
89
- # Age Group Classification Model 🎯πŸ‘₯
 
 
 
 
 
 
 
 
90
 
91
- ### Key Features
92
 
93
- A breakthrough age group classification model that **solves the age prediction bias problem** where 70-year-olds are incorrectly predicted as 30-year-olds. Instead of exact age regression, this model classifies faces into 5 practical age groups with **75.5% validation accuracy**.- **Bias-Free Predictions**: Correctly classifies seniors instead of mispredicting them as young adults
94
 
95
  - **Practical Categories**: Returns useful age ranges rather than potentially inaccurate exact ages
96
 
97
- ## πŸš€ Quick Start- **High Performance**: 75.5% validation accuracy on 5-class classification
 
 
 
 
 
 
98
 
99
- - **Stable Architecture**: ResNet50V2 backbone with proven reliability
100
 
101
- ### Using Hugging Face Transformers
102
 
103
- ```python## Model Details
104
 
105
- from transformers import pipeline
 
 
 
 
 
 
 
 
106
 
107
  from PIL import Image### Architecture
108
 
109
- - **Base Model**: ResNet50V2 (pre-trained on ImageNet)
110
 
111
- # Load the classifier- **Task**: Multi-class classification (5 categories)
 
 
 
 
 
 
112
 
113
  classifier = pipeline("image-classification", - **Input**: RGB facial images (224x224)
114
 
 
 
115
  model="Sharris/age-group-classifier")- **Output**: Age group probabilities
116
 
 
 
 
 
 
 
 
117
 
 
118
 
119
- # Classify an image### Age Groups
120
 
121
- image = Image.open("face_image.jpg")- **Group 0**: Youth (0-20 years)
122
 
123
  results = classifier(image)- **Group 1**: Young Adult (21-40 years)
124
 
 
 
125
  - **Group 2**: Middle Age (41-60 years)
126
 
127
- print(f"Predicted age group: {results[0]['label']}")- **Group 3**: Senior (61-80 years)
128
 
129
- print(f"Confidence: {results[0]['score']:.2%}")- **Group 4**: Elderly (81-100 years)
130
 
131
- ```
 
 
 
 
 
 
 
 
132
 
133
  ### Performance
134
 
 
 
135
  ### Using TensorFlow Directly- **Validation Accuracy**: 75.5%
136
 
137
- ```python- **Training Accuracy**: 79.1%
138
 
139
- import tensorflow as tf- **Generalization Gap**: 3.6% (healthy)
140
 
141
- import numpy as np- **Training Epochs**: 13 (with early stopping)
142
 
143
- from PIL import Image
144
 
145
- from huggingface_hub import hf_hub_download## Problem Solved
146
 
 
147
 
148
 
149
- # Download and load model### Original Issue
150
 
151
- model_path = hf_hub_download(Traditional age regression models often exhibit severe bias:
152
 
153
- repo_id="Sharris/age-group-classifier",- 70-year-old faces predicted as 30-year-olds
154
 
155
- filename="resnet50v2_age_classifier_best.h5"- Inconsistent predictions across age ranges
156
 
157
- )- Poor handling of seniors and elderly individuals
158
 
159
- model = tf.keras.models.load_model(model_path)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
160
 
161
- ### Our Solution
162
 
163
- # Preprocess image- **Age Group Classification**: More robust than exact age regression
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
164
 
165
- image = Image.open("face_image.jpg").convert("RGB")- **Balanced Training**: Proper representation across all age groups
166
 
167
- image = image.resize((224, 224))- **Transfer Learning**: Leverages ResNet50V2 features optimized for facial analysis
168
 
169
- image_array = np.array(image, dtype=np.float32) / 255.0
170
 
171
- image_array = np.expand_dims(image_array, axis=0)## Usage
172
 
173
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
174
 
175
- # Predict```python
176
 
177
- predictions = model.predict(image_array)[0]from transformers import pipeline
178
 
179
- age_groups = ["Youth (0-20)", "Young Adult (21-40)", "Middle Age (41-60)", import numpy as np
180
 
181
- "Senior (61-80)", "Elderly (81-100)"]from PIL import Image
182
 
 
183
 
 
184
 
185
- predicted_group = age_groups[np.argmax(predictions)]# Load the model
186
 
187
- confidence = predictions[np.argmax(predictions)]classifier = pipeline("image-classification",
 
 
188
 
189
  model="your-username/age-group-classifier")
190
 
 
 
191
  print(f"Predicted: {predicted_group} ({confidence:.1%} confidence)")
192
 
193
- ```# Classify an image
 
 
 
 
194
 
195
  image = Image.open("face_image.jpg")
196
 
 
 
197
  ## 🎯 Model Overviewresults = classifier(image)
198
 
 
199
 
 
200
 
201
- ### The Problem We Solvedprint(f"Predicted age group: {results[0]['label']}")
202
 
203
- Traditional age regression models suffer from **severe age bias**:print(f"Confidence: {results[0]['score']:.2%}")
204
 
205
- - 70-year-old faces β†’ Predicted as 30-year-olds ❌```
 
 
 
 
 
 
 
 
 
206
 
207
- - Inconsistent predictions across age ranges
208
 
209
- - Poor handling of seniors and elderly individuals### Example Output
210
 
211
- - Exact age predictions often inaccurate and not practical```python
 
 
 
 
 
 
 
 
212
 
213
  [
214
 
215
- ### Our Solution: Age Group Classification {'label': 'Senior (61-80)', 'score': 0.87},
216
 
217
- - **5 Age Groups**: More robust than exact age regression βœ… {'label': 'Middle Age (41-60)', 'score': 0.09},
218
 
219
- - **Bias-Free**: 75-year-olds correctly classified as "Senior (61-80)" βœ… {'label': 'Elderly (81-100)', 'score': 0.03},
220
 
221
- - **Practical**: Returns useful age ranges for real applications βœ… {'label': 'Young Adult (21-40)', 'score': 0.01},
222
 
223
- - **Reliable**: 75.5% validation accuracy with stable predictions βœ… {'label': 'Youth (0-20)', 'score': 0.00}
224
 
225
- ]
226
 
227
- ## πŸ“Š Model Performance```
228
 
229
 
 
230
 
231
- | Metric | Value | Description |## Training Details
232
 
233
- |--------|-------|-------------|
234
 
235
- | **Validation Accuracy** | **75.5%** | 5-class classification accuracy |### Dataset
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
236
 
237
- | **Training Accuracy** | **79.1%** | Training set performance |- **Source**: UTKFace dataset
238
 
239
- | **Generalization Gap** | **3.6%** | Healthy gap - no overfitting |- **Size**: 23,687 facial images
240
 
241
- | **Training Epochs** | **13** | Early stopping applied |- **Split**: 80% training, 20% validation
242
 
243
- | **Parameters** | **23.8M** | ResNet50V2 backbone |- **Preprocessing**: Stratified sampling to ensure balanced age group representation
244
 
245
 
246
 
 
1
+ ---------
2
 
3
+ language: en
4
 
5
+ license: mitlanguage: enlanguage: en
6
 
7
+ library_name: tensorflow
8
 
9
+ tags:license: mitlicense: mit
10
 
11
+ - computer-vision
12
 
13
+ - image-classificationlibrary_name: tensorflowlibrary_name: tensorflow
14
 
15
+ - age-estimation
16
 
17
+ - face-analysistags:tags:
18
 
19
+ - resnet50v2
20
 
21
+ - tensorflow- computer-vision- computer-vision
22
 
23
+ - keras
24
 
25
+ - utkface- image-classification- image-classification
26
 
27
+ - bias-correction
28
 
29
+ - age-groups- age-estimation- age-estimation
30
 
31
+ - classification
32
 
33
+ - deep-learning- face-analysis- face-analysis
34
 
35
+ - facial-analysis
36
 
37
+ - demographic-estimation- resnet50v2- resnet50v2
38
 
39
+ - transfer-learning
40
 
41
+ datasets:- tensorflow- tensorflow
42
 
43
+ - UTKFace
44
 
45
+ metrics:- keras- keras
46
 
47
+ - accuracy
48
 
49
+ model-index:- utkface- utkface
50
 
51
+ - name: age-group-classifier
52
 
53
+ results:- bias-correction- bias-correction
54
+
55
+ - task:
56
+
57
+ type: image-classification- age-groups- age-groups
58
+
59
+ name: Age Group Classification
60
+
61
+ dataset:- classification- classification
62
+
63
+ type: UTKFace
64
+
65
+ name: UTKFace- deep-learning- deep-learning
66
+
67
+ metrics:
68
+
69
+ - type: accuracy- facial-analysis- facial-analysis
70
+
71
+ value: 0.755
72
+
73
+ name: Validation Accuracy- demographic-estimation- demographic-estimation
74
+
75
+ pipeline_tag: image-classification
76
+
77
+ base_model: tensorflow/resnet50v2- transfer-learning- transfer-learning
78
+
79
+ widget:
80
+
81
+ - src: https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/tasks/image-classification-input.jpgdatasets:datasets:
82
+
83
+ example_title: Sample Face Image
84
+
85
+ ---- UTKFace- UTKFace
86
+
87
+
88
+
89
+ # Age Group Classification Model 🎯πŸ‘₯metrics:metrics:
90
+
91
+
92
+
93
+ A breakthrough age group classification model that **solves the age prediction bias problem** where 70-year-olds are incorrectly predicted as 30-year-olds. Instead of exact age regression, this model classifies faces into 5 practical age groups with **75.5% validation accuracy**.- accuracy- accuracy
94
+
95
+
96
+
97
+ ## πŸš€ Quick Startmodel-index:model-index:
98
+
99
+
100
+
101
+ ### Using Hugging Face Transformers- name: age-group-classifier- name: age-group-classifier
102
+
103
+ ```python
104
+
105
+ from transformers import pipeline results: results:
106
+
107
+ from PIL import Image
108
 
109
  - task: - task:
110
 
111
+ # Load the classifier
112
+
113
+ classifier = pipeline("image-classification", type: image-classification type: image-classification
114
+
115
+ model="Sharris/age-group-classifier")
116
 
117
  name: Age Group Classification name: Age Group Classification
118
 
119
+ # Classify an image
120
+
121
+ image = Image.open("face_image.jpg") dataset: dataset:
122
+
123
+ results = classifier(image)
124
 
125
  type: UTKFace type: UTKFace
126
 
127
+ print(f"Predicted age group: {results[0]['label']}")
128
+
129
+ print(f"Confidence: {results[0]['score']:.2%}") name: UTKFace name: UTKFace
130
+
131
+ ```
132
 
133
  metrics: metrics:
134
 
135
+ ### Using TensorFlow Directly
136
+
137
+ ```python - type: accuracy - type: accuracy
138
 
139
+ import tensorflow as tf
140
 
141
+ import numpy as np value: 0.755 value: 0.755
142
+
143
+ from PIL import Image
144
 
145
+ from huggingface_hub import hf_hub_download name: Validation Accuracy name: Validation Accuracy
146
 
 
147
 
148
+
149
+ # Download and load modelpipeline_tag: image-classification---
150
+
151
+ model_path = hf_hub_download(
152
+
153
+ repo_id="Sharris/age-group-classifier",base_model: tensorflow/resnet50v2
154
+
155
+ filename="resnet50v2_age_classifier_best.h5"
156
+
157
+ )widget:# Age Group Classification Model
158
+
159
+ model = tf.keras.models.load_model(model_path)
160
 
161
  - src: https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/tasks/image-classification-input.jpg
162
 
163
+ # Preprocess image
164
 
165
+ image = Image.open("face_image.jpg").convert("RGB") example_title: Sample Face Image## Model Description
166
+
167
+ image = image.resize((224, 224))
168
+
169
+ image_array = np.array(image, dtype=np.float32) / 255.0---
170
+
171
+ image_array = np.expand_dims(image_array, axis=0)
172
 
173
  This model performs age group classification on facial images, predicting one of 5 age categories instead of exact ages. It was specifically designed to solve the common bias problem where older adults (70+) are incorrectly predicted as young adults (30s).
174
 
175
+ # Predict
176
+
177
+ predictions = model.predict(image_array)[0]# Age Group Classification Model 🎯πŸ‘₯
178
+
179
+ age_groups = ["Youth (0-20)", "Young Adult (21-40)", "Middle Age (41-60)",
180
+
181
+ "Senior (61-80)", "Elderly (81-100)"]### Key Features
182
+
183
+
184
 
185
+ predicted_group = age_groups[np.argmax(predictions)]A breakthrough age group classification model that **solves the age prediction bias problem** where 70-year-olds are incorrectly predicted as 30-year-olds. Instead of exact age regression, this model classifies faces into 5 practical age groups with **75.5% validation accuracy**.- **Bias-Free Predictions**: Correctly classifies seniors instead of mispredicting them as young adults
186
 
187
+ confidence = predictions[np.argmax(predictions)]
188
 
189
  - **Practical Categories**: Returns useful age ranges rather than potentially inaccurate exact ages
190
 
191
+ print(f"Predicted: {predicted_group} ({confidence:.1%} confidence)")
192
+
193
+ ```## πŸš€ Quick Start- **High Performance**: 75.5% validation accuracy on 5-class classification
194
+
195
+
196
+
197
+ ## 🎯 Model Overview- **Stable Architecture**: ResNet50V2 backbone with proven reliability
198
 
 
199
 
 
200
 
201
+ ### The Problem We Solved### Using Hugging Face Transformers
202
 
203
+ Traditional age regression models suffer from **severe age bias**:
204
+
205
+ - 70-year-old faces β†’ Predicted as 30-year-olds ❌```python## Model Details
206
+
207
+ - Inconsistent predictions across age ranges
208
+
209
+ - Poor handling of seniors and elderly individualsfrom transformers import pipeline
210
+
211
+ - Exact age predictions often inaccurate and not practical
212
 
213
  from PIL import Image### Architecture
214
 
215
+ ### Our Solution: Age Group Classification
216
 
217
+ - **5 Age Groups**: More robust than exact age regression βœ…- **Base Model**: ResNet50V2 (pre-trained on ImageNet)
218
+
219
+ - **Bias-Free**: 75-year-olds correctly classified as "Senior (61-80)" βœ…
220
+
221
+ - **Practical**: Returns useful age ranges for real applications βœ…# Load the classifier- **Task**: Multi-class classification (5 categories)
222
+
223
+ - **Reliable**: 75.5% validation accuracy with stable predictions βœ…
224
 
225
  classifier = pipeline("image-classification", - **Input**: RGB facial images (224x224)
226
 
227
+ ## πŸ“Š Model Performance
228
+
229
  model="Sharris/age-group-classifier")- **Output**: Age group probabilities
230
 
231
+ | Metric | Value | Description |
232
+
233
+ |--------|-------|-------------|
234
+
235
+ | **Validation Accuracy** | **75.5%** | 5-class classification accuracy |
236
+
237
+ | **Training Accuracy** | **79.1%** | Training set performance |# Classify an image### Age Groups
238
 
239
+ | **Generalization Gap** | **3.6%** | Healthy gap - no overfitting |
240
 
241
+ | **Training Epochs** | **13** | Early stopping applied |image = Image.open("face_image.jpg")- **Group 0**: Youth (0-20 years)
242
 
243
+ | **Parameters** | **23.8M** | ResNet50V2 backbone |
244
 
245
  results = classifier(image)- **Group 1**: Young Adult (21-40 years)
246
 
247
+ ## 🏷️ Age Groups
248
+
249
  - **Group 2**: Middle Age (41-60 years)
250
 
251
+ | Group ID | Age Range | Label | Description |
252
 
253
+ |----------|-----------|-------|-------------|print(f"Predicted age group: {results[0]['label']}")- **Group 3**: Senior (61-80 years)
254
 
255
+ | 0 | 0-20 years | Youth | Children, teenagers |
256
+
257
+ | 1 | 21-40 years | Young Adult | College age to early career |print(f"Confidence: {results[0]['score']:.2%}")- **Group 4**: Elderly (81-100 years)
258
+
259
+ | 2 | 41-60 years | Middle Age | Established adults |
260
+
261
+ | 3 | 61-80 years | Senior | Retirement age |```
262
+
263
+ | 4 | 81-100 years | Elderly | Advanced age |
264
 
265
  ### Performance
266
 
267
+ ## πŸ”§ Technical Details
268
+
269
  ### Using TensorFlow Directly- **Validation Accuracy**: 75.5%
270
 
271
+ ### Architecture
272
 
273
+ - **Base Model**: ResNet50V2 (pre-trained on ImageNet)```python- **Training Accuracy**: 79.1%
274
 
275
+ - **Task**: Multi-class classification (5 categories)
276
 
277
+ - **Input**: RGB facial images (224Γ—224)import tensorflow as tf- **Generalization Gap**: 3.6% (healthy)
278
 
279
+ - **Output**: Age group probabilities
280
 
281
+ - **Transfer Learning**: 2-phase training (frozen base β†’ fine-tuning)import numpy as np- **Training Epochs**: 13 (with early stopping)
282
 
283
 
 
284
 
285
+ ### Training Configurationfrom PIL import Image
286
 
287
+ - **Framework**: TensorFlow/Keras
288
 
289
+ - **Optimizer**: Adam (lr: 0.001 β†’ 0.0001)from huggingface_hub import hf_hub_download## Problem Solved
290
 
291
+ - **Loss Function**: Categorical Crossentropy
292
 
293
+ - **Batch Size**: 32
294
+
295
+ - **Data Split**: 80% train, 20% validation (stratified)
296
+
297
+ - **Early Stopping**: Patience=3 epochs# Download and load model### Original Issue
298
+
299
+
300
+
301
+ ### Datasetmodel_path = hf_hub_download(Traditional age regression models often exhibit severe bias:
302
+
303
+ - **Source**: UTKFace dataset
304
+
305
+ - **Size**: 23,687 facial images repo_id="Sharris/age-group-classifier",- 70-year-old faces predicted as 30-year-olds
306
+
307
+ - **Age Distribution**: Balanced across age groups
308
+
309
+ - **Preprocessing**: Stratified sampling for equal representation filename="resnet50v2_age_classifier_best.h5"- Inconsistent predictions across age ranges
310
+
311
+
312
+
313
+ ## 🎯 Bias Validation)- Poor handling of seniors and elderly individuals
314
+
315
+
316
+
317
+ ### Test Resultsmodel = tf.keras.models.load_model(model_path)
318
 
319
+ | Input Age | Predicted Group | Status |
320
 
321
+ |-----------|----------------|---------|### Our Solution
322
+
323
+ | 15 years | Youth (0-20) | βœ… Correct |
324
+
325
+ | 25 years | Young Adult (21-40) | βœ… Correct |# Preprocess image- **Age Group Classification**: More robust than exact age regression
326
+
327
+ | 35 years | Young Adult (21-40) | βœ… Correct |
328
+
329
+ | 45 years | Middle Age (41-60) | βœ… Correct |image = Image.open("face_image.jpg").convert("RGB")- **Balanced Training**: Proper representation across all age groups
330
+
331
+ | 55 years | Middle Age (41-60) | βœ… Correct |
332
+
333
+ | 65 years | Senior (61-80) | βœ… Correct |image = image.resize((224, 224))- **Transfer Learning**: Leverages ResNet50V2 features optimized for facial analysis
334
+
335
+ | **75 years** | **Senior (61-80)** | βœ… **BIAS FIXED!** |
336
+
337
+ | 85 years | Elderly (81-100) | βœ… Correct |image_array = np.array(image, dtype=np.float32) / 255.0
338
 
 
339
 
 
340
 
341
+ **Key Achievement**: 70+ year olds are now correctly classified as Senior/Elderly instead of being mispredicted as young adults!image_array = np.expand_dims(image_array, axis=0)## Usage
342
 
 
343
 
344
 
345
+ ## πŸ’‘ Use Cases
346
+
347
+
348
+
349
+ ### βœ… Recommended Applications# Predict```python
350
+
351
+ - **Content Personalization**: Age-appropriate content delivery
352
+
353
+ - **Market Research**: Demographic analysis of audiencespredictions = model.predict(image_array)[0]from transformers import pipeline
354
+
355
+ - **Photo Organization**: Automatic family album categorization
356
+
357
+ - **Social Media**: Age group insights and targetingage_groups = ["Youth (0-20)", "Young Adult (21-40)", "Middle Age (41-60)", import numpy as np
358
+
359
+ - **Research**: Age-related studies and analysis
360
 
361
+ - **Accessibility**: Age-aware interface design "Senior (61-80)", "Elderly (81-100)"]from PIL import Image
362
 
 
363
 
 
364
 
365
+ ### ❌ Limitations
366
 
367
+ - **Border Cases**: Ages near group boundaries (e.g., 40 vs 41) can be challenging
368
 
369
+ - **Image Quality**: Performance varies with lighting and image qualitypredicted_group = age_groups[np.argmax(predictions)]# Load the model
370
 
371
+ - **Pose Sensitivity**: Works best with frontal face images
372
 
373
+ - **Demographic Bias**: May vary across different ethnic groupsconfidence = predictions[np.argmax(predictions)]classifier = pipeline("image-classification",
374
+
375
+ - **Not for Legal Use**: Estimates only, not for official identification
376
 
377
  model="your-username/age-group-classifier")
378
 
379
+ ## πŸ”¬ Model Files
380
+
381
  print(f"Predicted: {predicted_group} ({confidence:.1%} confidence)")
382
 
383
+ - **`resnet50v2_age_classifier_best.h5`**: Complete trained model (98MB)
384
+
385
+ - **`config.json`**: Model configuration and label mappings```# Classify an image
386
+
387
+ - **`README.md`**: This comprehensive model card
388
 
389
  image = Image.open("face_image.jpg")
390
 
391
+ ## πŸ€– Live Demo
392
+
393
  ## 🎯 Model Overviewresults = classifier(image)
394
 
395
+ Try the model instantly with our Gradio demo:
396
 
397
+ **[Age Group Classifier Demo](https://huggingface.co/spaces/Sharris/age-group-classifier-demo)**
398
 
 
399
 
 
400
 
401
+ Features:### The Problem We Solvedprint(f"Predicted age group: {results[0]['label']}")
402
+
403
+ - Upload facial images
404
+
405
+ - Get age group predictionsTraditional age regression models suffer from **severe age bias**:print(f"Confidence: {results[0]['score']:.2%}")
406
+
407
+ - View confidence scores for all groups
408
+
409
+ - Compare predictions across different ages- 70-year-old faces β†’ Predicted as 30-year-olds ❌```
410
+
411
 
 
412
 
413
+ ## πŸ“œ License & Ethics- Inconsistent predictions across age ranges
414
 
415
+
416
+
417
+ ### License- Poor handling of seniors and elderly individuals### Example Output
418
+
419
+ - **Model**: MIT License
420
+
421
+ - **Code**: MIT License- Exact age predictions often inaccurate and not practical```python
422
+
423
+ - **Dataset**: UTKFace (academic/research use)
424
 
425
  [
426
 
427
+ ### Ethical Considerations
428
 
429
+ - **Bias Mitigation**: Specifically designed to reduce age prediction bias### Our Solution: Age Group Classification {'label': 'Senior (61-80)', 'score': 0.87},
430
 
431
+ - **Fairness**: Balanced training across all age groups
432
 
433
+ - **Transparency**: Clear category boundaries and confidence scores- **5 Age Groups**: More robust than exact age regression βœ… {'label': 'Middle Age (41-60)', 'score': 0.09},
434
 
435
+ - **Privacy**: Consider consent when processing facial images
436
 
437
+ - **Responsible Use**: Avoid high-stakes decisions without human oversight- **Bias-Free**: 75-year-olds correctly classified as "Senior (61-80)" βœ… {'label': 'Elderly (81-100)', 'score': 0.03},
438
 
 
439
 
440
 
441
+ ## πŸ“š Citation- **Practical**: Returns useful age ranges for real applications βœ… {'label': 'Young Adult (21-40)', 'score': 0.01},
442
 
 
443
 
 
444
 
445
+ If you use this model in your research, please cite:- **Reliable**: 75.5% validation accuracy with stable predictions βœ… {'label': 'Youth (0-20)', 'score': 0.00}
446
+
447
+
448
+
449
+ ```bibtex]
450
+
451
+ @misc{age-group-classifier-2025,
452
+
453
+ title={Age Group Classification: Solving Age Prediction Bias in Facial Analysis},## πŸ“Š Model Performance```
454
+
455
+ author={Sharris},
456
+
457
+ year={2025},
458
+
459
+ publisher={Hugging Face},
460
+
461
+ url={https://huggingface.co/Sharris/age-group-classifier}| Metric | Value | Description |## Training Details
462
+
463
+ }
464
+
465
+ ```|--------|-------|-------------|
466
+
467
+
468
+
469
+ ## 🀝 Contact & Support| **Validation Accuracy** | **75.5%** | 5-class classification accuracy |### Dataset
470
+
471
+
472
+
473
+ - **Model Repository**: [Sharris/age-group-classifier](https://huggingface.co/Sharris/age-group-classifier)| **Training Accuracy** | **79.1%** | Training set performance |- **Source**: UTKFace dataset
474
+
475
+ - **Demo Space**: [age-group-classifier-demo](https://huggingface.co/spaces/Sharris/age-group-classifier-demo)
476
+
477
+ - **Issues**: Use the discussions tab for questions and feedback| **Generalization Gap** | **3.6%** | Healthy gap - no overfitting |- **Size**: 23,687 facial images
478
+
479
+
480
 
481
+ ---| **Training Epochs** | **13** | Early stopping applied |- **Split**: 80% training, 20% validation
482
 
 
483
 
 
484
 
485
+ **πŸŽ‰ Ready to use bias-free age group classification?** Try our [live demo](https://huggingface.co/spaces/Sharris/age-group-classifier-demo) or integrate the model into your applications today!| **Parameters** | **23.8M** | ResNet50V2 backbone |- **Preprocessing**: Stratified sampling to ensure balanced age group representation
486
 
487
 
488