Spaces:
Runtime error
Runtime error
| #Import necessary libraries | |
| import gradio as gr | |
| from fastai.vision.all import * | |
| import skimage | |
| bear_learner = load_learner('export.pkl') | |
| #Create function that accepth image path and | |
| labels = bear_learner.dls.vocab | |
| def predict(img): | |
| img = PILImage.create(img) | |
| pred, idx, probs = bear_learner.predict(img) | |
| return {labels[i]: round(float(probs[i]), 2) for i in range(len(labels))} | |
| examples = ["black_bear.jpg", "teddy_bear.jpg"] | |
| #interface = | |
| gr.Interface(fn=predict,inputs=gr.inputs.Image(shape=(512, 512)), outputs=gr.outputs.Label()).launch() |