cat-detector-v2 / app.py
thejb2014's picture
Create app.py
c0cb33b verified
raw
history blame contribute delete
430 Bytes
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()