File size: 595 Bytes
4714b06
 
75ef911
15e37e5
3f658ad
 
 
 
4714b06
3f658ad
4714b06
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from fastai.vision.all import *
import gradio as gr
from pathlib import Path
import pathlib

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

categories = ('Man', 'Woman')
learner = load_learner('export.pkl')


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

inputs = gr.Image(height=224, width=224)
outputs = gr.Label()

examples = ['0.jpg', '71.jpg', '47.jpg', '19.jpg']

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