minima / app.py
mathewka's picture
Update app.py
4d7e42f verified
raw
history blame contribute delete
789 Bytes
import gradio as gr
from fastai.vision.all import *
def is_cat(x): return x[0].isupper()
if platform.system().lower() == "windows":
import pathlib
posix_path = pathlib.PosixPath
pathlib.PosixPath = pathlib.WindowsPath
learner=load_learner("model.pkl")
if platform.system().lower() == "windows":
pathlib.PosixPath = posix_path
categories=('Dog','Cat')
def classify_image(img):
pred,idx,prob=learner.predict(img)
return dict(zip(categories,map(float,prob)))
image=gr.inputs.Image(shape=(192,192))
label=gr.outputs.Label()
examples=['dog.jpg','cat.jpg','unknown.jpg','cat_2.jpg']
intf=gr.Interface(fn=classify_image,inputs=image,outputs=label,examples=examples)
intf.launch(inline=False)
demo = gr.Interface(fn=greet, inputs="text", outputs="text")
demo.launch()