cotel557
Fix bug
0714d9a
raw
history blame contribute delete
808 Bytes
from fastai.vision.all import *
import gradio as gr
learn = load_learner('export.pkl')
labels = learn.dls.vocab
def predict(img_fnm):
img = PILImage.create(img_fnm)
pred, pred_idx, probs = learn.predict(img)
return {label: float(prob) for label, prob in zip(labels, probs)}
title = "Moody-nana Classifier"
description = "Classifies an image as either happy, angry, or banana."
examples = [
"examples/angry-banana.jpg",
"examples/angry.jpg",
"examples/happy.jpg",
"examples/banana.jpg"
]
interpretation = "default"
enable_queue = True
intf = gr.Interface(
fn=predict,
inputs=gr.components.Image(shape=(512, 512)),
outputs=gr.components.Label(),
title=title,
description=description,
examples=examples,
interpretation=interpretation
)
intf.launch()