Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import pipeline
|
2 |
+
|
3 |
+
classifier = pipeline("image-classification", model="Thogmey/Chess-model")
|
4 |
+
|
5 |
+
|
6 |
+
|
7 |
+
import gradio as gr
|
8 |
+
import numpy as np
|
9 |
+
|
10 |
+
# Function to classify images into 7 classes
|
11 |
+
def image_classifier(inp):
|
12 |
+
# Dummy classification logic
|
13 |
+
# Generating random confidence scores for each class
|
14 |
+
confidence_scores = np.random.rand(6)
|
15 |
+
# Normalizing confidence scores to sum up to 1
|
16 |
+
confidence_scores /= np.sum(confidence_scores)
|
17 |
+
# Creating a dictionary with class labels and corresponding confidence scores
|
18 |
+
classes = ['Bishop', 'King', 'Knight', 'Pawn', 'Queen', 'Rook']
|
19 |
+
result = {classes[i]: confidence_scores[i] for i in range(6)}
|
20 |
+
return result
|
21 |
+
|
22 |
+
# Creating Gradio interface
|
23 |
+
demo = gr.Interface(fn=image_classifier, inputs="image", outputs="label")
|
24 |
+
demo.launch()
|
25 |
+
|
26 |
+
|