File size: 629 Bytes
355dd78
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#|export
from fastai.vision.all import *
import gradio as gr

#|export
learn = load_learner('model.pkl')

#|export
def output(img):
    predict,index,probs = learn.predict(img)
    probs = torch.max(probs)
    return f'The picture is appear to be {predict} with probability = {probs}'

#|export
image = gr.inputs.Image(shape=(192,192))
label = gr.outputs.Label()
examples = ['images/bean.jpg', 'images/tesla.jpg', 'images/Boeing.jpg', 'images/bird.jpg', 'images/boat.jpg',
           'images/french.jpg','images/fat-cat.jpg']
intf = gr.Interface(fn=output, inputs=image, outputs=label, examples=examples)
intf.launch(inline=True)