Spaces:
Runtime error
Runtime error
from fastai.vision.all import * | |
import gradio as gr | |
import pathlib, os | |
# def greet(name): | |
# return "Hello " + name + "!!!!" | |
def is_cat(x): return x[0].isupper() | |
categories = ['Dog', 'Cat'] | |
def classify_image(img): | |
if os.name == 'nt': # workaround for Windows | |
pathlib.PosixPath = pathlib.WindowsPath | |
learn = load_learner('model_cat-or-dog.pkl') | |
pred,idx,probs = learn.predict(img) | |
return dict(zip(categories, map(float, probs))) | |
image = gr.inputs.Image(shape=(192,192)) | |
label = gr.outputs.Label() | |
examples = ['img_20180720_163054.jpg', 'img_20210614_141029.jpg', 'img_20210614_140945.jpg', 'img_20210613_193627.jpg', 'img_20210613_184022.jpg', 'cat.4764.jpg', 'cat.4782.jpg'] | |
iface = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples) | |
iface.launch() |