Spaces:
No application file
No application file
__all__ = ['categories', 'image', 'label', 'examples', 'intf', 'is_cat', 'classify_image'] | |
from fastai.vision.all import * | |
import gradio as gr | |
def is_cat(x): | |
return x[0].isupper() | |
categories = ('Dog', 'Cat') | |
learn = load_learner('model.pkl') | |
def classify_image(img): | |
pred, idx, probs = learn.predict(img) | |
return dict(zip(categories, map(float, probs))) | |
image = gr.components.Image(height = 192, width = 192) | |
label = gr.components.Label() | |
examples = ['example-dog.jpg', 'example-cat.jpg'] | |
intf = gr.Interface(fn = classify_image, inputs = image, outputs = label, examples = examples) | |
intf.launch(inline = False, share=True) | |