bird-classifier / app.py
pkarthik15's picture
Upload 4 files
87da3c4
raw
history blame
527 Bytes
import gradio as gr
from fastai.vision.all import *
model = load_learner('bird-classifier-model.pkl')
labels = model.dls.vocab
def greet(name):
return f"Hello {name} !!"
def predict(img):
pred, pred_idex, probs = model.predict(img)
return {labels[i] : float(probs[i]) for i in range(len(labels))}
ip = gr.inputs.Image(shape=(512, 512))
op = gr.outputs.Label(num_top_classes=2)
example = ['bird.jpg', 'forest.jpg']
interface = gr.Interface(fn=predict, inputs=ip, outputs=op, examples=example)
interface.launch()