rpa45's picture
simple interface built
38aadeb
raw
history blame
506 Bytes
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()