Downloads · 30 days
46
30% of all-time downloads
hudaakram/FaceGuard-20ID-ViT
FaceGuard-20ID-ViT is a image classification model from hudaakram. Use it when you need a label for an image. It is set up for transformers. The card lists the license as apache-2.0.
A Vision Transformer (ViT-Base) fine-tuned for identity classification on a 20-identity subset of the CelebA dataset. This model predicts anonymized celebid integers (not celebrity names). It powers the demo Space: ht…
Downloads · 30 days
46
30% of all-time downloads
All-time downloads
155
Public
Parameters
85.8M
344 MB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors343 MB · 100%
From the Hugging Face model README
A Vision Transformer (ViT-Base) fine-tuned for identity classification on a 20-identity subset of the CelebA dataset.
This model predicts anonymized celeb_id integers (not celebrity names).
It powers the demo Space: https://huggingface.co/spaces/hudaakram/FaceGuard-demo
google/vit-base-patch16-224 (pretrained on ImageNet-1k)celeb_ids)Recommendation: Use strictly for research/educational purposes.
Use the code below to get started with the model.
from transformers import ViTForImageClassification, AutoImageProcessor
from PIL import Image
import torch
model_id = "hudaakram/FaceGuard-20ID-ViT"
processor = AutoImageProcessor.from_pretrained(model_id)
model = ViTForImageClassification.from_pretrained(model_id)
img = Image.open("face.jpg").convert("RGB")
inputs = processor(images=img, return_tensors="pt")
with torch.no_grad():
logits = model(**inputs).logits
probs = torch.softmax(logits, dim=-1)[0]
id2label = {int(k): v for k, v in model.config.id2label.items()}
top5 = probs.topk(5)
for score, idx in zip(top5.values, top5.indices):
print(f"Label {idx.item()} (celeb_id {id2label[idx.item()]}): {score:.3f}")
celeb_id → contiguous 0–19| Split | #Images | #Classes | Min/Class | Median/Class | Max/Class |
|---|---|---|---|---|---|
| Train | 501 | 20 | 24 | 24 | 28 |
| Val | 60 | 20 | 3 | 3 | 3 |
| Test | 77 | 20 | 3 | 4 | 4 |
Confusion Matrix (normalized):

ROC Curves (one-vs-rest):

CelebA Dataset:
Z. Liu, P. Luo, X. Wang, and X. Tang. Deep Learning Face Attributes in the Wild. ICCV 2015.
ViT:
A. Dosovitskiy et al. An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale. ICLR 2021.
Hackathon submission by Huda Akram