Spaces:
Sleeping
Sleeping
from fastai.vision.all import * | |
import gradio as gr | |
import pathlib | |
plt = platform.system() | |
if plt == 'Windows': | |
pathlib.PosixPath = pathlib.WindowsPath | |
if plt == 'Linux': | |
pathlib.WindowsPath = pathlib.PosixPath | |
def label_func(x): | |
if int((x.split('.')[0].lstrip('0'))) <= 5: | |
return 'Mogged' | |
else: | |
return 'Mogger' | |
learn = load_learner('mommodel.pkl') | |
categories = {'Mogger', 'Mogged'} | |
def classify_img(image): | |
# what, _t , _ = learn.predict(image) | |
# return what | |
pred, idx, probs = learn.predict(image) | |
return dict(zip(categories, map(float, probs))) | |
# image = gr.Image(shape=(224,224)) | |
image = gr.Image() | |
label = gr.Label() | |
examples = ['001.jpg','002.jpg','007.jpg','008.jpg','004.jpg'] | |
intf = gr.Interface(fn=classify_img, inputs=image, outputs=label, examples=examples) | |
intf.launch(inline=False) |