lordsquirrel's picture
Improved model quite a lot
5056593
raw
history blame
1.11 kB
# AUTOGENERATED! DO NOT EDIT! File to edit: model-test.ipynb.
# %% auto 0
__all__ = ['plt', 'learn', 'categories', 'description', 'image', 'label', 'examples', 'iface', '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
# %% model-test.ipynb 7
learn = load_learner(Path('./resnet18-albani.pkl'))
categories = ('God Øl', 'Dårlig Øl')
def classify_image(img):
pred,idx,probs = learn.predict(img)
return dict(zip(categories, map(float, probs)))
description = """
## Er du i tvivl om at den øl du sidder med i hånden lige, nu er god?
### Tvivl ej 68 års invotation inden for machine learning skal nok fortælle dig om øllen er god eller ej
"""
image = gr.Image(shape=(192, 192))
label = gr.Label()
examples = ['albani.jpg', 'albani2.jpg', 'albani3.jpg', 'heineken.jpg', 'carlsberg.jpg']
iface = gr.Interface(
fn=classify_image,
inputs=image,
outputs=label,
examples=examples,
description=description,
)
iface.launch(inline=False)