fastspace / app.py
averageandyyy's picture
message
2cf3b3c
raw
history blame contribute delete
852 Bytes
# AUTOGENERATED! DO NOT EDIT! File to edit: Bear Classifier (model uploaded).ipynb.
# %% auto 0
__all__ = ['model', 'categories', 'image', 'label', 'examples', 'intf', 'classify_images']
# %% Bear Classifier (model uploaded).ipynb 1
from fastai.vision.all import *
import gradio as gr
# %% Bear Classifier (model uploaded).ipynb 3
model = load_learner('model.pkl')
# %% Bear Classifier (model uploaded).ipynb 5
categories = ("black", "grizzly", "teddy")
def classify_images(img):
pred,idx,probs = model.predict(img)
return dict(zip(categories, map(float,probs)))
# %% Bear Classifier (model uploaded).ipynb 6
image = gr.inputs.Image(shape=(192, 192))
label = gr.outputs.Label()
examples = ['blackbear.jpg', 'bear.jpeg']
intf = gr.Interface(fn=classify_images, inputs=image, outputs=label, examples=examples)
intf.launch(inline=False)