File size: 430 Bytes
c0cb33b
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import gradio as gr
from transformers import pipeline
from PIL import Image

classifier = pipeline("image-classification", model="microsoft/resnet-50")

def classify(image):
    results = classifier(image)
    top = results[0]
    label = top['label']
    score = round(top['score'] * 100, 2)
    return f"{label} ({score}%)"

gr.Interface(fn=classify, inputs=gr.Image(type="pil"), outputs="text", title="Cat Classifier").launch()