File size: 1,005 Bytes
ae2df06
db919db
 
 
 
 
f3228d9
eff928d
db919db
 
 
 
 
 
 
 
09433ab
 
dd1ca89
db919db
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
__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)