Spaces:
Sleeping
Sleeping
File size: 812 Bytes
1846ecd |
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 |
from transformers import pipeline
classifier = pipeline("image-classification", model="Thogmey/Chess-model")
import gradio as gr
import numpy as np
# Function to classify images into 7 classes
def image_classifier(inp):
# Dummy classification logic
# Generating random confidence scores for each class
confidence_scores = np.random.rand(6)
# Normalizing confidence scores to sum up to 1
confidence_scores /= np.sum(confidence_scores)
# Creating a dictionary with class labels and corresponding confidence scores
classes = ['Bishop', 'King', 'Knight', 'Pawn', 'Queen', 'Rook']
result = {classes[i]: confidence_scores[i] for i in range(6)}
return result
# Creating Gradio interface
demo = gr.Interface(fn=image_classifier, inputs="image", outputs="label")
demo.launch()
|