Spaces:
Runtime error
Runtime error
# Bismillahir Rahmaanir Raheem | |
# Almadadh Ya Gause Radi Allahu Ta'alah Anh - Ameen | |
from fastai.vision.all import * | |
import gradio as gr | |
def is_cat(x): | |
return x[0].isupper() | |
# load the trained fast ai model for predictions | |
learn = load_learner('model.pkl') | |
# define the function to call | |
categories = ('Dog', 'Cat') | |
def predict(img): | |
pred, idx, probs = learn.predict(img) | |
return dict(zip(categories, map(float, probs))) | |
title = "Cat or Dog Predictor" | |
description = "A cat or dog predictor model trained on the Pets dataset with fastai." | |
article = "<p style='text-align: center'><span style='font-size: 15pt;'>Cat or Dog Predictor. Zakia Salod. 2022. </span></p>" | |
image = gr.inputs.Image(shape=(512, 512)) | |
label = gr.outputs.Label() | |
examples = [ | |
['cat1.jpg'], | |
['dog1.jpg'], | |
['cat2.jpg'], | |
['dog2.jpg'], | |
['cat3.jpg'], | |
['dog3.jpg'], | |
] | |
interpretation = 'default' | |
enable_queue = True | |
iface = gr.Interface( | |
fn=predict, | |
title=title, | |
description=description, | |
article=article, | |
inputs=image, | |
outputs=label, | |
#theme="grass", | |
examples=examples, | |
interpretation=interpretation, | |
enable_queue=enable_queue | |
) | |
iface.launch(inline=False) | |