Spaces:
Sleeping
Sleeping
| 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() | |