File size: 1,106 Bytes
0d5acf9 5056593 0d5acf9 5056593 0d5acf9 5056593 0d5acf9 6425640 c5fed56 3dd905b 5056593 0d5acf9 3dd905b 6425640 3dd905b 0d5acf9 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# 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)
|