File size: 968 Bytes
2995784
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
from fastai.vision.all import *
import gradio as gr

learn = load_learner('export.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))}

title = "Food 101 Classifier"
description = "A Food 101 Classifier created using Custom Dataset from Kaggle. Created as a demo for Gradio and HuggingFace Spaces."
article="<p style='text-align: center'><a href='https://satish1v.medium.com/' target='_blank'>Blog post coming soon</a></p>"
enable_queue=True
examples = ['1005649.jpg']


demo=gr.Interface(fn=predict, 
                    inputs=gr.inputs.Image(shape=(460, 460)),
                    outputs= gr.outputs.Label(num_top_classes=len(labels)),
                    title=title,
                    description=description,
                    article=article,
                    examples=examples
                   )

demo.lauch()