File size: 656 Bytes
ee2159b 5b6f824 c02d05a ee2159b 5a286da ee2159b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
import gradio as gr
from fastai.vision.all import *
#this needs to be included for finding file path for some reason
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() |