File size: 4,131 Bytes
606558a f269bef 606558a d94888d 606558a d94888d 606558a d94888d 606558a 8502c81 606558a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
---
license: cc-by-nc-4.0
language:
- en
base_model:
- facebook/metaclip-2-worldwide-s16
pipeline_tag: image-classification
library_name: transformers
tags:
- text-generation-inference
- gender-identifier
---

# **MetaCLIP-2-Gender-Identifier**
> **MetaCLIP-2-Gender-Identifier** is an image classification vision-language encoder model fine-tuned from **[facebook/metaclip-2-worldwide-s16](https://huggingface.co/facebook/metaclip-2-worldwide-s16)** for a single-label classification task.
> It is designed to predict the gender of a person from an image using the **MetaClip2ForImageClassification** architecture.
>[!note]
MetaCLIP 2: A Worldwide Scaling Recipe : https://huggingface.co/papers/2507.22062
```
Classification Report:
precision recall f1-score support
female 0.9815 0.9631 0.9722 1600
male 0.9638 0.9819 0.9728 1600
accuracy 0.9725 3200
macro avg 0.9727 0.9725 0.9725 3200
weighted avg 0.9727 0.9725 0.9725 3200
```

---
The model categorizes images into two gender classes:
* **Class 0:** "female"
* **Class 1:** "male"
# **Run with Transformers**
```python
!pip install -q transformers torch pillow gradio
```
```python
import gradio as gr
import torch
from transformers import AutoImageProcessor, AutoModelForImageClassification
from PIL import Image
# Model name from Hugging Face Hub
model_name = "prithivMLmods/MetaCLIP-2-Gender-Identifier"
# Load processor and model
processor = AutoImageProcessor.from_pretrained(model_name)
model = AutoModelForImageClassification.from_pretrained(model_name)
model.eval()
# Define labels
LABELS = {
0: "female",
1: "male"
}
def age_classification(image):
"""Predict the age group of a person from an image."""
image = Image.fromarray(image).convert("RGB")
inputs = processor(images=image, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
logits = outputs.logits
probs = torch.nn.functional.softmax(logits, dim=1).squeeze().tolist()
predictions = {LABELS[i]: round(probs[i], 3) for i in range(len(probs))}
return predictions
# Build Gradio interface
iface = gr.Interface(
fn=age_classification,
inputs=gr.Image(type="numpy", label="Upload Image"),
outputs=gr.Label(label="Predicted Gender"),
title="MetaCLIP-2-Gender-Identifier",
description="Upload an image to predict the person's gender."
)
# Launch app
if __name__ == "__main__":
iface.launch()
```
# **Sample Inference:**




# **Intended Use:**
The **MetaCLIP-2-Gender-Identifier** model is designed to classify images into gender categories.
Potential use cases include:
* **Demographic Analysis:** Supporting research and business insights into gender-based distribution.
* **Health and Fitness Applications:** Assisting in gender-specific analytics and recommendations.
* **Security and Access Control:** Supporting gender-based identity verification systems.
* **Retail and Marketing:** Enabling improved personalization and customer segmentation.
* **Forensics and Surveillance:** Assisting in identity estimation for investigative purposes. |