Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
+
from PIL import Image
|
4 |
+
|
5 |
+
classifier = pipeline("image-classification", model="microsoft/resnet-50")
|
6 |
+
|
7 |
+
def classify(image):
|
8 |
+
results = classifier(image)
|
9 |
+
top = results[0]
|
10 |
+
label = top['label']
|
11 |
+
score = round(top['score'] * 100, 2)
|
12 |
+
return f"{label} ({score}%)"
|
13 |
+
|
14 |
+
gr.Interface(fn=classify, inputs=gr.Image(type="pil"), outputs="text", title="Cat Classifier").launch()
|