Spaces:
Runtime error
Runtime error
File size: 612 Bytes
8cf2d92 6a8b6a9 8cf2d92 d3f7ee1 6a8b6a9 8cf2d92 7fddb45 8cf2d92 7fddb45 8cf2d92 7fddb45 8cf2d92 7fddb45 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
from fastai.vision.all import *
import gradio as gr
#|export
learn = load_learner('export.pkl')
#|export
categories = learn.dls.vocab
def classify_image(inp):
pred, pred_idx, probs = learn.predict(inp)
return dict(zip(categories, map(float, probs)))
image = gr.inputs.Image(shape=(128, 128))
label = gr.outputs.Label(num_top_classes=3)
examples = ['teddy_1.jpg', 'grizzly_1.jpg', 'black_bear.jpg']
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples, title='Bear Classifier', description='An AI that identifies bears')
if __name__ == '__main__':
intf.launch()
|