CoolFace
Apppublic

S6six/fast_ai_pet_classifier

sourceHugging Faceupdated 3y agoView on Hugging Face
0likes
app.py23 linesDownload Raw Back to root
1import gradio as gr2from fastai.vision.all import *3import skimage4 5import pathlib6plt = platform.system()7if plt == 'Linux': pathlib.WindowsPath = pathlib.PosixPath8 9learn = load_learner('export.pkl')10labels = learn.dls.vocab11def predict(img):12    img = PILImage.create(img)13    pred, idx, probs = learn.predict(img)14    return{labels[i]: float(probs[i]) for i in range(len(labels))}15 16title = "Breed Classifier"17description = "A animal/pet Breed Classifier"18examples = ['cat.jpg.webp']19interpretation = 'default'20enable_queue = True21 22gr.Interface(fn = predict, inputs = gr.Image(), outputs = gr.Label(num_top_classes = 3), title = title, description = description , examples = examples).launch(share=True)23