import timm | |
from fastai.vision.all import * | |
import gradio as gr | |
path = Path() | |
path | |
learn = load_learner('export.pkl') | |
labels = learn.dls.vocab | |
def roofpredict(img): | |
img = PILImage.create(img) | |
img = img.to_thumb(500,500) | |
pred,pred_idx,probs = learn.predict(img) | |
return {labels[i]: float(probs[i]) for i in range(len(labels))} | |
title = "Chocolate Classifier" | |
interpretation='default' | |
enable_queue=True | |
gr.Interface(fn=roofpredict, inputs="image", outputs="label",title=title).launch() |