Spaces:
Sleeping
Sleeping
| 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 = 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 trained on the Oxford Pets dataset with fastai. Created as a demo from the course by Jeremy Howard." | |
| article="<p style='text-align: center'><a href='https://course.fast.ai/' target='_blank'>Go to course</a></p>" | |
| examples = ['siamese.jpg','pug.jpg'] | |
| interpretation='default' | |
| enable_queue=True | |
| gr.Interface(fn=predict, | |
| inputs=gr.inputs.Image(shape=(512, 512)), | |
| outputs=gr.outputs.Label(num_top_classes=3), | |
| title=title, | |
| description=description, | |
| article=article, | |
| examples=examples, | |
| interpretation=interpretation, | |
| enable_queue=enable_queue).launch() |