pdlc / app.py
Matt Fisher
Add app and example images
bd4d803
raw
history blame contribute delete
589 Bytes
from fastai.vision.all import *
import gradio as gr
learn = load_learner("model.pkl")
categories = ["black", "grizzly", "teddy"]
def classify_image(img):
prediction, idx, prob = learn.predict(img)
return {category: float(prob[i]) for (i, category) in enumerate(categories)}
image = gr.components.Image(shape=(224, 224))
label = gr.components.Label(num_top_classes=3)
examples = ["images/black.jpeg", "images/grizzly.jpeg", "images/teddy.jpeg"]
interface = gr.Interface(
fn=classify_image, inputs=image, outputs=label, examples=examples,
)
interface.launch(inline=False)