Spaces:
Runtime error
Runtime error
File size: 687 Bytes
5b609f4 d1ab4e2 5b609f4 2427c60 e567656 5b609f4 e567656 aad814b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# import all the fastai stuff.
from fastai.vision.all import *
def is_cat(x): return x[0].isupper()
# load our model.
learn = load_learner('model.pkl')
# define a prediction function, not sure what this means.
labels = learn.dls.vocab
def predict(img):
img = PILImage.create(img)
# this returns
# predicted category
# index
# probabilities of each category
pred,pred_idx,probs = learn.predict(img)
# we return a weird dictionary or JSON?
return {labels[i]: float(probs[i]) for i in range(len(labels))}
import gradio as gr
gr.Interface(fn=predict, inputs=gr.inputs.Image(shape=(512, 512)), outputs=gr.outputs.Label(num_top_classes=3)).launch() |