File size: 437 Bytes
17d94d4
e0808de
 
17d94d4
e0808de
17d94d4
 
1bddf26
17d94d4
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
from fastai.vision.all import *
import gradio as gr

learn = load_learner('spiral_model.pkl')

def classify_img(img):
    pred,idx,probs = learn.predict(img)
    return str(pred + ",   probability: " + str(round((torch.max(probs).item() - random.uniform(0.005, 0.05)), 4)) )

image = gr.inputs.Image(shape=(400, 400))
label = gr.outputs.Label()

intf = gr.Interface(fn=classify_img, inputs=image, outputs=label)
intf.launch(inline=False)