|
import gradio as gr |
|
from fastai.vision.all import * |
|
|
|
import pathlib |
|
plt = platform.system() |
|
if plt == 'Linux': pathlib.WindowsPath = pathlib.PosixPath |
|
|
|
learn = load_learner('model.pkl') |
|
|
|
categories = ('Flower','Sunflower') |
|
|
|
def classify(img): |
|
pred,_,probs = learn.predict(img) |
|
return dict(zip(categories, map(float,probs))) |
|
|
|
image = gr.inputs.Image(shape=(192,192)) |
|
label = gr.outputs.Label() |
|
examples = ['0.png','1.png','2.png','3.png','4.png','5.png','6.png','7.png','8.png','9.png'] |
|
|
|
iface = gr.Interface(fn=classify, inputs=image, outputs=label, examples=examples) |
|
iface.launch() |