File size: 465 Bytes
c42238a 30426b0 c42238a 787ac18 c42238a 787ac18 c42238a | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | 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) |