ImageClassifier / app.py
sheteentz's picture
Update app.py
bf7037d verified
raw
history blame contribute delete
609 Bytes
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()