Spaces:
Runtime error
Runtime error
from fastai.vision.all import * | |
from fastai.text.all import * | |
from fastai.collab import * | |
from fastai.tabular.all import * | |
# import pathlib | |
# temp = pathlib.PosixPath | |
# pathlib.PosixPath = pathlib.WindowsPath | |
import gradio as gr | |
learn = load_learner('model.pkl') | |
categories = ('golden', 'not golden') | |
def classify_img(img): | |
pred, pred_idx, probs = learn.predict(img) | |
return dict(zip(categories, map(float, probs))) | |
image = gr.inputs.Image(shape=(192, 192)) | |
label = gr.outputs.Label(num_top_classes=2) | |
#examples = ["golden_retriever.jpg", "cat.jpg", "dog.jpg"] | |
intf = gr.Interface(fn=classify_img, inputs=image, outputs=label) | |
intf.launch(inline=False) |