minimal / app.py
dgwyer's picture
updates
d910a75
raw
history blame
589 Bytes
# Import libraries
from fastai.vision.all import *
import gradio as gr
# Load model
learn = load_learner('labrador.pkl')
# Define categories
categories = ('Black', 'Golden')
# Define function to classify image
def classify_image(img):
pred, idx, probs = learn.predict(img)
return dict(zip(categories, map(float, probs)))
# Define Gradio interface
image = gr.inputs.Image(shape=(192, 192))
label = gr.outputs.Label()
examples = ['black.jpg', 'golden.jpg', 'banana.jpg']
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
intf.launch(inline=False)