Spaces:
Runtime error
Runtime error
File size: 597 Bytes
96032dc 9320334 1fbfecc 9320334 82c1275 85617fa acf2b04 9320334 1fbfecc |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
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))}
examples = ['1.jpg', '2.jpg', '3.jpg', '4.jpg', '5.jpg', '6.jpg', '7.jpg', '8.jpg', '9.jpg', '10.jpg', '11.jpg', '12.jpg', '13.jpg', '14.jpg', '15.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) |