File size: 761 Bytes
84d2700
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

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)