Spaces:
Sleeping
Sleeping
from transformers import pipeline | |
import gradio as gr | |
def image_classifier(image): | |
classifier = pipeline("image-classification", model="dupthotshering/bhutanese-textile-model") | |
results = classifier(image) | |
# Convert results into a dictionary with class names as keys | |
formatted_results = {result['label']: result['score'] for result in results} | |
return formatted_results | |
# Define Gradio interface | |
demo = gr.Interface( | |
fn=image_classifier, | |
inputs=gr.Image(type="pil"), # Ensure input is an image | |
outputs=gr.Label(num_top_classes=7), # Display all class scores | |
title="Bhutanese Textile Classifier", | |
description="Upload an image to classify it into one of the Bhutanese textile categories." | |
) | |
demo.launch() | |