File size: 637 Bytes
11d7443
 
6f9c310
11d7443
 
 
 
b3f3c73
11d7443
a27dbe8
11d7443
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4db70fc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#|export

#from fastcore.all import *
from fastai.vision.all import *
from fastbook import load_learner
import gradio as gr

inf = load_learner('LeopardCheetah (1).pkl')

categories = ('Cat', 'Cheetah', 'Other', 'Leopard', 'Lion', 'Snow Leopard', 'Tiger')

def classify_img(img):
    pred, idx, probs = inf.predict(img)
    return dict(zip(categories,map(float,probs)))

    #|export

#This creates the gradio interface

image = gr.Image(shape=(192,192))
label = gr.outputs.Label()

examples = ['cheetah.jpg','leopard.jpg','img.jpg']

intf = gr.Interface(fn = classify_img, inputs=image,outputs=label,examples = examples)

intf.launch()