Spaces:
Runtime error
Runtime error
from fastai.vision.all import * | |
import gradio as gr | |
learner = load_learner('export.pkl') | |
labels = learner.dls.vocab | |
def predict(img): | |
img = PILImage.create(img) | |
pred, pred_idx, probs = learner.predict(img) | |
return {labels[i]: float(probs[i]) for i in range(len(labels))} | |
image = gr.inputs.Image(shape=(224, 224)) | |
label = gr.outputs.Label() | |
examples = ['1.jpg', '2.jpg', '3.jpg'] | |
gr.Interface(fn=predict, inputs=gr.inputs.Image(shape=(224, 224)), outputs=gr.outputs.Label(num_top_classes=3), examples=examples).launch(share=True, debug=True) |