kgrv's picture
v0.1 of multiclass image classification
4ef584e
Raw History Blame Contribute Delete
456 Bytes
from fastai.vision.all import *
import gradio as gr
learn = load_learner('model.pkl')
categories = ['bird', 'cat', 'dog', 'forest']
def classify_image(img):
pred, idx, probs = learn.predict(img)
return dict(zip(categories, map(float, probs)))
image = gr.Image(type="pil")
label = gr.Label()
interface = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=['bird.jpg', 'cat.jpg', 'dog.jpg', 'forest.jpg'])
interface.launch()