import gradio as gr from fastcore.all import * from fastai.vision.all import * # import pathlib # temp = pathlib.PosixPath # pathlib.PosixPath = pathlib.WindowsPath 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 = "my little Food Classifier" description = "My first Food Classifier trained on some food I know. I made this to learn making models in fastAI and deploying them. " examples = ['barfi.webp',"brocoli.jfif","dal.jpg","gulabjamun.jfif","jalebi.jpg","ladoo.webp","pakora.webp","samosa.webp"] interpretation='default' enable_queue=True gr.Interface(fn=predict,inputs=gr.inputs.Image(shape=(512, 512)),outputs=gr.outputs.Label(num_top_classes=5),title=title,description=description,examples=examples,interpretation=interpretation,enable_queue=enable_queue).launch()