kev12321's picture
Upload 6 files
d41e637 verified
raw
history blame contribute delete
780 Bytes
from fastai.vision.all import *
learn = load_learner('orange_cats.pkl')
labels = learn.dls.vocab
def predict(img):
img = PILImage.create(img)
pred,pred_idx,probs = learn.predict(img)
return {labels[i]: float(probs[i]) for i in range(len(labels))}
import gradio as gr
title = "Cat, croissant, leaves, or yellow tiles?"
description = "This model can classify images into 4 categories: cat, croissant, leaves, or yellow tiles. Upload an image or click an example image to test the model."
examples =['examples/cat.jpg', 'examples/Croissant.png', 'examples/leaves.jpg', 'examples/Tiles.jpg']
gr.Interface(fn=predict,examples=examples, title=title,description=description,inputs=gr.Image(), outputs=gr.Label(num_top_classes=3)).launch(share=True)