File size: 659 Bytes
ab4921f
 
8aa942e
ab4921f
 
 
8aa942e
 
 
 
 
 
 
 
98913b7
e34d20e
8aa942e
 
 
98913b7
8aa942e
2558bf4
8aa942e
e34d20e
8aa942e
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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 = ['images/pizza.jpg', 'images/pasta.jpg', 'images/dunno.jpg']

app = gr.Interface(fn=classify_image,
                   inputs=image,
                   outputs=gr.Textbox(label="Output"),
                   examples=examples)
app.launch()