jadavis's picture
Another fix
f953b0c
raw
history blame contribute delete
458 Bytes
from fastai.vision.all import *
import gradio as gr
learn=load_learner("model.pkl")
labels=learn.dls.vocab
def sample_predict(img):
print(img)
img = PILImage.create(img)
pred,pred_idx,probs=learn.predict(img)
return {labels[i]: float(probs[i]) for i in range(len(labels))}
intf=gr.Interface(fn=sample_predict,
inputs=gr.components.Image(shape=(256, 256)),
outputs=gr.components.Label())
intf.launch()