satish860's picture
My initial check-in
2995784
raw
history blame contribute delete
968 Bytes
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()