lordsquirrel's picture
Initial release
0d5acf9
raw
history blame
915 Bytes
# AUTOGENERATED! DO NOT EDIT! File to edit: model-test.ipynb.
# %% auto 0
__all__ = ['plt', 'learn', 'categories', 'image', 'label', 'examples', 'iface', 'is_albani', 'classify_image']
# %% model-test.ipynb 2
from fastai.vision.all import *
import pathlib
import gradio as gr
plt = platform.system()
if plt == 'Linux': pathlib.WindowsPath = pathlib.PosixPath
def is_albani(path):
return parent_label(path) == "albani"
# %% model-test.ipynb 7
learn = load_learner(Path('./resnet18-albani.pkl'))
categories = ('Dårlig Øl', 'God Øl')
def classify_image(img):
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 = ['albani.jpg', 'albani2.jpg', 'heineken.jpg', 'carlsberg.jpg']
iface = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
iface.launch(inline=False)