bird_classifier / app.py
satani's picture
Update app.py
85617fa
raw
history blame
597 Bytes
from fastai.vision.all import *
import gradio as gr
learner = load_learner('export.pkl')
labels = learner.dls.vocab
def predict(img):
img = PILImage.create(img)
pred, pred_idx, probs = learner.predict(img)
return {labels[i]: float(probs[i]) for i in range(len(labels))}
examples = ['1.jpg', '2.jpg', '3.jpg', '4.jpg', '5.jpg', '6.jpg', '7.jpg', '8.jpg', '9.jpg', '10.jpg', '11.jpg', '12.jpg', '13.jpg', '14.jpg', '15.jpg']
gr.Interface(fn=predict, inputs=gr.inputs.Image(shape=(224, 224)), outputs=gr.outputs.Label(num_top_classes=3), examples=examples).launch(share=True, debug=True)