Spaces:
Runtime error
Runtime error
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() | |