|
__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(), |
|
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) |
|
|
|
|
|
|