Spaces:
Sleeping
Sleeping
import gradio as gr | |
from fastai.vision.all import * | |
import skimage | |
def is_cat(x): return x[0].isupper() | |
learn = load_learner('model.pkl') | |
labels = learn.dls.vocab | |
categories = ('Dog', 'Cat') | |
def predict(img): | |
img = PILImage.create(img) | |
img.thumbnail((192, 192)) | |
pred,pred_idx,probs = learn.predict(img) | |
return dict(zip(categories, map(float, probs))) | |
examples = ['cat.jpeg', 'dog.jpeg',] | |
title = "Cat vs Dog classifier" | |
description = "Classification of dog and cat :)" | |
article="<p style='text-align: center'><a href='https://tmabraham.github.io/blog/gradio_hf_spaces_tutorial' target='_blank'>Blog post</a></p>" | |
gr.Interface(fn=predict, inputs="image", outputs="label",title=title,description=description,article=article,examples=examples).launch() |