Spaces:
Running
Running
Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -1,128 +1,16 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
colorFrom: blue
|
| 5 |
colorTo: purple
|
| 6 |
sdk: gradio
|
| 7 |
-
|
| 8 |
app_file: app.py
|
| 9 |
-
|
| 10 |
-
tags:
|
| 11 |
-
- age-estimation
|
| 12 |
-
- gender-classification
|
| 13 |
-
- face-analysis
|
| 14 |
-
- vision-transformer
|
| 15 |
-
- dinov3
|
| 16 |
-
- coral-ordinal-regression
|
| 17 |
-
pipeline_tag: image-classification
|
| 18 |
---
|
| 19 |
|
| 20 |
-
# FaceAge-DINOv3
|
| 21 |
|
| 22 |
-
|
| 23 |
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
| Model | MAE β | CS@5 β | Gender Acc β |
|
| 27 |
-
|-------|--------|--------|-------------|
|
| 28 |
-
| MiVOLO v2 [face+body] (paper) | 3.650 | 74.48% | 97.99% |
|
| 29 |
-
| MiVOLO v2 [face+body] (measured on the public model) | 3.859 | 76.5% | β |
|
| 30 |
-
| MiVOLO v2 [face-only] (measured on the public model) | 3.941 | 75.6% | β |
|
| 31 |
-
| **FaceAge-DINOv3 (face-only)** | **3.760** | β | β |
|
| 32 |
-
|
| 33 |
-
Trained on:Our collection data.
|
| 34 |
-
|
| 35 |
-
## Architecture
|
| 36 |
-
|
| 37 |
-
```
|
| 38 |
-
Face [B, 3, 224, 224]
|
| 39 |
-
β
|
| 40 |
-
DINOv3-ViT-L/16 (307M params, pretrained on LVD-1.68B)
|
| 41 |
-
β pooler_output
|
| 42 |
-
[B, 1024]
|
| 43 |
-
β LayerNorm β Linear(1024β512) β GELU β Dropout
|
| 44 |
-
[B, 512]
|
| 45 |
-
βββ age_head: Linear(512, 100) β CORAL β age β [0, 100]
|
| 46 |
-
βββ gender_head: Linear(512, 2) β softmax β {female, male}
|
| 47 |
-
```
|
| 48 |
-
|
| 49 |
-
**CORAL ordinal regression**: age = Ξ£ Ο(logit_k) for k=0..99. Exploits the ordinal structure of ages (25 < 26 < 27) for better calibration than standard cross-entropy.
|
| 50 |
-
|
| 51 |
-
## Usage
|
| 52 |
-
|
| 53 |
-
```python
|
| 54 |
-
from PIL import Image
|
| 55 |
-
from transformers import AutoImageProcessor, AutoModel
|
| 56 |
-
|
| 57 |
-
processor = AutoImageProcessor.from_pretrained("trungthanhtran/faceage-dino")
|
| 58 |
-
model = AutoModel.from_pretrained("trungthanhtran/faceage-dino",
|
| 59 |
-
trust_remote_code=True)
|
| 60 |
-
model.eval()
|
| 61 |
-
|
| 62 |
-
# Input: 224Γ224 face crop (already cropped, no detection needed)
|
| 63 |
-
image = Image.open("face_crop.jpg").convert("RGB")
|
| 64 |
-
inputs = processor(images=image, return_tensors="pt")
|
| 65 |
-
|
| 66 |
-
import torch
|
| 67 |
-
with torch.no_grad():
|
| 68 |
-
outputs = model(**inputs)
|
| 69 |
-
|
| 70 |
-
age = outputs.age_output.item()
|
| 71 |
-
gender = "male" if outputs.gender_class_idx.item() == 1 else "female"
|
| 72 |
-
conf = outputs.gender_probs[0, outputs.gender_class_idx.item()].item()
|
| 73 |
-
|
| 74 |
-
print(f"Age : {age:.1f}")
|
| 75 |
-
print(f"Gender : {gender} (conf={conf:.2f})")
|
| 76 |
-
```
|
| 77 |
-
|
| 78 |
-
## ONNX (no PyTorch needed)
|
| 79 |
-
|
| 80 |
-
The model is also available as a single-file ONNX for CPU deployment:
|
| 81 |
-
|
| 82 |
-
```bash
|
| 83 |
-
pip install onnxruntime numpy pillow
|
| 84 |
-
python infer_onnx.py --onnx faceage_dino_fp32.onnx --image face.jpg
|
| 85 |
-
```
|
| 86 |
-
|
| 87 |
-
ONNX is ~3-4Γ faster on CPU than the PyTorch model and requires no GPU.
|
| 88 |
-
|
| 89 |
-
## Benchmark against MiVOLO v2
|
| 90 |
-
|
| 91 |
-
```bash
|
| 92 |
-
python infer_onnx.py \
|
| 93 |
-
--onnx faceage_dino_fp32.onnx \
|
| 94 |
-
--lagenda_dir data/lagenda \
|
| 95 |
-
--annotation_csv lagenda_test.csv \
|
| 96 |
-
--batch_size 256
|
| 97 |
-
```
|
| 98 |
-
|
| 99 |
-
## Training
|
| 100 |
-
|
| 101 |
-
Multi-phase fine-tuning on DINOv3-ViT-L:
|
| 102 |
-
|
| 103 |
-
| Phase | Backbone | LR | Data |
|
| 104 |
-
|-------|----------|-----|------|
|
| 105 |
-
| 1 | Frozen (all 24 blocks) | 1e-3 | Our collection 786k faces |
|
| 106 |
-
| 2 | Top 4 blocks unfrozen | 1e-4 | Same |
|
| 107 |
-
| 3 | All blocks unfrozen | 3e-5 | Same |
|
| 108 |
-
| 4 | All blocks | 3e-6 | Our collection 4M faces, age reweighting |
|
| 109 |
-
|
| 110 |
-
Age group reweighting (Phase 4): 36-50 Γ2.0, 51-65 Γ1.5, 66-100 Γ3.0 to improve accuracy on older faces.
|
| 111 |
-
|
| 112 |
-
## Citation
|
| 113 |
-
|
| 114 |
-
If you use this model, please cite:
|
| 115 |
-
|
| 116 |
-
```bibtex
|
| 117 |
-
@misc{faceage-dino-2026,
|
| 118 |
-
title = {FaceAge-DINOv3: Age and Gender Estimation with DINOv3-ViT-L},
|
| 119 |
-
author = {Trung Thanh Tran},
|
| 120 |
-
year = {2026},
|
| 121 |
-
url = {https://huggingface.co/trungthanhtran/faceage-dino}
|
| 122 |
-
}
|
| 123 |
-
```
|
| 124 |
-
|
| 125 |
-
Also cite the backbones and datasets used:
|
| 126 |
-
- DINOv3: Meta AI, "DINOv3: Scaling Up Vision Foundation Models", 2025
|
| 127 |
-
- LAGENDA: Bhuiyan et al., 2023
|
| 128 |
-
- MiVOLO: Kuprashevich & Tolstykh, arXiv 2307.04616
|
|
|
|
| 1 |
---
|
| 2 |
+
title: FaceAge-DINOv3 Demo
|
| 3 |
+
emoji: π§βπ¦³
|
| 4 |
colorFrom: blue
|
| 5 |
colorTo: purple
|
| 6 |
sdk: gradio
|
| 7 |
+
sdk_version: "4.0.0"
|
| 8 |
app_file: app.py
|
| 9 |
+
pinned: false
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
---
|
| 11 |
|
| 12 |
+
# FaceAge-DINOv3 β Age & Gender Estimation Demo
|
| 13 |
|
| 14 |
+
Upload a photo to get age and gender predictions.
|
| 15 |
|
| 16 |
+
Model: [TrungTran/faceage-dino](https://huggingface.co/TrungTran/faceage-dino)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|