Spaces:
Runtime error
Runtime error
File size: 609 Bytes
f3ec3b5 5e7bfba bf7037d 5e7bfba f3ec3b5 81d9678 f3ec3b5 81d9678 f3ec3b5 ab927e7 f3ec3b5 ab927e7 76d190b | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | from fastai.vision.all import *
import gradio as gr
import skimage
learn = load_learner('model.pkl')
labels = learn.dls.vocab
def classify_image(img):
img = PILImage.create(img)
pred,pred_idx,probs = learn.predict(img)
return {labels[i]: float(probs[i]) for i in range(len(labels))}
image = gr.inputs.Image(shape=(192,192))
label = gr.outputs.Label()
examples = ['grizzly bear.png', 'black bear.png', 'teddy bear.png']
demo = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples, title="Image Classifier", description="Upload an image to classify it.")
demo.launch()
|