testing / app.py
driveposter999's picture
yes
9b8e51b
Raw
History Blame
637 Bytes
import platform
import pathlib
if platform.system() == "Windows":
temp = pathlib.PosixPath
pathlib.PosixPath = pathlib.WindowsPath
from fastai.vision.all import *
import gradio as gr
learn = load_learner(Path("model.pkl"))
def classify_image(img):
pred, idx, probs = learn.predict(img)
return f"This is {pred}.\nConfidence Level: {float(max(probs))}"
image = gr.Image(shape=(192, 192))
examples = ['pizza.jpg', 'pasta.jpg', 'dunno.jpg']
app = gr.Interface(fn=classify_image,
inputs=image,
outputs=gr.Textbox(label="Output"),
examples=examples)
app.launch()