Spaces:
Runtime error
Runtime error
File size: 1,187 Bytes
8d0eeb9 1022a9c | 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 | #Importing necessary libraries
import gradio as gr
from fastai.vision.all import *
#Load the model
learn = load_learner("export.pkl")
#Identify labels from the dataloaders class
labels = learn.dls.vocab
#Define function for making prediction
def predict(img):
img = PILImage.create(img)
pred, idx, probs = learn.predict(img)
return {labels[i]: float(probs[i]) for i in range(len(labels))}
#Customizing the gradio interface
title = "Classification between Zebras and Elephants"
description = "An Zebra_Elephant classifier that was trained using Zindi Dataset, Using Fastai framework."
article="<p style='text-align: center'><a href='https://zindi.africa/competitions/sbtic-animal-classification' target='_blank'>Link to Zindi competition</a></p>"
examples = ['zebra.jpeg', 'zebra2.jpeg', 'elephant.jpeg', 'elephant2.jpeg']
enable_queue=True
#Launching the gradio application
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,
enable_queue=enable_queue).launch(inline=False) |