animals / app.py
Manan Daga
Fix classify_img to return a dictionary
787ac18
raw
history blame contribute delete
465 Bytes
import gradio as gr
from fastai.vision.all import *
learn = load_learner("model.pkl")
animal_list = ['cat', 'cow', 'deer', 'dog', 'donkey', 'goat', 'horse', 'pig', 'rabbit', 'sheep']
def classify_img(img):
animal, _, prob = learn.predict(img)
return dict(zip(animal_list, map(float, prob)))
image = gr.inputs.Image(shape=(192, 192))
label = gr.outputs.Label()
intf = gr.Interface(fn=classify_img, inputs=image, outputs=label)
intf.launch(inline=False)