File size: 858 Bytes
5a0cfaa
5a3f9c7
e5e6249
5a0cfaa
f6c9658
 
326e781
 
 
 
5a0cfaa
 
 
 
9c4a810
 
5a0cfaa
b937508
5a0cfaa
b937508
5a0cfaa
 
b937508
 
 
 
e5e6249
60d17b1
 
5a0cfaa
cd78c4a
e5e6249
5a0cfaa
 
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

from fastai.vision.all import * 
import gradio as gr

import pathlib
plt = platform.system()
if plt == 'Windows': 
    pathlib.PosixPath = pathlib.WindowsPath
if plt == 'Linux': 
    pathlib.WindowsPath = pathlib.PosixPath

def label_func(x):
    if int((x.split('.')[0].lstrip('0'))) <= 5:
        return 'Mogged'
    else:
        return 'Mogger'
    
learn = load_learner('mommodel.pkl')

categories = {'Mogger', 'Mogged'}

def classify_img(image):
    # what, _t , _ = learn.predict(image)
    # return what
    pred, idx, probs = learn.predict(image)
    return dict(zip(categories, map(float, probs)))

# image = gr.Image(shape=(224,224))
image = gr.Image()
label = gr.Label()
examples = ['001.jpg','002.jpg','007.jpg','008.jpg','004.jpg']

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