Spaces:
Sleeping
Sleeping
File size: 1,448 Bytes
91b5a3c f191270 9149a8c d333068 91b5a3c 751cccd e1f850a 91b5a3c 332b9fc 453a486 332b9fc 453a486 332b9fc d333068 91b5a3c 6b0db57 95d80ff 91b5a3c 6b0db57 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
from fastai.vision.all import *
from fastai.learner import load_learner
from huggingface_hub import from_pretrained_fastai, hf_hub_download
import gradio as gr
import skimage
learn = load_learner('PetNet50.pkl')
# learn = from_pretrained_fastai("kurianbenoy/course_v5_lesson2_pets_convnext_base_in22k")
#learn = load_learner(
# hf_hub_download("kurianbenoy/course_v5_lesson2_pets_convnext_base_in22k", "model.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))}
title = "Pet Breed Classifier"
description = """
🐶🐱
🇬🇧 = A pet breed classifier (Dogs and Cats) trained on the Oxford Pets dataset using fastai. Created as a demo from the course by Jeremy Howard.
For best results use photos of your pets.
🇪🇸 = Un clasificador de razas de mascotas (perros y gatos) entrenado en el dataset Oxford Pets.
Usa fotos de tus mascotas para obtener la raza.
👨👨👧👦 CZDJ ❤️
"""
article="<p style='text-align: center'><a href='https://course.fast.ai/' target='_blank'>Go to course!</a></p>"
examples = ['siamese.jpg','pug.jpg']
gr.Interface(fn=predict,
inputs=gr.Image(),
outputs=gr.Label(num_top_classes=3),
title=title,
description=description,
article=article,
examples=examples).launch()
|