Spaces:
Runtime error
Runtime error
File size: 740 Bytes
fc5dcde e6609c2 f997537 a934642 e6609c2 68e639f 0e914bc 68e639f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
from fastai.learner import load_learner
import gradio as gr
learn = load_learner('model_cat_dog.pkl')
categories = ('Cat','Dog','Lion','None','Tiger','Wolf')
def classify_img(image):
pred,idx,probs = learn.predict(image)
return (dict(zip(categories,map(float,probs))))
image = gr.inputs.Image(shape=(192,192))
label = gr.outputs.Label()
examples = ['cat.jpg','food.jpg','tiger.jpg','cat_dog.jpg']
title = 'Simple classifier'
description = 'The model classifies input images into Dog, Cat, Lion, Tiger, Wolf classes. If the input image is not in target class, it is classified as None'
intf = gr.Interface(fn=classify_img, inputs=image, outputs=label,title=title,description=description,examples=examples)
intf.launch(inline=False) |