|
from fastai.vision.all import* |
|
import gradio as gr |
|
from joblib import dump, load |
|
|
|
import pathlib |
|
plt = platform.system() |
|
if plt == 'Linux': pathlib.WindowsPath = pathlib.PosixPath |
|
|
|
learn = load_learner('model.pkl') |
|
im_bb = PILImage.create('samp_bb.jpg') |
|
im_lf = PILImage.create('samp_lf.jpg') |
|
im_other = PILImage.create('samp_other.jpg') |
|
|
|
categories = ('bb', 'lf', 'other') |
|
def classify_image(img): |
|
pred, idx, probs = learn.predict(img) |
|
return dict(zip(categories, map(float, probs))) |
|
|
|
image = gr.Image(height=500, width=500) |
|
label = gr.Label() |
|
examples = ['samp_lf.jpg', 'samp_other.jpg'] |
|
|
|
intf= gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples) |
|
intf.launch(inline=False) |