File size: 576 Bytes
62ead1b 60c56bd 36f6e50 593ed83 62ead1b 60c56bd 36f6e50 2b49a10 444179e 593ed83 bf8d52c 444179e ea6d7fc 444179e |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
import pathlib
import platform
if platform.system()=='Linux': pathlib.WindowsPath=pathlib.PosixPath
import dill
import gradio as gr
with open('model_dill.pkl','rb') as f: learn=dill.load(f)
labels=['Dog','Cat']
def predict(img):
from fastai.vision.all import PILImage
img=PILImage.create(img)
pred,pred_idx,probs=learn.predict(img)
return {labels[i]:float(probs[i]) for i in range(len(labels))}
gr.Interface(
fn=predict,
inputs=gr.Image(type="pil"),
outputs=gr.Label(num_top_classes=2),
examples=['dog.jpg','cat.jpg','dcat.jpg']
).launch() |