File size: 635 Bytes
8e2414f
 
95c5724
2497f7b
95c5724
 
 
 
 
 
3390643
95c5724
 
02d8da5
2497f7b
95c5724
2497f7b
95c5724
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
__all__ = ['learn', 'categories', 'classify_image', 'input_image', 'labels', 'intf']

from fastai.vision.all import *
import gradio
import nbdev

learn = load_learner('fast-food-model.pkl')

categories = ('Baked Potato', 'Burger', 'Crispy Chicken', 'Donut', 'Fries','Hot Dog','Pizza','Sandwich','Taco','Taquito')
def classify_image (image):
    pred,idx,probs = learn.predict(image)
    return dict(zip(categories, map(float, probs)))

input_image = gradio.inputs.Image(shape=(192, 192))
labels = gradio.outputs.Label()

intf = gradio.Interface(fn = classify_image, inputs = input_image, outputs = labels)
intf.launch(inline = False)