Spaces:
Sleeping
Sleeping
from fastai.vision.all import PILImage, load_learner | |
from gradio import Interface | |
from gradio.components import Image, Label | |
TITLE = "Chicken Breed Classifier" | |
DESCRIPTION = """A chicken breed classifier trained using the dataset here: https://www.kaggle.com/datasets/edkenthazledine/chicken-breeds | |
There are many breeds of chicken, and getting lots of pictures of them is hard! | |
This can identify (to varying degrees of accuracy, the model is ~90% accurate): American Gamefowl, Australorp, Burford Brown, Crevecoeur, Derbyshire Redcap, Easter Egger, Light Sussex, Sapphire Gem, Speckled Sussex, Wyandotte | |
""" | |
EXAMPLES = ["wyandotte.jpg"] | |
learn = load_learner("export_10b_90p.pkl") | |
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))} | |
iface = Interface( | |
fn=predict, | |
inputs=Image(shape=(512, 512)), | |
outputs=Label(num_top_classes=3), | |
title=TITLE, | |
description=DESCRIPTION, | |
examples=EXAMPLES, | |
) | |
iface.launch(enable_queue=True) | |