Spaces:
Sleeping
Sleeping
File size: 584 Bytes
47a908c b5ef0b7 303967f 47a908c b5ef0b7 47a908c b5ef0b7 47a908c 3120f44 755dd7f b5ef0b7 3120f44 47a908c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
import gradio as gr
from fastai.vision.all import *
# Load the learner
learn = load_learner('export (1).pkl')
# Get the labels from the learner's dataloaders
labels = learn.dls.vocab
# Set up Gradio interface
title = "Bird or Not?"
description = "A classifier that detects birds using ResNet18"
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))}
# Set up the Gradio interface with the predict function
gr.Interface(fn=predict,inputs="image",outputs="label").launch()
|