File size: 506 Bytes
38aadeb
 
a91cddc
 
38aadeb
a91cddc
38aadeb
a91cddc
38aadeb
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
from fastai.vision.all import *
from pathlib import Path
import gradio as gr

learn = load_learner('aih_model.pkl')

categories = ('AI Hand', 'Human Hand')

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

image = gr.Image(shape=(512,512))
label = gr.Label()
examples = [str(x) for x in Path('./samples').glob('*')]

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