deelight-del's picture
Updated app.py gradio method to use inline not share
1022a9c
#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)