File size: 744 Bytes
40e0f09
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12627df
ed36f2c
40e0f09
 
0948e6d
40e0f09
 
 
 
 
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
28
29
30
31
32
33
34
35
36
37
import gradio as gr
from fastai.vision.all import *

# def greet(name):
#     return "Hello " + name + "!!"

# demo = gr.Interface(fn=greet, inputs="text", outputs="text")
# demo.launch()


im = PILImage.create('victory.jpg')
im
learn = load_learner('clean_model.pkl')

learn.predict(im)

categories = ('victory hand sign photo','thumbs up human hand', 'thumbs down human hand')

def classify_image(img):
    pred,idx,probs = learn.predict(img)
    return(dict(zip(categories,map(float,probs))))

print(classify_image(im))


##
image = gr.Image(width=500, height = 256)
label = gr.Label()
examples = ['victory.jpg']

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