Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
# Load the age estimation model
|
| 5 |
+
age_model = pipeline("image-classification", model="nateraw/vit-age-classifier")
|
| 6 |
+
|
| 7 |
+
def predict_age(image):
|
| 8 |
+
|
| 9 |
+
result = age_model(image)
|
| 10 |
+
|
| 11 |
+
age = result[0]['label']
|
| 12 |
+
|
| 13 |
+
return f"Estimated Face Age: {age}"
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
iface = gr.Interface(
|
| 17 |
+
fn=predict_age,
|
| 18 |
+
inputs=gr.Image(type="pil"),
|
| 19 |
+
outputs="text",
|
| 20 |
+
title="Face Age Detection",
|
| 21 |
+
description="Upload a face and AI will estimate the age."
|
| 22 |
+
)
|
| 23 |
+
|
| 24 |
+
iface.launch()
|