Spaces:
Sleeping
Sleeping
from fastai.vision.all import * | |
import gradio as gr | |
def label_func(x): | |
if "Raven" in x.parent.name: | |
return "raven" | |
else: | |
return "crow" | |
categories = ("raven", "crow") | |
def classify_image(img): | |
pred, idx, probs = learn.predict(img) | |
return dict(zip(categories, map(float,probs))) | |
learn = load_learner("model.pkl") | |
image = gr.inputs.Image(shape=(400, 400)) | |
label = gr.outputs.Label() | |
examples = ["examples/crow.jpg", "examples/raven.jpg"] | |
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples) | |
intf.launch(inline=False) |