bears / app.py
EvanMarie's picture
Update app.py
09433ab
__all__ = ['learner_bears', 'categories', 'classify_bears', 'image', 'label', 'examples', 'intf']
from fastai.vision.all import *
import gradio as gr
learner_bears = load_learner('bears.pk1')
categories = ['black bear', 'grizzly bear', 'teddy bear']
def classify_bears(img):
prediction, index, probability = learner_bears.predict(img)
return dict(zip(categories, map(float, probability)))
intf = gr.Interface(fn=classify_bears,
inputs=gr.Image(shape=(192, 192)),
outputs=gr.Label(),
title="Grizzlies and Teddies and Black Bears, OH MY!",
description="Input an image that is one of the three types of bears, and get an accurate result. OR put in an image of you and see which you most closely resemble! Most of all, just have fun!",
examples=['grizzly_bear.jpeg', 'black_bear.jpeg', 'teddy_bear.jpeg', 'bear01.jpg', 'bear06.jpg', 'bear03.jpg', 'bear05.jpg', 'bear04.jpg', 'bear02.jpg', 'not_sure.jpeg'])
intf.launch(inline=False)