Spaces:
Sleeping
Sleeping
from fastai.vision.all import * | |
import gradio as gr | |
import skimage | |
learn = load_learner('bearmodel.pkl') | |
labels = learn.dls.vocab | |
def predict(img): | |
img = PILImage.create(img) | |
pred,pred_idx,probs = learn.predict(img) | |
return {labels[i]: float(probs[i]) for i in range(len(labels))} | |
title = "Bear Breed Classifier" | |
description = "A bear breed classifier trained on a custom dataset from DDG images with fastai. Created as a demo for Gradio and HuggingFace Spaces." | |
#interpretation ='default' | |
image = gr.Image(height=192, width=192) | |
label = gr.Label() | |
examples = [['black bear.jfif'], ['grizzly bear.jfif'], ['teddy bear.jfif']] | |
#enable_queue=True | |
intf = gr.Interface(fn=predict, inputs=image, outputs=label, title=title, description=description,examples=examples) | |
intf.launch(inline=False) | |
#def greet(name): | |
# return "Hello " + name + "!!" | |
#demo = gr.Interface(fn=greet, inputs="text", outputs="text") | |
#demo.launch() |