Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| from transformers import pipeline | |
| from PIL import Image | |
| # Load the pipeline for age classification | |
| pipe = pipeline("image-classification", model="prithivMLmods/Age-Classification-SigLIP2") | |
| # Define the prediction function | |
| def predict(input_img): | |
| # Get the predictions | |
| predictions = pipe(input_img) | |
| # Format the predictions into a human-readable string | |
| result_str = "\n".join([f"{p['label']}: {p['score']:.4f}" for p in predictions]) | |
| return result_str | |
| # Create a Gradio interface | |
| iface = gr.Interface(fn=predict, | |
| inputs=gr.Image(type="pil"), # Define input type as an image | |
| outputs=gr.Textbox(label="Class Confidence Scores", interactive=False), # Output as plain text | |
| ) # Set live=True to update results as soon as the image is uploaded | |
| # Launch the Gradio app | |
| iface.launch() | |