Spaces:
Sleeping
Sleeping
import gradio as gr | |
from fastai.vision.all import * | |
import PIL | |
def is_cat(x): return x[0].isupper() | |
learned = load_learner('model.pkl') | |
labels = learned.dls.vocab | |
def predict (img): | |
img = PILImage.create(img) | |
pred, pred_idx, probs = learned.predict(img) | |
return dict(zip(labels, map(float, probs))) | |
title = "Cat Predictor" | |
examples= ["tabby.jpg"] | |
iface = gr.Interface(fn=predict, title=title, examples=examples, inputs=gr.inputs.Image(shape=(512, 512)), outputs=gr.outputs.Label(num_top_classes=3)) | |
iface.launch(debug=True) |