pets_classify / app.py
neilkazimierzsheridan
alter code
6665a29
raw
history blame contribute delete
696 Bytes
from fastai.vision.all import *
import skimage
import gradio as gr
learn = load_learner('export_pets.pkl') #this is a kinda dog detector it seems
labels = learn.dls.vocab
def predict(img):
img = PILImage.create(img)
pred,pred_idx,probs = learn.predict(img)
return {labels[i]: float(probs[i]) for i in range(len(labels))}
gr.Interface(fn=predict,
title="Pet Breed Classifier",
description="Pet breed classifier using Oxford Pets Database. Test for Gradio and HuggingFace",
inputs=gr.Image(width=512, height=512), #this is the proper syntax for images not the (shape=(xxx,xxx))
outputs=gr.Label(num_top_classes=3)).launch(share=True)