Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -2,11 +2,15 @@ from transformers import pipeline
|
|
2 |
import gradio as gr
|
3 |
from PIL import Image
|
4 |
|
|
|
|
|
|
|
5 |
# Prediction function
|
6 |
def predict(input_img):
|
7 |
# Get the predictions from the pipeline
|
8 |
predictions = pipe(input_img)
|
9 |
|
|
|
10 |
result = {p["label"]: p["score"] for p in predictions}
|
11 |
|
12 |
# Return the image and the top predictions as a string
|
@@ -27,7 +31,3 @@ gradio_app = gr.Interface(
|
|
27 |
|
28 |
# Launch the app
|
29 |
gradio_app.launch()
|
30 |
-
|
31 |
-
|
32 |
-
if _name=="main_":
|
33 |
-
gradio_app.launch()
|
|
|
2 |
import gradio as gr
|
3 |
from PIL import Image
|
4 |
|
5 |
+
# Initialize the image classification pipeline
|
6 |
+
pipe = pipeline("image-classification", model="prithivMLmods/Age-Classification-SigLIP2")
|
7 |
+
|
8 |
# Prediction function
|
9 |
def predict(input_img):
|
10 |
# Get the predictions from the pipeline
|
11 |
predictions = pipe(input_img)
|
12 |
|
13 |
+
# Format the result correctly for Gradio output
|
14 |
result = {p["label"]: p["score"] for p in predictions}
|
15 |
|
16 |
# Return the image and the top predictions as a string
|
|
|
31 |
|
32 |
# Launch the app
|
33 |
gradio_app.launch()
|
|
|
|
|
|
|
|