minimal / app.py
Overlord03's picture
Update app.py
f45b10a
raw
history blame contribute delete
No virus
686 Bytes
import gradio as gr
#| export (creating a gradio interface)
from fastai.vision.all import *
import pathlib
plt = platform.system()
if plt == 'Linux': pathlib.WindowsPath = pathlib.PosixPath
learn = load_learner("bear_model.pkl")
categories = ('black', 'grizzly', 'teddy')
def classify_image(img):
pred,idx,probs = learn.predict(img)
return dict(zip(categories, map(float, probs)))
image = gr.inputs.Image(shape=(192, 192))
label = gr.outputs.Label()
# example images
examples = ['blackbear.jpg', 'teddybear.jpg', 'grizzlybear.jpg']
# define interface below
intf = gr.Interface(fn=classify_image, inputs = image, outputs = label, examples=examples)
intf.launch(inline=False)